Player IDs Desyncing?
#1

I'm in the process of writing a roleplay script and a new bug has appeared. All of my commands with a player id parameter bug out and act on the wrong IDs. They normally refer to ID 0 no matter what you enter. Below is an example code that my administrative commands use to fetch player IDs.

pawn Код:
YCMD:slap(playerid, params[], help)
{
    if(PlayerInfo[playerid][pAdmin] < 2 && !IsPlayerAdmin(playerid))
    {
        SendClientMessage(playerid, COLOUR_YELLOW, "You're not an admin or aren't a high enough level admin.");
    }
    else
    {
        new Float:x, Float:y, Float:z;
        new otherplayerid;
        new str3[128];
        if(sscanf(params, "u", otherplayerid)) return SendClientMessage(playerid, COLOUR_YELLOW, "Usage: /slap [Player ID]");
        else if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, COLOUR_YELLOW, "A player with the specified ID was not found.");
        else
        {
            SendClientMessage(otherplayerid, COLOUR_YELLOW, "You have been slapped by an admin.");
            GetPlayerPos(otherplayerid, x, y, z);
            SetPlayerPos(otherplayerid, x, y, z+5);
            format(str3, sizeof (str3), "%s was slapped by admin %s.", GetName(otherplayerid), GetName(playerid));
            SendClientMessageToAll(COLOUR_RED, str3);
        }
    }
    return 1;
}
Everything compiles fine. I tried adding an NPC as a place taker to remove ID 0 but then the commands even acted on the NPC. I can only think something is wrong with my Sscanf lines, but what?
Reply
#2

Update your sscanf.
Reply
#3

Simple fix and it worked, thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)