Car engine doesn't work normal
#1

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 ??
Reply
#2

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.
Reply
#3

Like I said, the command is all I have where do I need to define that ?
Reply
#4

Uh, just change engine == 0 to engine != 1
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
Uh, just change engine == 0 to engine != 1
In the command ?
Reply
#6

Lol, look at the code you posted.
Reply
#7

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
Reply
#8

I have fixed the problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)