SA-MP Forums Archive
onplayertext bugged - 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 bugged (/showthread.php?tid=149999)



onplayertext bugged - iStarzz - 24.05.2010

When i talk it goes like this:
banned(0): hi
banned: hi
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (pmuted[playerid] == 1 )
    {
        SendClientMessage(playerid, green,"You can't talk while you are muted.");
        return 0;
    }
    new string[256];

    if(text[0] == '@')
        {
          if(UserUD[playerid][admin] > 0)
          {
                format(string, sizeof(string), "Admin: %s(%d): %s", UserUD[playerid][accname], playerid, text[1]);

              for(new j = 0; j < MAX_PLAYERS; j++)
                {
                if(IsPlayerConnected(j) && UserUD[j][admin] > 0) SendClientMessage(j, green, string);
                }
          }
          else
          {
            SendClientMessage(playerid,green,"You aren't a admin!");
            return 0;
          }
        }
    new textstring[256], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(textstring, sizeof(textstring), "%s(%d): %s", name, playerid, text);
    SendClientMessageToAll(GetPlayerColor(playerid),textstring);
    return 1;
}



Re: onplayertext bugged - [MWR]Blood - 24.05.2010

Quote:

banned(0): hi
banned: hi

Hm, and how do you want it to be?


Re: onplayertext bugged - iStarzz - 24.05.2010

banned(0): hi, now it send the message 2 times.. :S


Re: onplayertext bugged - Sascha - 24.05.2010

Try:
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (pmuted[playerid] == 1 )
    {
        SendClientMessage(playerid, green,"You can't talk while you are muted.");
        return 0;
    }
    new string[256];

    if(text[0] == '@')
        {
          if(UserUD[playerid][admin] >> 0)
          {
                format(string, sizeof(string), "Admin: %s(%d): %s", UserUD[playerid][accname], playerid, text[1]);

              for(new j = 0; j < MAX_PLAYERS; j++)
                {
                if(IsPlayerConnected(j) && UserUD[j][admin] >> 0) SendClientMessage(j, green, string);
                }
                return 0;
          }
          else
          {
            SendClientMessage(playerid,green,"You aren't a admin!");
            return 0;
          }
        }
    new textstring[256], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(textstring, sizeof(textstring), "%s(%d): %s", name, playerid, text);
    SendClientMessageToAll(GetPlayerColor(playerid),textstring);
    return 1;
}

(sorry that the indentation is kinda bad as I just edited your text...didn't use pawn or so)


Re: onplayertext bugged - Sascha - 24.05.2010

Quote:
Originally Posted by Seif_
No, just return 0 at the end of OnPlayerText.
if you'd replace the return 1; with a return 0; it would send no message...


Re: onplayertext bugged - [MWR]Blood - 24.05.2010

Quote:
Originally Posted by Sascha
Quote:
Originally Posted by Seif_
No, just return 0 at the end of OnPlayerText.
if you'd replace the return 1; with a return 0; it would send no message...
He means
pawn Код:
return 1;
}
return 0;
}



Re: onplayertext bugged - iStarzz - 24.05.2010

Thanks Seif_ it worked, now i have a new problem :S Now when typing in admin chat it goes like this:

Admin: banned(0): hi
@banned(0): hi


Re: onplayertext bugged - iStarzz - 24.05.2010

nvm, already fixed