09.09.2013, 23:28
I want to make a /engine system for my script, as well as a total system.
How?
How?
#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;
}
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 Код:
|
SetVehicleParams