SA-MP Forums Archive
[HELP] What is wrong with this? - 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: [HELP] What is wrong with this? (/showthread.php?tid=81970)



[HELP] What is wrong with this? - FreddeN - 15.06.2009

I have finaly fixed a police radio, but I only have 2 errors left to fix... but I cant figure it out.

Here is the script:

public OnPlayerCommandText(playerid, cmdtext[])

Код:
	if(strcmp(cmdtext , "/radio", true) == 0)
	{
    if(GetPlayerTeam(playerid) != 5) return SendClientMessage(playerid,COLOR_RED, "Identification Error - You need rank 1 to do this.");
			{
				if ((strlen(cmdtext) >= 1)&&(strlen(cmdtext) <= 3))
					{
            new string[128];
						new playername[MAX_PLAYER_NAME];
						GetPlayerName(playerid,playername,sizeof(playername));
						format(string,sizeof(string),"*Radio: %s:%s",playername,cmdtext[128]);
						SendCopMessage(COLOR_BLUE, string);
						return 1;
					}
			}
	}
	return 0;
}
On the bottom of my script.

Код:
SendCopMessage(color, text[]) {
  for(new i = 0; i < MAX_PLAYERS; i ++) {
  if(IsPlayerConnected(i)) {
  if(GetPlayerTeam(playerid) != 5)
      SendClientMessage(i, color, text);
      }
    }
  }
}
The errors:

error 017: undefined symbol "playerid"
error 054: unmatched closing brace ("}")

Thanks so mutch!



Re: [HELP] What is wrong with this? - OmeRinG - 15.06.2009

Problems are in the function SendCopMessage...
When you did GetPlayerTeam you used playerid instead of i
You used 1 more bracket than you needed to


Re: [HELP] What is wrong with this? - FreddeN - 15.06.2009

Quote:
Originally Posted by OmeRinG
Problems are in the function SendCopMessage...
When you did GetPlayerTeam you used playerid instead of i
You used 1 more bracket than you needed to
Now I have:

Код:
	if(strcmp(cmdtext , "/radio", true) == 0)
	{
    	if(GetPlayerTeam(playerid) != 5) return SendClientMessage(playerid,COLOR_RED, "Identification Error - You need rank 1 to do this.");
			{
				if ((strlen(cmdtext) >= 1)&&(strlen(cmdtext) <= 3))
					{
            new string[128];
						new playername[MAX_PLAYER_NAME];
						GetPlayerName(playerid,playername,sizeof(playername));
						format(string,sizeof(string),"Police Radio: %s:%s",playername,cmdtext[128]);
						SendCopMessage(COLOR_BLUE, string);
						return 1;
					}
			}
	}
	return 0;
}
Код:
SendCopMessage(color, text[]) {
	for(new i = 0; i < MAX_PLAYERS; i ++) {
  if(IsPlayerConnected(i)) {
  if(GetPlayerTeam(i) != 5)
      SendClientMessage(i, color, text);
      }
    }
  }
But when I type /radio, it says Unknown Command..., nothing more