sscanf issue. I guess?
#1

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

You must check if the id = INVALID_PLAYER_ID.
Reply
#3

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

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

If pStatus is your problem, where is it being set?
Reply
#6

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

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

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

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

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)