Problem with sscanf specifiers - returns error message everytime.
#1

Hey guys. I tried debugging this for a lot of time, but I couldn't, so here it is.
The problem is even if I am typing the correct parameters, it still brings up the error message. Hope you get it using this pic.
The code and error:

I have tried all specifiers, i, d, n, but to no use.
Can someone tell me where I am/it is going wrong?
Reply
#2

Have you tried it this way? (and mind posting the whole command so we can dig deeper into the problem?)
Also check if you have the latest sscanf package.

pawn Код:
new costbase, str[20];
if(sscanf(params, "s[20]d", st, costbase)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /create (name)(base)");
{
    //your code goes in here
}
Reply
#3

Same here.I was tired of it,so i left it for sometime.But I need the solution too.
Reply
#4

Got it. For some reason, iPleoMAX's textdraw editor (whose plugin and filterscript too, I was loading along) was breaking the process. I removed his FS and plugin, and it started working.
Reply
#5

Not mine.btw one more prb

pawn Код:
CMD:settime(playerid,params[]) {
    if(AdminData[playerid][Level] >= 3) {
        new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(sscanf(params, "d", tmp) || sscanf(params, "d",tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playerid, red, "USAGE: /settime [playerid] [hour]");
        new player1 = strval(tmp), time = strval(tmp2), string[128];
        if(AdminData[player1][Level] == ServerInfo[MaxAdminLevel] && AdminData[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
            CMDMessageToAdmins(playerid,"SETTIME");
            format(string, sizeof(string), "You have set \"%s's\" time to %d:00", pName(player1), time); SendClientMessage(playerid,blue,string);
            if(player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your time to %d:00", pName(playerid), time); SendClientMessage(player1,blue,string); }
            PlayerPlaySound(player1,1057,0.0,0.0,0.0);
            return SetPlayerTime(player1, time, 0);
        } else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
    } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough Level to use this command");
}
This is my code for settime for a specific player.I replaced sscanf with if(params(isnull)).But when i type only this much
pawn Код:
/settime 0
It shows me output like this
pawn Код:
You have set blabla time to 00:00
But the correct format for using it is
pawn Код:
/settime [playerid] [time]
Reply
#6

Quote:
Originally Posted by Gamer_007
Посмотреть сообщение
Not mine.btw one more prb

pawn Код:
new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(sscanf(params, "d", tmp) || sscanf(params, "d",tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playerid, red, "USAGE: /settime [playerid] [hour]");
Why do you use strtok when you have sscanf?

pawn Код:
new
    hours,
    minutes
;
if(sscanf(params, "dd", hours, minutes)) return SendClientMessage(playerid, red, "USAGE: /settime [playerid] [hour]");
@Rajat_Pawar
- The sscanf works fine, make sure it's updated!
Reply
#7

Quote:
Originally Posted by Gamer_007
Посмотреть сообщение
Not mine.btw one more prb
Do not bump into other user's problem. Create your thread.

Nevertheless, check your sscanf parameter. You want to declare a new variable 'targetid' (Therefore it should say,)
pawn Код:
new targetid;
if(sscanf(params, "dd", targetid, tmp)) return SCM(...);
Again, wrong thread to post your problems into.
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
Please don't! If everyone used the same threads for similar problems we would have VASTLY fewer pages of rubbish and a nicely neat and organised forum! In fact, there is one topic that is already perfect for posting all your sscanf issues and it's called the sscanf topic!



That's not how sscanf works! Nor how "else" works. Nor how numbers work! Have you even read the sscanf documentation at all? "d" is for numbers yet you store it in a string. You also check if sscanf passes then do exactly the same thing again so will get exactly the same result twice. Finally, "d" does "IsNumeric" checks and vastly more. Seriously, go read the wiki page on fast commands.
You're right.I am a noob still in sscanf.Just tried.Thanks for suggesting.Gonna read it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)