/engine 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: /engine command (
/showthread.php?tid=318882)
/engine command -
nmader - 16.02.2012
Alright, I ran and compiled this with no errors, but the minute I go to test it on my server, it doesn't work...
pawn Код:
if(!strcmp(cmdtext, "/engine", true))
{
new veh = GetPlayerVehicleID(playerid);
new engineStatus[MAX_VEHICLES];
if(engineStatus[veh] = 0)
{
new
engine,
lights,
alarm,
doors,
bonnet,
boot,
objective;
GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(veh, 1, lights, alarm, doors, bonnet, boot, objective);
engineStatus[veh] = 1;
}
else
{
new engine, lights, alarm, doors, bonnet, boot,objective;
GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(veh, 0, lights, alarm, doors, bonnet, boot, objective);
engineStatus[veh] = 0;
}
return 1;
}
Re: /engine command -
[Diablo] - 16.02.2012
i believe it's because you have a local variable engineStatus, and everytime you write /engine that specific var is 0, so it will always execute the first condition. am try making it global variable.
Re: /engine command -
Toreno - 16.02.2012
Try this, not tested though.
pawn Код:
if(!strcmp(cmdtext, "/engine", true)) {
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You are not in any vehicle.")
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You need to be the driver.");
new veh = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine) SetVehicleParamsEx(veh, 0, lights, alarm, doors, bonnet, boot, objective);
else SetVehicleParamsEx(veh, 1, lights, alarm, doors, bonnet, boot, objective);
return 1;
}