Question.
#1

I am using zCMD + SSCANF.

I made a /vehicle command, and used 'strcmp' to compare the /v [option] to "buy"

PHP код:
if(strcmp(vtext"buy"true) == 0
How can I add another sscanf string under the 'buy'?

I tried adding it:
PHP код:
if ( sscanfparams"d"integer)) return ShowVehicleList(playerid); 
But seems like it's not working.

How can I add another string under it then?
Without using strtok and etc.

* NOTE:
Tried changing 'params' to vtext.
Reply
#2

What do you mean? You want to make

'/vehicle buy infernus'

?
Reply
#3

Show us your the full code of your command. It's hard to understand what you're actually trying to do.

And about adding multiple things in sscanf:

pawn Код:
CMD:vehicle(playerid, vtext[])
{
    new part_A[16], part_B[32]; //These are new string variables.
   
    if(sscanf(vtext, "s[16]s[32]", part_A, part_B)) return SendClientMessage(playerid, -1, "Usage: /vehicle [...] [...]");
   
    if(!strcmp(part_A, "buy", true))
    {
        // the user typed: /vehicle buy something
       
        if(!strcmp(part_B, "turismo", true))
        {
            // User typed: /vehicle buy turismo
        }
       
    } else // <-- :D
   
    if (!strcmp(part_A, "sell", true))
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, -1, "You don't have a vehicle to sell..");
        }
    }
   
    return true;
}
Reply
#4

I'm trying to make a number after /v buy.
Like if I want to buy Sultan, I write /v buy 560
560 = Sultan VEH ID

And if he didn't use any number, [wrote /v buy] I want it to return ShowVehicleList(playerid);
Reply
#5

Quote:
Originally Posted by yanir3
Посмотреть сообщение
I'm trying to make a number after /v buy.
Like if I want to buy Sultan, I write /v buy 560
560 = Sultan VEH ID
pawn Код:
CMD:vehicle(playerid, vtext[])
{
    new
        option[12],
        veh_id
    ;
   
    if (sscanf(vtext, "s[12]i", option, veh_id)) //s = string, i = integer (you can also use 'd')
    return SendClientMessage(playerid, -1, "Usage: /vehicle [Option] [VehicleID]");
   
    if (!strcmp(option, "buy", true))
    {
        switch(veh_id)
        {
            case 560:
            {
                GetPlayerPos(...);
                CreateVehicle(...);
                PutPlayerInVehicle(...);
            }
            default: SendClientMessage(playerid, -1, "Sorry, the Vehicle ID you have entered isn't available for purchase.");
        }
    }
   
    return true;
}
Reply
#6

Would it not be better to use names? Players don't know IDs. Better yet, use a menu/dialog list.
Reply
#7

And that's why I want to return 'ShowVehicleList', it shows the price + vehicle ID + name.
Anyone?
Reply
#8

pawn Код:
CMD:v(playerid, params[])
{
    new option[4], carid;
    if(unformat(params, "s[4]i",option, carid)) return SendClientMessage(playerid, -1, "Usage: /v [option] [car id]");
    if(carid < 400 || carid > 611) return SendClientMessage(playerid, -1, "car ids must be between 400 and 611");
    if(!strcmp(option, "buy", true))
    {
        new Float:Coord[3];
        GetPlayerPos(playerid, Coord[0],Coord[1],Coord[2]);
        CreateVehicle(carid,Coord[0],Coord[1],Coord[2], 0, COLOR, COLOR, RESPAWN_TIME);
    }
    else return SendClientMessage(playerid, -1, "usage: /v [buy] [car id]");
}
Reply
#9

Quote:

And that's why I want to return 'ShowVehicleList', it shows the price + vehicle ID + name.
Anyone?

....
Reply
#10

Try with:
pawn Код:
if (sscanf(params, "{s[100]}d", integer)) return ShowVehicleList(playerid);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)