sscanf problem
#1

hey everyone .
i didn't understand whats the problem .
i tried to script this command:

pawn Код:
CMD:drift(playerid, params[])
    {
        new option[3];
        if(!sscanf(params, "i[3]", option))
        {
            if(strcmp(option, "1", true) == 0)
            {
                if(IsPlayerInAnyVehicle(playerid))
                {
                    new vid;
                    vid = GetPlayerVehicleID(playerid);
                    SetPlayerPos(playerid,1264.5880, -2013.3972, 59.2888);
                    SetVehiclePos(vid,1264.5880, -2013.3972, 59.2888);
                    PutPlayerInVehicle(playerid,vid,0);
                    GameTextForPlayer(playerid, "You have been teleported to\n ~r~Drift 1", 3000, 5);
                }
                else
                {
                    SetPlayerPos(playerid,1264.5880, -2013.3972, 59.2888);
                    GameTextForPlayer(playerid, "You have been teleported to\n ~r~Drift 1", 3000, 5);
                }
                return 1;
            }
            if(strcmp(option, "2", true) == 0)
            {
                if(IsPlayerInAnyVehicle(playerid))
                {
                    new vid;
                    vid = GetPlayerVehicleID(playerid);
                    SetPlayerPos(playerid,-299.6478, 1523.1639, 75.3594);
                    SetVehiclePos(vid,-299.6478, 1523.1639, 75.3594);
                    PutPlayerInVehicle(playerid,vid,0);
                    GameTextForPlayer(playerid, "You have been teleported to\n ~r~Drift 2", 3000, 5);
                }
                else
                {
                    SetPlayerPos(playerid,-299.6478, 1523.1639, 75.3594);
                    GameTextForPlayer(playerid, "You have been teleported to\n ~r~Drift 2", 3000, 5);
                }
                return 1;
            }
            if(strcmp(option, "3", true) == 0)
            {
                if(IsPlayerInAnyVehicle(playerid))
                {
                    new vid;
                    vid = GetPlayerVehicleID(playerid);
                    SetPlayerPos(playerid,-2401.7813, -594.6240, 132.6484);
                    SetVehiclePos(vid,-2401.7813, -594.6240, 132.6484);
                    PutPlayerInVehicle(playerid,vid,0);
                    GameTextForPlayer(playerid, "You have been teleported to\n ~r~Drift 3", 3000, 5);
                }
                else
                {
                    SetPlayerPos(playerid,-2401.7813,-594.6240, 132.6484);
                    GameTextForPlayer(playerid, "You have been teleported to\n ~r~Drift 3", 3000, 5);
                }
                return 1;
            }
            else return GameTextForPlayer(playerid, "~r~USAGE : ~w~/Drift 1-3", 3000, 5);
        }
        else return GameTextForPlayer(playerid, "~r~USAGE : ~w~/Drift 1-3", 3000, 5);
    }
but the command doesn't work right and the console gives me this message every time i enter the command :

Код:
[05:49:09] sscanf warning: Format specifier does not match parameter count.
[05:49:11] sscanf warning: Format specifier does not match parameter count.
[05:49:13] sscanf warning: Format specifier does not match parameter count.
any idea about how to fix that shit? :/
Reply
#2

remove new option[3] and make it as new option;
and change strcmp to if(option == 1/2/3)
and on the if(!sscanf(params, "i[3]", option))
change the i[3] to i only.
Reply
#3

pawn Код:
new option;
if(!sscanf(params, "i", option))
{
    switch(option)
    {
        case 1: {
            ...
        }
    }
}
Reply
#4

Код:
 "i[3]"
This. You don't need the size here.
So, change it to
Код:
 "i"
EDIT: check the replies above, they beat me to it lolz
Reply
#5

You don't need arrays for integers, so remove the [3] from the option, and also, on your sscanf line:
pawn Код:
if(!sscanf(params, "i[3]", option))
Make that:

pawn Код:
if(!sscanf(params, "i", option))
If you're new to using SSCANF, then I'm sure you could find a good, well written tutorial, I recommend just reading ******'s tutorial on his SSCANF plugin page.

Best of luck.
Reply
#6

you dont need to use [3] if you use an integer you can only use it for strings example s[128]
Reply
#7

Quote:
Originally Posted by MikeLovesToHelp
Посмотреть сообщение
You don't need arrays for integers, so remove the [3] from the option, and also, on your sscanf line:
pawn Код:
if(!sscanf(params, "i[3]", option))
Make that:

pawn Код:
if(!sscanf(params, "i", option))
If you're new to using SSCANF, then I'm sure you could find a good, well written tutorial, I recommend just reading ******'s tutorial on his SSCANF plugin page.

Best of luck.
thanks everyone for the help .
well , yeah i'm new in using sscanf
i already tried what you said before but it gives me
"Argument tag mismatch "
error on the " if(strcmp(option, "number", true) == 0) " lines :/
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
You really don't need ANY of all that unless you have more than 9 options (10 with "0" as a valid option):

pawn Код:
CMD:drift(playerid, params[])
{
    switch (params[0])
    {
        case '1':
        {
        }
        case '2':
        {
        }
        case '3':
        {
        }
    }
}
Note the use of '3' not just 3.
oh didn't know that ^^
thanks alot dude fixed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)