How do I create an engine system and a total system?
#4

There are a lot of vehicle engine systems, all you need to do is to search. Here's a simple one I made using ZCMD for the engine command.
pawn Код:
#define     VEHICLE_PARAMS_OFF      0
#define     VEHICLE_PARAMS_ON       1

new VehicleEngine[MAX_VEHICLES];

public OnPlayerUpdate(playerid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new engine, lights, alarm, doors, bonnet, boot, objective;
        new vehicle = GetPlayerVehicleID(playerid);
        new Float:vehicleHP;
        GetVehicleHealth(vehicle, vehicleHP);
       
        if(vehicleHP <= 350) // set this to whatever you like
        {
            SetVehicleHealth(vehicle, 400);
            TogglePlayerControllable(playerid, false); // optional
            GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicle, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
            GameTextForPlayer(playerid, "~r~TOTALLED!", 1000, 5);
            VehicleEngine[vehicle] = VEHICLE_PARAMS_OFF;
        }
    }
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    new engine, lights, alarm, doors, bonnet, boot, objective;
    VehicleEngine[vehicleid] = VEHICLE_PARAMS_OFF;
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
    return 1;
}

CMD:engine(playerid, params[])
{
    #pragma unused params
    new engine, lights, alarm, doors, bonnet, boot, objective;
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new vehicle = GetPlayerVehicleID(playerid);
        if(VehicleEngine[vehicle] == VEHICLE_PARAMS_OFF)
        {
            VehicleEngine[vehicle] = VEHICLE_PARAMS_ON;
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
            SendClientMessage(playerid, -1, "Engine: ON");
        }
        else
        {
            VehicleEngine[vehicle] = VEHICLE_PARAMS_OFF;
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
            SendClientMessage(playerid, -1, "Engine: OFF);
        }
    }
    else SendClientMessage(playerid, -1, "
You're not in the driver's seat.");
    return 1;
}
Haven't tested it though.
Reply


Messages In This Thread
How do I create an engine system and a total system? - by Grooty - 09.09.2013, 23:28
Re: How do I create an engine system and a total system? - by Tom1412 - 09.09.2013, 23:39
Re: How do I create an engine system and a total system? - by Omar55555 - 09.09.2013, 23:43
Re: How do I create an engine system and a total system? - by Eyce - 09.09.2013, 23:46
Re: How do I create an engine system and a total system? - by Grooty - 09.09.2013, 23:54
Re: How do I create an engine system and a total system? - by Ceez - 10.09.2013, 09:34

Forum Jump:


Users browsing this thread: 1 Guest(s)