SA-MP Forums Archive
Car engine doesn't work normal - 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: Car engine doesn't work normal (/showthread.php?tid=617284)



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(playeridparams[]) {
    new 
vehicleid GetPlayerVehicleID(playerid), string[128];
    new 
enginelightsalarmdoorsbonnetbootobjective;
    if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridCOLOR_WHITE"You're not in a vehicle.");
    if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playeridCOLOR_WHITE"You're not the driver of this vehicle!");
    
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective);
    if(
engine == 0) {
        
SetVehicleParamsEx(vehicleidtruelightsalarmdoorsbonnetbootobjective);
        
format(stringsizeof string"* %s has switched their engine on."GetPlayerNameEx(playerid));
        
engine 1;
    }
    else {
        
SetVehicleParamsEx(vehicleidfalselightsalarmdoorsbonnetbootobjective);
        
format(stringsizeof string"* %s has switched their engine off."GetPlayerNameEx(playerid));
        
engine 0;
    }
    
ProxDetector(30.0playeridstringCOLOR_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