SA-MP Forums Archive
OnPlayerText - 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: OnPlayerText (/showthread.php?tid=198517)



OnPlayerText - blackwave - 12.12.2010

Look my code:

pawn Код:
if(text[0] == '&')
   {
      new string[128],nome[30];
      GetPlayerName(playerid, nome, 30);
      format(string,sizeof(string),"%s [ID: %d]: %s", nome, playerid, text);
      foreach(Player, todos)
      {
         if(IsPlayerConnected(todos))
         {
             if(time[todos] == EMPTY) return SendClientMessage(todos, 0xFFFFFFFF, string);
             else if(time[todos] == POLICE) return SendClientMessage(todos, 0x0080FFFF, string);
             else if(time[todos] == ARMY) return SendClientMessage(todos, 0x7CAD0CFF, string);
             else if(time[todos] == RUNNER) return SendClientMessage(todos, 0xFF00FFFF, string);
             else if(time[todos] == ADMIN) return SendClientMessage(todos, 0xFFFF80FF, string);
          }
       }
    }
If a player types the simbol & + message, the message will be sent according to these defined teams above. How to do that? it's not working :S. Also tried
Код:
if(strfind(text,"&",true) =! -1)



Re: OnPlayerText - Benjo - 12.12.2010

You could try using the String Compare function:

pawn Код:
if(strcmp(text[0], "&", true) == 0)
{
  // do stuff
}



Re: OnPlayerText - Jefff - 12.12.2010

Remove all 'return' and put return 0; here
pawn Код:
if(text[0] == '&')
{
//code
return 0;
}
+
pawn Код:
format(string,sizeof(string),"%s [ID: %d]: %s", nome, playerid, text[1]);