sscanf help.
#1

I'm trying to make an /accept [name] command.
I have no errors when I compile, and my command works perfectly, but on my server window I get
Код:
[18:22:07] sscanf warning: Unknown format specifier 'j', skipping.
How can I fix this? This isn't really a major issue. I just really want to know how to compare strings with sscanf.
My code.
pawn Код:
CMD:accept(playerid,params[])
{
    new x_job[124];
    if(sscanf(params,"s[256]",x_job))
    {
        SendClientMessage(playerid,COLOR_GREY,"Usage: /accept [name]");
        SendClientMessage(playerid,COLOR_GREY,"Names: Job, Faction");
        return 1;
    }
    if(sscanf("job",params,"s[256]",x_job))
    {
    // I left out the rest of the command since the problem isn't within the command. It's mainly the above line.
Reply
#2

Sweet baby jesus, don't use 256, please!

pawn Код:
CMD:accept(playerid, params[])
{
    if(isnull(params)) {
        SendClientMessage(playerid,COLOR_GREY,"Usage: /accept [name]");
        return SendClientMessage(playerid,COLOR_GREY,"Names: Job, Faction");
    }
   
    if(strcmp(params, "job", true) == 0)
    {
        //Do the rest of your code
    }
    else return 0; //They typed in something other than "Job"
}
Reply
#3

CMD:accept(playerid,params[])
{
new x_job[124];
if(sscanf(params,"s[256]",x_job))
{
SendClientMessage(playerid,COLOR_GREY,"Usage: /accept [name]");
SendClientMessage(playerid,COLOR_GREY,"Names: Job, Faction");
return 1;
}
if(!strcmp(x_job,"job",false)) //try this?
{
Reply
#4

So it is not possible to compare strings using sscanf?
Reply
#5

I'm honestly not sure, but it's common practice to compare them using strcmp. It's easier.
Reply
#6

You can compare strings with sscanf. I can't remember exactly how but this should work.

pawn Код:
if(!sscanf(params, "'job's[124]", x_job)) {
    // "Job" was found.
}
Reply
#7

pawn Код:
if(!sscanf(params, "{'jobs'}"))
{
    //we would do code here
}
Is a way of comparing, however it isn't case sensitive
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)