Command engine doesn't work because another value
#1

Hi. I have this system that you need tires, engine and fuel to start a car.

PHP код:
stock StartVehicle(playerid)
{
    new 
GetPlayerVehicleID(playerid);
    
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
    if(
FOUR_TIRE(playerid) || FOUR_TIRE2(playerid))
    {
        if(
vInfo[i][vehicleFuel] >= 1)
        {
            if(
vInfo[i][vehicleTires] == 4)
            {
                if(
vInfo[i][vehicleEngine] == 1)
                {
                    
SetVehicleParamsEx(GetPlayerVehicleID(playerid),1,lights,alarm,doors,bonnet,boot,objective);
                }
            }
        }
        if(
vInfo[i][vehicleTires] <= 3)
        {
            
SetVehicleParamsEx(GetPlayerVehicleID(playerid),0,lights,alarm,doors,bonnet,boot,objective);
        }
    }

And this command

PHP код:
CMD:engine(playeridparams[])
{
    if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1"You need to be the driver of the vehicle");
    
GetVehicleParamsEx(GetPlayerVehicleID(playerid), enginelightsalarmdoorsbonnetbootobjective);
    if(
engine == 1)
    {
        
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0lightsalarmdoorsbonnetbootobjective);
        
SendClientMessage(playerid, -1"You have turned the engine off");
    }
    else
    {
        
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1lightsalarmdoorsbonnetbootobjective);
        
SendClientMessage(playerid, -1"You have turned the engine on");
    }
    return 
1;


But when I have 4/4 tires, 1/1 engine or 1/100 fuel, command :engine won't shut down the car.

Can you help me fixing it?
Reply
#2

post the whole code
Reply
#3

Quote:
Originally Posted by doodlebob666
Посмотреть сообщение
post the whole code
This is the whole code.
Reply
#4

instead of
pawn Код:
if(vInfo[i][vehicleFuel] >= 1)
set the code to

pawn Код:
if(vInfo[i][vehicleFuel] >= 0)
tell me if it work

You said you only put 1 fuel when testing, but the script says the value must be greater than 1
Reply
#5

Quote:
Originally Posted by doodlebob666
Посмотреть сообщение
instead of
pawn Код:
if(vInfo[i][vehicleFuel] >= 1)
set the code to

pawn Код:
if(vInfo[i][vehicleFuel] >= 0)
tell me if it work

You said you only put 1 fuel when testing, but the script says the value must be greater than 1
I said that, if i have 4/4 Wheels, 1/1 Engine and 1/100 (minimum) fuel, Command engine won't shut the engine because automatically script detects that it has 4/4 wheels, 1/1 engine and 1/100 fuel and it starts it back again.
Reply
#6

pawn Код:
if(vInfo[i][vehicleFuel] >= 1)
        {
            if(vInfo[i][vehicleTires] == 4)
            {
                if(vInfo[i][vehicleEngine] == 1)
                {
                    SetVehicleParamsEx(GetPlayerVehicleID(playerid),1,lights,alarm,doors,bonnet,boot,objective);
                }
            }
        }
What this is saying is "If the fuel is greater than 1, always keep the car on."
Using "SetVehicleParamsEx(GetPlayerVehicleID(playeri d),1,lights,alarm,doors,bonnet,boot,objective); "
keeps the car on even if the player uses /engine
The player only should control the engine, but it is automatically kept on. Find a way to fix it.

I think you should remove that part of the code then it'll be fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)