SA-MP Forums Archive
Player ID Bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Player ID Bug (/showthread.php?tid=471374)



Player ID Bug - Lunixx - 22.10.2013

SOmetimes if players joins my server and i try to /goto /jetpack or whatever it says:"Invalid Player Specified"


Re: Player ID Bug - TomatoRage - 22.10.2013

Code??


Re: Player ID Bug - Lunixx - 22.10.2013

i kinda should give you most of my admin /goto /give /take commands then. about 20 commands


Re: Player ID Bug - Marshall32 - 22.10.2013

It could be the way your checking the ID. Or if your using sscanf you didnt do something well. Could be anything till we can take a look.


Re: Player ID Bug - Tagathron - 22.10.2013

Lunixx,noone will try to guess your code,either try to find it yourself or post the /goto command(or whichever causes the bug)


Re: Player ID Bug - iFiras - 22.10.2013

Quote:
Originally Posted by Tagathron
Посмотреть сообщение
Lunixx,noone will try to guess your code,either try to find it yourself or post the /goto command(or whichever causes the bug)
^^^
Lunixx, wanna help?? Post your code so we can help you fixing it


Re: Player ID Bug - DanishHaq - 22.10.2013

Make sure your sscanf is the latest version, post one of the commands that aren't working if your sscanf is on the latest version and you're still getting these problems.


Re: Player ID Bug - Wizza - 22.10.2013

Its sscanf, download the newest version.


Re: Player ID Bug - Lunixx - 24.10.2013

I tried updating sscanf, still appears sometimes. so if i get home from school i'm gonna upload about 20+ commands


Re: Player ID Bug - Pottus - 24.10.2013

Yeah there is sometimes a problem using the "u" specifier it's rare but can happen it was actually happening on the DayZ server. The beauty of sscanf() is you can define your own specifiers so I wrote an custom "u" specifier to address this issue.

Yes you will need YSI or you can use an alternative hooking method

You will need to update the sscanf()'s in your script where you use the "u" specifier with this.

pawn Код:
sscanf(params, "k<u>", pid);
pawn Код:
#include <YSI\y_hooks>

static PlayerNames[MAX_PLAYERS][MAX_PLAYER_NAME];

// Store players name
hook OnPlayerConnect(playerid)
{
    if(IsPlayerNPC(playerid)) return 1;
    GetPlayerName(playerid, PlayerNames[playerid], MAX_PLAYER_NAME);
    return 1;
}

// Search for players name
SSCANF:u(name[])
{
    // No name specified
    if(isnull(name)) return INVALID_PLAYER_ID;

    new id;

    // Was a part of name provided?
    if(sscanf(name, "i", id))
    {
        new matches;
       
        // Find a player return the id
        foreach(new i : Player)
        {
            // Search for part of the players name
            if(strfind(PlayerNames[i], name, true) != -1)
            {
                matches++;
                id = i;
                if(matches > 1) return INVALID_PLAYER_ID;
            }
        }
        // Found a match
        if(matches) return id;

        // No player found return invalid player id
        return INVALID_PLAYER_ID;
    }

    // Player supplied a id

    // Make sure the id is greater than 0
    if(id < 0) return INVALID_PLAYER_ID;

    // Make sure the id is connected
    if(!IsPlayerConnected(id)) return INVALID_PLAYER_ID;

    // Return the id
    return id;
}