SA-MP Forums Archive
sscanf2 problem? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: sscanf2 problem? (/showthread.php?tid=234727)



sscanf2 problem? - Mike Garber - 04.03.2011

Well i was testing my new script in development with a few players, and i found this problem..
Yeah, so this isn't happening with just this command, it happens with all of my commands
that requires a Player ID input.


They simply don't work for ID 3 and above, they work for ID 0, ID 1 and ID 2.
With that i mean "giveid", If i type /setcash 3 100000 it returns 0 and I get "This player is not connected"

Using ZCMD and sscanf2.

pawn Код:
COMMAND:setcash(playerid,params[])
{
    if(pData[playerid][pAdminLevel] >= 3)
    {
        new cash,giveid,str[96];
        if (!sscanf(params, "rn",giveid,cash))
        {
            if(IsPlayerConnected(giveid))
            {
                if(cash >= 0 && cash <= 99999999)
                {
                    ResetPlayerCash(giveid);
                    GivePlayerCash(giveid,cash);
                    format(str,sizeof(str), "%s's (ID:%d) cash has been set to $%d by %s",PlayerName(giveid),giveid,cash,PlayerName(playerid));
                    SendMessageToStaff_L3A(str);
                    format(str,64,"Your cash has been set to $%d by an Administrator.",cash);
                    SendClientMessage(giveid,COLOR_GREEN,str);
                }
                else SendClientMessage(playerid,COLOR_RED,"ERROR: Invalid Amount!");
            }
            else SendClientMessage(playerid, COLOR_RED, "ERROR: This player is not connected!");
        }
        else SendClientMessage(playerid,-1,"USAGE: /setcash [playerid] [cash]");
    }
    else SendClientMessage(playerid, COLOR_RED, "ERROR: You are not authorized to use this command.");
    return 1;
}



Re: sscanf2 problem? - Calgon - 04.03.2011

Try using the 'U' parameter instead for the userID and 'i' or 'd' for the integer/digits/numbers parameters.


Re: sscanf2 problem? - Mike Garber - 04.03.2011

Thank you, changing "r" to "u" did work.


Re: sscanf2 problem? - tanush - 04.03.2011

example
pawn Код:
COMMAND:setcash(playerid, params[])
{
    if(pData[playerid][pAdminLevel] >= 3)
    {
        new id,cash;
        if(sscanf(params, "ui", id,cash)) return SendClientMessage(playerid, 0xFF9900AA, "USAGE: /setcash [id] [cash]");
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "That user is not connected.");
        SendClientMessage(playerid, 0xFF9900AA, "You had set that player cash");
        SendClientMessage(id, 0xFF9900AA, "Your cash has been set by a admin!");
        ResetPlayerMoney(id);
        GivePlayerMoney(id,cash);
    }
    else return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Your admin level isn't high enough!");
    return 1;
}
i made it...


Re: sscanf2 problem? - Mike Garber - 05.03.2011

Don't need an example after I said I solved It, I'm not a beginner at scripting, nor stupid.