SA-MP Forums Archive
Sscanf ID0 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: Sscanf ID0 bug. (/showthread.php?tid=383393)



Sscanf ID0 bug. - tsonn1 - 07.10.2012

Hi!

I've got a little problem with my /makeadmin command.
It just makes ID0 admin, it doesn't matter, what I write.

So here's the code:
pawn Код:
CMD:makeadmin(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new type[32];
        new string[128];
        new sendername[MAX_PLAYER_NAME];
        new giveplayer[MAX_PLAYER_NAME];
        new otherId;
        new lvl;
        if(sscanf(params, "s[32]i", type,lvl))
        {
            SendClientMessage(playerid, COLOR_GRAD1, "KASUTUS: /adminiks [MдngijaID/Osanimest] [aLevel]");
            return 1;
        }
        if (KasutajaInfo[playerid][pAdmin] >= 1337)
        {
            if(IsPlayerConnected(otherId))
            {
                if(otherId != INVALID_PLAYER_ID)
                {
                    GetRPName(otherId, giveplayer, sizeof(giveplayer));
                    GetRPName(playerid, sendername, sizeof(sendername));
                    KasutajaInfo[otherId][pAdmin] = lvl;
                    printf("AdmCmd: %s has promoted %s to a level %d admin.", sendername, giveplayer, lvl);
                    format(string, sizeof(string), "Sind tehti level %d adminiks admini %s poolt.", lvl, sendername);
                    SendClientMessage(otherId, COLOR_LIGHTBLUE, string);
                    format(string, sizeof(string), "Tegid mдngija %s level %d adminiks.", giveplayer,lvl);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    format(string, 256, "TДHELEPANU: %s tegi mдngija %s level %d adminiks.", sendername,giveplayer,lvl);
                    ABroadCast(COLOR_YELLOW,string,1);

                }
            }
        }
        else if(IsPlayerAdmin(playerid))
        {
            if(IsPlayerConnected(otherId))
            {
                if(otherId != INVALID_PLAYER_ID)
                {
                    GetRPName(otherId, giveplayer, sizeof(giveplayer));
                    GetRPName(playerid, sendername, sizeof(sendername));
                    KasutajaInfo[otherId][pAdmin] = lvl;
                    printf("AdmCmd: %s has promoted %s to a level %d admin.", sendername, giveplayer, lvl);
                    format(string, sizeof(string), "Sind tehti level %d adminiks admini %s poolt.", lvl, sendername);
                    SendClientMessage(otherId, COLOR_LIGHTBLUE, string);
                    format(string, sizeof(string), "Tegid mдngija %s level %d adminiks.", giveplayer,lvl);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                    format(string, 256, "TДHELEPANU: %s tegi mдngija %s level %d adminiks.", sendername,giveplayer,lvl);
                    ABroadCast(COLOR_YELLOW,string,1);

                }
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GRAD1, "Sa ei saa seda kдsklust kasutada.");
        }
    }
    return 1;
}



Re: Sscanf ID0 bug. - JaKe Elite - 07.10.2012

[Tutorial] sscanf ID 0 bugged [For Newbie] - Fixed by Romel


Re: Sscanf ID0 bug. - tsonn1 - 07.10.2012

Come on...
That's just a tutorial for updating sscanf.
Btw. I've got the latest version.

It's something in my script. (I'm a sscanf newbie.. )


Re: Sscanf ID0 bug. - AndreT - 07.10.2012

Jesus f**king christ, the people "helping" in this topic, read the code FOR ONCE.

You are not using the u-specifier of sscanf. The 'u' is meant for detecting a player. It should look something like this:
pawn Код:
sscanf(params, "ui", otherId, lvl)
What you use the "type" array for... no idea.


Re: Sscanf ID0 bug. - tsonn1 - 07.10.2012

You made a little mistake.
Код:
if(sscanf(params, "ui", otherId, lvl))


Thanks for the help.