sscanf2 problem?
#1

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;
}
Reply
#2

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

Thank you, changing "r" to "u" did work.
Reply
#4

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...
Reply
#5

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


Forum Jump:


Users browsing this thread: 1 Guest(s)