SA-MP Forums Archive
error Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: error Help (/showthread.php?tid=105927)



error Help - Pinehole - 31.10.2009

Ok i have this team chat command
Код:
if(!strcmp("/d", cmdtext, true))
{
	new PlayerName[MAX_PLAYERS];
	new playername[MAX_PLAYER_NAME];
	new string[128];
	GetPlayerName(playerid, playername, sizeof(playername));
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	format(string, sizeof(string), "Police [%s]: ", playername)
 	if(gTeam[playerid] == TEAM_LSPD)
 	{
	SendClientMessage(playerid, COLOR_GOLD, string);
	}
	return 1;
	}
 	return 0;
}
I get this annoying error

Код:
 error 001: expected token: ";", but found "if"



Re: error Help - member - 31.10.2009

The Error message says it all. The compiler was looking for a ";" but instead it found an "if" statement.

Change:
pawn Код:
format(string, sizeof(string), "Police [%s]: ", playername)
to:
pawn Код:
format(string, sizeof(string), "Police [%s]: ", playername);
Hope that helps.


Re: error Help - Abernethy - 31.10.2009

Quote:
Originally Posted by [B2K
Hustler ]
The Error message says it all. The compiler was looking for a ";" but instead it found an "if" statement.

Change:
pawn Код:
format(string, sizeof(string), "Police [%s]: ", playername)
to:
pawn Код:
format(string, sizeof(string), "Police [%s]: ", playername);
Hope that helps.
That will fix your errors, but remember to indent your code. (Not sure if it's just the conversion)


Re: error Help - Pinehole - 31.10.2009

Ok thanks i have no errors, but when i use /d 'isaysomething' it shows up like [LSPD] Pinehole ,over
i want it to be chat for to do '/d hello' then it shows up like [LSPD] Pinehole: hello, over, please help


Re: error Help - member - 31.10.2009

you didnt format your string correctly to display the text.

Try this:

pawn Код:
if(!strcmp(cmdtext,"/d",true,2))
{
    if(!strlen(cmdtext[2])) return SendClientMessage(playerid, 0xAFAFAFAA, "USAGE: /d [text]");
    new playername[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, playername, sizeof(playername));
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        format(string, sizeof(string), "Police [%s]: %s, over", playername, cmdtext[2])
        if(gTeam[playerid] == TEAM_LSPD)
        {
            SendClientMessage(playerid, COLOR_GOLD, string);
        }
    }
    return 1;
}
I'd recommend using sscanf and zcmd. Hope that helps. Good Luck.


Re: error Help - Pinehole - 31.10.2009

Thanks it works , but it spams


Re: error Help - GhOstY93 - 31.10.2009

try this
pawn Код:
if(!strcmp("/d", cmdtext, true))
{
    new PlayerName[MAX_PLAYERS];
    new playername[MAX_PLAYER_NAME];
    new string[128];
    GetPlayerName(playerid, playername, sizeof(playername));
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    format(string, sizeof(string), "Police [%s]: %s",playername,cmdtext);
    if(gTeam[playerid] == TEAM_LSPD)
    {
    SendClientMessage(playerid, COLOR_GOLD, string);
    }
    return 1;
    }
    return 0;
}



Re: error Help - Pinehole - 31.10.2009

Nope it doesnt' work, can someone help me when i do /d <text> it spams


Re: error Help - member - 31.10.2009

Try this:

pawn Код:
if(!strcmp(cmdtext,"/d",true,2))
{
    if(!strlen(cmdtext[2])) return SendClientMessage(playerid, 0xAFAFAFAA, "USAGE: /d [text]");
    if(gTeam[playerid] != TEAM_LSPD) return SendClientMessage(playerid, 0xAFAFAFAA, "You must be a cop to use this command!");
    new playername[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, playername, sizeof(playername));
    format(string, sizeof(string), "Police [%s]: %s, over", playername, cmdtext[2])
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(gTeam[playerid] == TEAM_LSPD)
        {
            SendClientMessage(playerid, COLOR_GOLD, string);
        }
        return 1;
    }
    return 0;
}



Re: error Help - Pinehole - 31.10.2009

Works, thanks but will the TEAM_LSPD will be able to see it? or will the person whop typed it will see it?