SA-MP Forums Archive
sscanf issue. I guess? - 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 issue. I guess? (/showthread.php?tid=287132)



sscanf issue. I guess? - PrawkC - 02.10.2011

Alright I'm using Vortex 2, using the latest sscanf plugin.. im wondering why when i use the command /check

and I put an id that isnt connected, it outputs the usually Unknown Command type thing, why the hell isnt it
outputting

return SendClientMessage(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");


pawn Код:
CMD:check(playerid,params[]) {
    if(playerVariables[playerid][pAdminLevel] >= 1) {

        new
            targetid;

        if(sscanf(params, "u", targetid))
            return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/check [playerid]");

        if(playerVariables[targetid][pStatus] != 1)
            return SendClientMessage(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");

        if(playerVariables[playerid][pAdminLevel] < playerVariables[targetid][pAdminLevel])
            return SendClientMessage(playerid, COLOR_GREY, "You can't check a higher level administrator.");

        showStats(playerid, targetid);
    }
    return 1;
}
and yes

playerVariables[targetid][pStatus]

is being set correctly, its DEFAULT vortex 2 script, i doubt calg0ne would mess that up.


Re: sscanf issue. I guess? - GrimR - 02.10.2011

You must check if the id = INVALID_PLAYER_ID.


Re: sscanf issue. I guess? - PrawkC - 02.10.2011

Quote:
Originally Posted by GrimR
Посмотреть сообщение
You must check if the id = INVALID_PLAYER_ID.
that doesn't make sense, I do the exact same thing in a different script and it works fine.


Re: sscanf issue. I guess? - GrimR - 02.10.2011

While sscanf does check the id when you use "u" it returns INVALID_PLAYER_ID.

What you need to understand is, doing an if sscanf means if it returns 1, clearly INVALID_PLAYER_ID is not 1, therefore if invalid it will not fire off, which is why you check it exclusively afterwards.

Using sscanf in that way only tells if it got the param(s) correctly or not.


Re: sscanf issue. I guess? - GrimR - 02.10.2011

If pStatus is your problem, where is it being set?


Re: sscanf issue. I guess? - PrawkC - 02.10.2011

Quote:
Originally Posted by GrimR
Посмотреть сообщение
If pStatus is your problem, where is it being set?
Read my post, I clearly stated that its being set properly.

and variables default to 0, so checking if that doesnt not equal 1, it SHOULD return the message, but it doesnt.


Re: sscanf issue. I guess? - GrimR - 02.10.2011

Looking at your code only the pStatus check returns the mesage your saying is not showing that should, sscanf has nothing to do with that conditional check.....


Re: sscanf issue. I guess? - GrimR - 02.10.2011

But that sscanf check will not behave like you think and return the message of how to use the function properly when an invalid id is gotten using sscanf, you have to check if the param you got is what I said before.


Re: sscanf issue. I guess? - [L3th4l] - 02.10.2011

You don't even need sscanf for this command. Try this:
pawn Код:
CMD:check(playerid, params[])
{
    if(playerVariables[playerid][pAdminLevel] >= 1)
    {
        if(isnull(params))
            return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/check [playerid]");

        new
            targetid = strval(params);

        if(playerVariables[targetid][pStatus] != 1)
            return SendClientMessage(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");

        if(playerVariables[playerid][pAdminLevel] < playerVariables[targetid][pAdminLevel])
            return SendClientMessage(playerid, COLOR_GREY, "You can't check a higher level administrator.");
    }
    return 1;
}



Re: sscanf issue. I guess? - Toni - 02.10.2011

I don't know if this is true, but is this still that issue with sscanf and the SA:MP update? It stopped working (the 'u' identifier) and I'm not sure if that was fixed yet.

Have you searched it up yet?