Need a little help please, slight problem please
#1

Well i am trying to make it so when you type /add it will give you a list of options you could put it so like for example

/add Nos - Nos would be added to the car
/add Hyrdolics - Hyrdolics would be added to the car


How would i make this be in one command


pawn Код:
CMD:add(playerid, params[])
{
    new string[64],
    option[4],
    Nos[4],
    Hyrodolics[5],
    Spolier[5],
    SideSkirts[12],
    Exaust[5];

    sscanf(params, "s", option);

    if (isnull(option))
  {
    SendClientMessage(playerid, COLOR_WHITE, " USAGE: /add [option]");
    SendClientMessage(playerid, COLOR_WHITE, " OPTIONS: Nos, Hyrodolics, Spoiler, SideSkirt,Exaust");
    return 1;
  }
    if (option(Nos))
    {
      SendClientMessage(playerid, 0x0000BBAA, "Hey");
    }
    if (option = Hyrodolics)
    {
      // Code for the drugs...
    }
    if (option = Spolier)
    {
      // Code for the money...
    }
    return 1;
  }

Thanks
Reply
#2

Use strcmp ...


pawn Код:
if (!strcmp("Nos",option))
{
    SendClientMessage(playerid, 0x0000BBAA, "Hey");
}
else if (!strcmp("Hyrodolics",option))
{
    // Code for the drugs...
}
else if (!strcmp("Spolier",option))
{
    // Code for the money...
}
Reply
#3

Here:
pawn Код:
CMD:add(playerid, params[])
{
    new string[64],
        option[4],
        Nos[4],
        Hydraulics[5],
        Spolier[5],
        SideSkirts[12],
        Exaust[5];

    sscanf(params, "s", option);

    if (isnull(option)) {
        SendClientMessage(playerid, COLOR_WHITE, " USAGE: /add [option]");
        SendClientMessage(playerid, COLOR_WHITE, " OPTIONS: Nos, Hydraulics, Spoiler, SideSkirt,Exaust");
        return 1;
    }
    if (strcmp("Nos",option)) {
        if (IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, 0x0000BBAA, "Nitro added");
            AddVehicleComponent(vehicleid, 1010);
        }
        else
        {
            return 1;
        }
    }
    else if (strcmp("Hydraulics",option)) {
        if (IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, 0x0000BBAA, "Hydraulics added");
            AddVehicleComponent(vehicleid, 1087);
        }
        else
        {
            return 1;
        }
    }
    else if (strcmp("Spolier",option)) {
        if (IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, 0x0000BBAA, "Spoiler added");
            AddVehicleComponent(vehicleid, 1003);
        }
        else
        {
            return 1;
        }
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Faisal_khan
Посмотреть сообщение
Here:
pawn Код:
CMD:add(playerid, params[])
{
    new string[64],
        option[4],
        Nos[4],
        Hydraulics[5],
        Spolier[5],
        SideSkirts[12],
        Exaust[5];

    sscanf(params, "s", option);

    if (isnull(option)) {
        SendClientMessage(playerid, COLOR_WHITE, " USAGE: /add [option]");
        SendClientMessage(playerid, COLOR_WHITE, " OPTIONS: Nos, Hydraulics, Spoiler, SideSkirt,Exaust");
        return 1;
    }
    if (strcmp("Nos",option)) {
        if (IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, 0x0000BBAA, "Nitro added");
            AddVehicleComponent(vehicleid, 1010);
        }
        else
        {
            return 1;
        }
    }
    else if (strcmp("Hydraulics",option)) {
        if (IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, 0x0000BBAA, "Hydraulics added");
            AddVehicleComponent(vehicleid, 1087);
        }
        else
        {
            return 1;
        }
    }
    else if (strcmp("Spolier",option)) {
        if (IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, 0x0000BBAA, "Spoiler added");
            AddVehicleComponent(vehicleid, 1003);
        }
        else
        {
            return 1;
        }
    }
    return 1;
}
Thank you but now i get these warnings


pawn Код:
warning 204: symbol is assigned a value that is never used: "Exaust"
warning 204:symbol is assigned a value that is never used: "SideSkirts"
warning 204: symbol is assigned a value that is never used: "Spolier"
warning 204: symbol is assigned a value that is never used: "Hydraulics"
warning 204: symbol is assigned a value that is never used: "Nos"
warning 204: symbol is assigned a value that is never used: "string"

Thank You
Reply
#5

pawn Код:
CMD:add(playerid, params[])
{
    new option,
        Nos,
        Hydraulics,
        Spolier,
        SideSkirts,
        Exaust;

    sscanf(params, "s", option);

    if (isnull(option)) {
        SendClientMessage(playerid, COLOR_WHITE, " USAGE: /add [option]");
        SendClientMessage(playerid, COLOR_WHITE, " OPTIONS: Nos, Hydraulics, Spoiler, SideSkirt,Exaust");
        return 1;
    }
    if (strcmp("Nos",option)) {
        if (IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, 0x0000BBAA, "Nitro added");
            AddVehicleComponent(vehicleid, 1010);
        }
        else
        {
            return 1;
        }
    }
    else if (strcmp("Hydraulics",option)) {
        if (IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, 0x0000BBAA, "Hydraulics added");
            AddVehicleComponent(vehicleid, 1087);
        }
        else
        {
            return 1;
        }
    }
    else if (strcmp("Spolier",option)) {
        if (IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, 0x0000BBAA, "Spoiler added");
            AddVehicleComponent(vehicleid, 1003);
        }
        else
        {
            return 1;
        }
    }
    return 1;
}
Reply
#6

Faisal , you don't need to use if (IsPlayerInAnyVehicle(playerid)) in every strcmp.

Just use one time in the top of command
Reply
#7

You set the value, but was never used.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)