OnPlayerText
#1

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)
Reply
#2

You could try using the String Compare function:

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

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]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)