OnplayerCommandReceived... Help here :(
#1

pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{

    if(PlayerInfo[ playerid ][ isAFK ] == 1 && strcmp(cmdtext,"/back",true) && strcmp(cmdtext,"/unjail",true) && strcmp(cmdtext,"/uncage",true))
    {
        SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"You are Now in AFK/BRB Mode! Try /back to use this cmd!");
        return 0;
    }
   
    if((GetTickCount() - GetPVarInt(playerid, "SpamCMD")) < 1000*2)
    {
        GameTextForPlayer(playerid, "~r~Please wait 2 seconds", 1000, 3);
        return 0;
    }
    SetPVarInt(playerid, "SpamCMD", GetTickCount());
    return 1;
}

This is my code
and i wanted to get all the cmds written there to be working in that condition but only /back is working
please help me to fix this


thanks in advance
Reply
#2

I don't see how that statement could ever work. If you type either of those commands, the value returned by strcmp will be 0, instantly rendering the whole statement false. This should be the correct logic:

pawn Код:
if(PlayerInfo[ playerid ][ isAFK ] == 1 && (!strcmp(cmdtext,"/back",true) || !strcmp(cmdtext,"/unjail",true) || !strcmp(cmdtext,"/uncage",true)))
Reply
#3

Thanks man
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)