SA-MP Forums Archive
Something with SSCANF - 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: Something with SSCANF (/showthread.php?tid=453750)



Something with SSCANF - DeMoX - 26.07.2013

Hi all,
I've faced an issue with sscanf for the first time.
whenever i try to use a command on ID 2 it says "Invalid player/Player not connected"
So if you've ever faced this issue and fixed it succesfully please let me know how.

It might be a fail from me too , here's a code :

pawn Код:
#define IsValidPlayer(%0) \
    (id_buf = (%0), 0 <= id_buf < MAX_PLAYERS && IsPlayerConnected(id_buf))

COMMAND:kick(playerid,params[])
{
    if(!AdminCommandCheck(playerid,"/kick"))
        return 1;

    new id,reason[128];
    if(sscanf(params,"us[128]",id,reason))
        return SendSyntaxWarning(playerid,"/kick <ID/Name> <Grund>");

    if(!IsValidPlayer(id))
        return SendLanguageMessage(playerid,COLOR_WARNING,"<$> -Warnung-<#> Ungueltige ID!","<$> -Warning-<#> Invalid ID!");

    if(IsPlayerHigherAdminAsPlayer(playerid,id))
    {
        if(IsValidPlayer(id) && id!=playerid)
        {
            KickPlayer(id,reason,PlayerName[playerid],playerid);
            return 1;
        }
        else
            return SendLanguageMessage(playerid,COLOR_WARNING,"<$> -Warnung-<#> Ungueltige ID!","<$> -Warning-<#> Invalid ID!");
    }
    else
        return SendLanguageMessage(playerid,COLOR_WARNING,"<$> -Warnung-<#> Der Spieler hat ein gleiches oder hoeheres Level, du kannst ihn nicht kicken!","<$> -Warning-<#> You can't kick a player with a higher level then yours!");
}

stock SendSyntaxWarning(playerid,cmd[])
{
    new string[128];
    if(GetPlayerLanguage(playerid)==LANG_DE)
        format(string,sizeof(string),"<$> -Warnung-<#> Anwendung: %s",cmd);
    else
        format(string,sizeof(string),"<$> -Warning-<#> Usage: %s",cmd);
    return SendClientMessageEx(playerid,COLOR_WARNING,string);
}
If you know how to fix it or you've seen it on a topic or find anything that might help please reply.


Re: Something with SSCANF - Threshold - 26.07.2013

Have you tried updating your sscanf? There is an issue that sometimes returns '0' for all player id values. Update to the latest version, and come back to us again if it doesn't work.


Re: Something with SSCANF - DeMoX - 26.07.2013

oh thanks, i tought that i updated it, but the host files aren't, Thanks.