Sscanf
#1

Hi everybody

So the other day I was trying to make a command which checks 2 parameters and then based on the second one it does something.

I wasn't able to successfully perform the command because the code just wasn't able to see the second parameter.

I did something like this:

Код:
CMD:v(playerid, params[])
{
    new cmd[64];
    format(cmd, sizeof(cmd), "%s", params);
    if(!strcmp(cmd, "lock", true, 4)) //I replaced strcmp with strfind and it works normally. That means that sscanf part is fine.
    {
        new id;
        if(sscanf(cmd, " i", id)) return SendCLientMessage(...);//I put a spacing before "i" because that's how sscanf can check for the second word/integer... and not the first one.
        vInfo[id][vDoors] = 1;
        return 1;
    }
    return 1;
}
So when I write in-game /v lock it says Usage: /v lock [ID] but when I put in an ID strcmp doesn't check for the lock command and it doesn't do anything.

Is there a way to do this with strcmp?

I did it with strfind and it works fine but I want to know how to use strcmp the right way...

By what I've read about strcmp my code should be working just fine but it's not.

Btw I shortened the code so you don't have to read a lot.

Thanks in advanced
Reply


Messages In This Thread
Strcmp? - by andrejc999 - 16.01.2018, 09:02
Re: Sscanf - by Misiur - 16.01.2018, 10:05
Re: Sscanf - by Dayrion - 16.01.2018, 10:33
Re: Sscanf - by andrejc999 - 16.01.2018, 17:54

Forum Jump:


Users browsing this thread: 1 Guest(s)