Car engine doesn't work normal -
IndependentGaming - 18.09.2016
Hello, I have made a car engine system in my gamemode.
Everything is working good but only the thing is if I enter a vehicle and use /engine if turns the engine off first, if I type /engine again then the engine goes on. How can I do it that you type /engine and the engine goes directly on in steat off first ?
Car engine command:
PHP код:
CMD:engine(playerid, params[]) {
new vehicleid = GetPlayerVehicleID(playerid), string[128];
new engine, lights, alarm, doors, bonnet, boot, objective;
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You're not in a vehicle.");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_WHITE, "You're not the driver of this vehicle!");
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == 0) {
SetVehicleParamsEx(vehicleid, true, lights, alarm, doors, bonnet, boot, objective);
format(string, sizeof string, "* %s has switched their engine on.", GetPlayerNameEx(playerid));
engine = 1;
}
else {
SetVehicleParamsEx(vehicleid, false, lights, alarm, doors, bonnet, boot, objective);
format(string, sizeof string, "* %s has switched their engine off.", GetPlayerNameEx(playerid));
engine = 0;
}
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
Do I need to add something else somewhere ??
Re: Car engine doesn't work normal -
Freaksken - 18.09.2016
When the engine stat is not set before, it will be -1instead of 0. In other words the value is initialized to -1 and not to 0.
Re: Car engine doesn't work normal -
IndependentGaming - 18.09.2016
Like I said, the command is all I have where do I need to define that ?
Re: Car engine doesn't work normal -
Vince - 18.09.2016
Uh, just change engine == 0 to engine != 1
Re: Car engine doesn't work normal -
IndependentGaming - 18.09.2016
Quote:
Originally Posted by Vince
Uh, just change engine == 0 to engine != 1
|
In the command ?
Re: Car engine doesn't work normal -
Freaksken - 18.09.2016
Lol, look at the code you posted.
Re: Car engine doesn't work normal -
IndependentGaming - 18.09.2016
Quote:
Originally Posted by Freaksken
Lol, look at the code you posted.
|
If I change it to engine != 1 the engine only goes off and not on
Re: Car engine doesn't work normal -
IndependentGaming - 18.09.2016
I have fixed the problem