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(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 ??
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: