Invalid Player Command Bug
#1

I need help! Some ID's always get "Invalid Player Specified" when admin commands or normal commands are used on them. I can't fix it, I need some assistance.
Reply
#2

Without any information I just can tell you to use zCMD, sscanf, and check the if statements when checking the targets id. Show us any command that doesnt work with everyone to see.
Reply
#3

Okay. I will show you one example where it will say Invalid Player Specified.

pawn Код:
CMD:gotoid(playerid, params[])
{
    new giveplayerid;
    if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /gotoid [playerid]");

    new Float:plocx,Float:plocy,Float:plocz;
    if (IsPlayerConnected(giveplayerid))
    {
        if (PlayerInfo[playerid][pAdmin] >= 2)
        {
            if(GetPlayerState(giveplayerid) == PLAYER_STATE_SPECTATING)
            {
                SendClientMessageEx(playerid, COLOR_GRAD2, "That player is spectating someone.");
                return 1;
            }
            if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
            {
                SendClientMessageEx(playerid, COLOR_GRAD2, "You can not do this while spectating.");
                return 1;
            }
            GetPlayerPos(giveplayerid, plocx, plocy, plocz);
            SetPlayerVirtualWorld(playerid, PlayerInfo[giveplayerid][pVW]);
            Streamer_UpdateEx(playerid, plocx, plocy, plocz);

            if (GetPlayerState(playerid) == 2)
            {
                new tmpcar = GetPlayerVehicleID(playerid);
                SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
            }
            else
            {
                SetPlayerPos(playerid,plocx,plocy+2, plocz);
                SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
                SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid));
            }

            SendClientMessageEx(playerid, COLOR_GRAD1, "   You have been teleported!");
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
        }

    }
    else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    return 1;
}
Reply
#4

Quote:
Originally Posted by Zach7
Посмотреть сообщение
Okay. I will show you one example where it will say Invalid Player Specified.

pawn Код:
CMD:gotoid(playerid, params[])
{
    new giveplayerid;
    if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /gotoid [playerid]");

    new Float:plocx,Float:plocy,Float:plocz;
    if (IsPlayerConnected(giveplayerid))
    {
        if (PlayerInfo[playerid][pAdmin] >= 2)
        {
            if(GetPlayerState(giveplayerid) == PLAYER_STATE_SPECTATING)
            {
                SendClientMessageEx(playerid, COLOR_GRAD2, "That player is spectating someone.");
                return 1;
            }
            if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
            {
                SendClientMessageEx(playerid, COLOR_GRAD2, "You can not do this while spectating.");
                return 1;
            }
            GetPlayerPos(giveplayerid, plocx, plocy, plocz);
            SetPlayerVirtualWorld(playerid, PlayerInfo[giveplayerid][pVW]);
            Streamer_UpdateEx(playerid, plocx, plocy, plocz);

            if (GetPlayerState(playerid) == 2)
            {
                new tmpcar = GetPlayerVehicleID(playerid);
                SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
            }
            else
            {
                SetPlayerPos(playerid,plocx,plocy+2, plocz);
                SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
                SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid));
            }

            SendClientMessageEx(playerid, COLOR_GRAD1, "   You have been teleported!");
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
        }

    }
    else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    return 1;
}

I think it only happens on ID 2
Reply
#5

hmm I can't tell you anything because that seems fine to me. Sorry.
Reply
#6

Quote:
Originally Posted by Zach7
Посмотреть сообщение
Okay. I will show you one example where it will say Invalid Player Specified.

pawn Код:
CMD:gotoid(playerid, params[])
{
    new giveplayerid;
    if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /gotoid [playerid]");

    new Float:plocx,Float:plocy,Float:plocz;
    if(IsPlayerConnected(giveplayerid))
    {
        if (PlayerInfo[playerid][pAdmin] >= 2)
        {
            if(GetPlayerState(giveplayerid) == PLAYER_STATE_SPECTATING)
            {
                SendClientMessageEx(playerid, COLOR_GRAD2, "That player is spectating someone.");
                return 1;
            }
            if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
            {
                SendClientMessageEx(playerid, COLOR_GRAD2, "You can not do this while spectating.");
                return 1;
            }
            GetPlayerPos(giveplayerid, plocx, plocy, plocz);
            SetPlayerVirtualWorld(playerid, PlayerInfo[giveplayerid][pVW]);
            Streamer_UpdateEx(playerid, plocx, plocy, plocz);

            if (GetPlayerState(playerid) == 2)
            {
                new tmpcar = GetPlayerVehicleID(playerid);
                SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
            }
            else
            {
                SetPlayerPos(playerid,plocx,plocy+2, plocz);
                SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
                SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid));
            }

            SendClientMessageEx(playerid, COLOR_GRAD1, "   You have been teleported!");
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
        }

    }
    else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    return 1;
}
Try:

pawn Код:
CMD:gotoid(playerid, params[])
{
    new giveplayerid;
    if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /gotoid [playerid]");

    new Float:plocx,Float:plocy,Float:plocz;
    if(giveplayerid != INVALID_PLAYER_ID)
    {
        if (PlayerInfo[playerid][pAdmin] >= 2)
        {
            if(GetPlayerState(giveplayerid) == PLAYER_STATE_SPECTATING)
            {
                SendClientMessageEx(playerid, COLOR_GRAD2, "That player is spectating someone.");
                return 1;
            }
            if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
            {
                SendClientMessageEx(playerid, COLOR_GRAD2, "You can not do this while spectating.");
                return 1;
            }
            GetPlayerPos(giveplayerid, plocx, plocy, plocz);
            SetPlayerVirtualWorld(playerid, PlayerInfo[giveplayerid][pVW]);
            Streamer_UpdateEx(playerid, plocx, plocy, plocz);

            if (GetPlayerState(playerid) == 2)
            {
                new tmpcar = GetPlayerVehicleID(playerid);
                SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
            }
            else
            {
                SetPlayerPos(playerid,plocx,plocy+2, plocz);
                SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
                SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid));
            }

            SendClientMessageEx(playerid, COLOR_GRAD1, "   You have been teleported!");
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
        }

    }
    else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    return 1;
}
That worked for me when I had the problem, if it won't work. I'm sorry.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)