problem with tuning command - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: problem with tuning command (
/showthread.php?tid=303467)
problem with tuning command -
Flovv - 13.12.2011
Hi.
I wanted to create a command on which my car gets tuned. There should be different tuning styles to select by parameter.
This works quite well, BUT the first tuning style is also applied if you just enter the command without parameter.
this is my command
pawn Код:
dcmd_nitro(playerid, params[]) //tuning
{
if(sscanf(params, "s"))
{
SendClientMessage(playerid, 0xFF0000FF, "Usage: /nitro <type>");
}
else if(IsPlayerInAnyVehicle(playerid) == 1)
{
if(!strcmp(params, "gold", true)) //yellow/black,switch rims
{
AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
AddVehicleComponent(GetPlayerVehicleID(playerid),1087);
AddVehicleComponent(GetPlayerVehicleID(playerid),1080);
ChangeVehicleColor(GetPlayerVehicleID(playerid),6,0);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
}
else if(!strcmp(params, "pink", true)) //pink/blue,offroad wheels
{
AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
AddVehicleComponent(GetPlayerVehicleID(playerid),1087);
AddVehicleComponent(GetPlayerVehicleID(playerid),1025);
ChangeVehicleColor(GetPlayerVehicleID(playerid),126,2);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
}
else{SendClientMessage(playerid, 0xFF0000FF, "SERVER: Please use a valid tuning style.");}
}
else {SendClientMessage(playerid, 0xFF0000FF, "SERVER: No car no nitro ;-)");}
return 1;
}
If anybody could tell me what i missed out here.... would be great
thanks in advance
Re: problem with tuning command -
Mokerr - 13.12.2011
Something like this?
pawn Код:
dcmd_nitro(playerid, params[]) //tuning
{
new type[10];
if(sscanf(params, "s[10]",type)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /nitro <type>");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "SERVER: No car no nitro ;-)");
if(strcmp(type,"gold",true) == 0)
{
AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
AddVehicleComponent(GetPlayerVehicleID(playerid),1087);
AddVehicleComponent(GetPlayerVehicleID(playerid),1080);
ChangeVehicleColor(GetPlayerVehicleID(playerid),6,0);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
SendClientMessage(playerid,0xFF0000FF, "Gold nitro activated!");
}
else if(strcmp(type,"pink",true) == 0)
{
AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
AddVehicleComponent(GetPlayerVehicleID(playerid),1087);
AddVehicleComponent(GetPlayerVehicleID(playerid),1025);
ChangeVehicleColor(GetPlayerVehicleID(playerid),126,2);
PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
SendClientMessage(playerid,0xFF0000FF, "Pink nitro activated!");
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "SERVER: Please use a valid tuning style.");
}
return 1;
}
AW: problem with tuning command -
Flovv - 13.12.2011
Thx for the quick help. Works fine now
Re: problem with tuning command -
Mokerr - 13.12.2011
You welcome.