SA-MP Forums Archive
Automatic Engine Start - 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: Automatic Engine Start (/showthread.php?tid=328337)



Automatic Engine Start - Dripac - 24.03.2012

I use the following timer

pawn Код:
public EngineStart()
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                new autoo = GetPlayerVehicleID(i);
                GetVehicleParamsEx(autoo,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(autoo,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
                Motor[autoo] = true;
            }
            else
            {
                NoFuel[i] = 1;
                GetVehicleParamsEx(vehicle,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                CreateBox(i,"Benzin","~r~Der Tank dieses Fahrzeugs ist leer");
            }
        }
    }
    return 1;
}
Now i want to make the engine turn off when there is no player inside the vehicle, what is the best method?


Re : Automatic Engine Start - KeeDee - 24.03.2012

public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}

And set the VehicleParamsEx to OFF.
Maybe with that's Code it's should works?


Re: Re : Automatic Engine Start - Dripac - 24.03.2012

Quote:
Originally Posted by KeeDee
Посмотреть сообщение
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}

And set the VehicleParamsEx to OFF.
Maybe with that's Code it's should works?
Yes, it will stop, but the engine will start again while the player is exiting and won't stop then


Re: Automatic Engine Start - emokidx - 24.03.2012

try this in the timer?
pawn Код:
new bool:vehicleused[MAX_VEHICLES];
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
                    vehicleused[GetPlayerVehicleID(i)] = true;
                    new autoo = GetPlayerVehicleID(i);
                    GetVehicleParamsEx(autoo,engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(autoo,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
                    Motor[autoo] = true;
        }
    }
    for(new i=1; i < MAX_VEHICLES; i++)
    {
        if(!vehicleused[i])
        {
                    NoFuel[i] = 1;
                GetVehicleParamsEx(vehicle,engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                    CreateBox(i,"Benzin","~r~Der Tank dieses Fahrzeugs ist leer");
        }
    }



Re: Automatic Engine Start - Dripac - 24.03.2012

It doesn't work


Re: Automatic Engine Start - Twisted_Insane - 24.03.2012

How about killing the timer?


Re: Automatic Engine Start - Dripac - 24.03.2012

Quote:
Originally Posted by Twisted_Insane
Посмотреть сообщение
How about killing the timer?
Under OnPlayerExitVehicle?


Re: Automatic Engine Start - Dripac - 25.03.2012

This doesn't even work, can anyone else help?