sscanf question & problem
#1

Hello!

I know it has been asked before numerous times, spent some time on searching those old threads, but didn't have luck in finding one! Anyways, is there a way to fix so called "sscanf ID bug" where random ID's wouldn't get passed in some command's parameters? Example:

pawn Код:
COMMAND:setskin(playerid,params[])
{
    if(PlayerAcc[playerid][AdminLevel] >= 2)
    {
        if(PlayerLogged[playerid] == 1)
        {
            new Target;
            new Skinid;
            if(!sscanf(params, "ui", Target, Skinid))
            {
                if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,red,"ERROR: Wrong player ID");
                if(Skinid > 299) return SendClientMessage(playerid,red,"ERROR: Skin IDґs from 0 to 299!");
                new tname[MAX_PLAYER_NAME];
                GetPlayerName(Target,tname,sizeof(tname));
                new pname[MAX_PLAYER_NAME];
                GetPlayerName(playerid,pname,sizeof(pname));
                new tstring[256];
                new pstring[256];
                format(tstring,sizeof(tstring),"Your skin is set to %d by %s",Skinid,pname);
                format(pstring,sizeof(pstring),"You have set %s's(%d) skin to %d",tname,Target,Skinid);
                SendClientMessage(Target,COLOR_BLUE,tstring);
                SendClientMessage(playerid,COLOR_BLUE,pstring);
                SetPlayerSkin(Target,Skinid);
            }
            else SendClientMessage(playerid,COLOR_YELLOW,"USAGE: /setskin <playerid> <skinid>");
        }
        else SendClientMessage(playerid,red,"ERROR: You must be logged in to use this command!");
    }
    else SendClientMessage(playerid,red,"ERROR: You must be an Admin level 2 or higher to perform this command!");
    return 1;
}
This command can't by executed on some ID's which differs from time to time (e.g. one time it can't be executed on id 0 or 1, the other time can't be executed on ID's 2 to 4)! What is the solution to this problem?

NOTE: All commands that are in my FS are "bugged" like this, but commands that are using sscanf and are in gamemode are working fine - could this be a problem or?


Thanks in advance!
Regards!
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
That could be a problem - are you sure the callback hooks are called? There's no reason why it would work in one script but not another. Frankly no-one else has mentioned anything about this in months since I changed the methods used.
What you mean by saying "callback hooks called"?

So, basically, by "transfering" all commands either from GM to FS or vice-versa would possibly solve this problem?

Thanks for your answer!
Reply
#3

He is asking if the callbacks are called..he means "are COMMANDxxx" called??

Once post your compile warnings..it sometimes happens when you forget to include zcmd but it compiles o.O

Do you have a callback OnCommandPerformed in your working script??If you have show it(Somtimes returning wrong will tell ZCMD that the cmd was performed when actually not and which actually belonged to other script that but ZCMD would stop the command being forwarded to other scripts)
Reply
#4

Quote:
Originally Posted by Yashas
Посмотреть сообщение
He is asking if the callbacks are called..he means "are COMMANDxxx" called??

Once post your compile warnings..it sometimes happens when you forget to include zcmd but it compiles o.O

Do you have a callback OnCommandPerformed in your working script??If you have show it(Somtimes returning wrong will tell ZCMD that the cmd was performed when actually not and which actually belonged to other script that but ZCMD would stop the command being forwarded to other scripts)
I have the ZCMD include, but don't have OnPlayerCommandPerformed!
Reply
#5

Quote:
Originally Posted by fiki574
Посмотреть сообщение
I have the ZCMD include, but don't have OnPlayerCommandPerformed!
You don't need OnPlayerCommandPerformed in your script unless you really want to peek into it and adjust your unsuccessful command processes and more.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)