Player ID Problem?
#1

When I try to do /setvip command it says Invalid player id

pawn Код:
COMMAND:setvip(playerid, params[])
{
    if(pInfo[playerid][Adminlevel] >= 4)
    {
            new Target;
            new Level;
            if(!sscanf(params, "ui", Target,Level))
            {
                if(Level > 3) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Maximum level is 3!");
                if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Invalid player ID");
                if(pInfo[Target][Adminlevel] >= pInfo[playerid][Adminlevel]) return SendClientMessage(playerid,COLOR_RED,"{F81414}[ERROR]: {FFFFFF}This command is not available in this server! Type {F81414}/help {FFFFFF}for a list of commands.");
                pInfo[Target][VIPlevel] = Level;
                new tname[MAX_PLAYER_NAME];
                GetPlayerName(Target,tname,sizeof(tname));
                new pname[MAX_PLAYER_NAME];
                GetPlayerName(playerid,pname,sizeof(pname));
                new MyString[128];
                new TargetString[128];
                format(MyString, sizeof(MyString), "You have set %s VIP Level to %i!", tname, Level);
                format(TargetString, sizeof(TargetString), "You have been promoted to  VIP Level %i, thanks to %s!", pname, Level);
                SendClientMessage(Target, COLOR_RED, TargetString);
                SendClientMessage(playerid,COLOR_GREEN,MyString);
            }
            else SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setvip <playerid> <vip-level>");
        }
    else SendClientMessage(playerid, COLOR_RED, "[ERROR]: You have to be an Admin level 4 or higher to perform this command!");
    return 1;
}
Help?
Reply
#2

Try using IsPlayerConnect
Example:
You got:
pawn Код:
if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Invalid player ID");
Try instead:
pawn Код:
if(!IsPlayerConnect(Target)) return SendClientMessage(playerid, COLOR_RED,"[ERROR]: Invalid playerID");
Reply
#3

pawn Код:
if(!IsPlayerConnected(Target)) return SendClientMessage(playerid, COLOR_RED,"[ERROR]: Invalid playerID");
Doesn't work either.
Reply
#4

Hmm, try updating sscanf?
Reply
#5

Update your sscanf plugin and include then re-compile.
Reply
#6

Thanks guys +repped.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)