OnPlayerCommandReceived Question
#10

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
You added too much parentheses.

pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(GetPVarInt(playerid, "LoggedIn") == 0)
    {
        SendClientMessage(playerid,COLOR_RED, "[SERVER]: You can't use commands if you didn't login.");
        return 0;
    }
    if(GetPVarInt(playerid, "Injured") != 0 || GetPVarInt(playerid, "Dragged") == 1 || GetPVarInt(playerid, "Cuffed") != 0)
    {
        if(strcmp(cmdtext, "ems", true, 3) == 0 || strcmp(cmdtext, "me", true, 2) == 0 || strcmp(cmdtext, "do", true, 2) == 0 || strcmp(cmdtext, "giveup", true, 6) == 0 || strcmp(cmdtext, "revive", true, 6) == 0)
        {
            SendClientMessage(playerid,COLOR_RED, "[SERVER]: You can't use commands while: injured/dragged/cuffed.");
            return 0;
        }
    }
    return 1;
}
okay this is working, however, quick fix for anyone who will need this in the future.
this is the right way:
pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(GetPVarInt(playerid, "LoggedIn") == 0)
    {
        SendClientMessage(playerid,COLOR_RED, "[SERVER]: You can't use commands if you didn't login.");
        return 0;
    }
    if(GetPVarInt(playerid, "Injured") != 0 || GetPVarInt(playerid, "Dragged") == 1 || GetPVarInt(playerid, "Cuffed") != 0)
    {
        if(strcmp(cmdtext, "/ems", true, 3) == 0 || strcmp(cmdtext, "/me", true, 2) == 0 || strcmp(cmdtext, "/do", true, 2) == 0 || strcmp(cmdtext, "/giveup", true, 6) == 0 || strcmp(cmdtext, "/revive", true, 6) == 0)
        {
            return 1;
        }
        else
        {
            SendClientMessage(playerid,COLOR_RED, "[SERVER]: You can't use commands while: injured/dragged/cuffed.");
            return 0;
        }
    }
    return 1;
}
Thanks for the guys who replied in the thread! honored rep++;
Reply


Messages In This Thread
OnPlayerCommandReceived Question - by maximthepain - 27.03.2015, 14:45
Re: OnPlayerCommandReceived Question - by Konstantinos - 27.03.2015, 14:47
Re: OnPlayerCommandReceived Question - by SickAttack - 27.03.2015, 14:48
Re: OnPlayerCommandReceived Question - by maximthepain - 27.03.2015, 14:50
Re: OnPlayerCommandReceived Question - by SickAttack - 27.03.2015, 14:53
Re: OnPlayerCommandReceived Question - by Konstantinos - 27.03.2015, 14:55
Re: OnPlayerCommandReceived Question - by SickAttack - 27.03.2015, 15:01
Re: OnPlayerCommandReceived Question - by Konstantinos - 27.03.2015, 15:07
Re: OnPlayerCommandReceived Question - by SickAttack - 27.03.2015, 15:10
Re: OnPlayerCommandReceived Question - by maximthepain - 27.03.2015, 15:16

Forum Jump:


Users browsing this thread: 3 Guest(s)