PDA

View Full Version : Need a little help please, slight problem please


Scripter12345
17/05/2012, 05:23 PM
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



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

ViniBorn
17/05/2012, 05:30 PM
Use strcmp ...



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...
}

Faisal_khan
17/05/2012, 05:32 PM
Here: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;
}

Scripter12345
17/05/2012, 05:52 PM
Here: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



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

Faisal_khan
17/05/2012, 05:58 PM
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;
}

ViniBorn
17/05/2012, 06:01 PM
Faisal , you don't need to use if (IsPlayerInAnyVehicle(playerid)) in every strcmp.

Just use one time in the top of command

.FuneraL.
17/05/2012, 06:02 PM
You set the value, but was never used.