PDA

View Full Version : How do I create an engine system and a total system?


Grooty
09/09/2013, 11:28 PM
I want to make a /engine system for my script, as well as a total system.
How?

Tom1412
09/09/2013, 11:39 PM
Goto www.******.co.uk

search samp engine system

There you go use the ****** to search befor posting or the search button on forum

Omar55555
09/09/2013, 11:43 PM
and u should say extra informations like what kind of command inculde u using (strcmd-zcmd-ycmd-etcc.)

and search on ****** sure u will find something usefull like a good format etc..

Eyce
09/09/2013, 11:46 PM
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.
#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.

Grooty
09/09/2013, 11:54 PM
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.
#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.

Doesn't really work, but thanks :)

Ceez
10/09/2013, 09:34 AM
Use SetVehicleParams to toggle the engine/doors/lights/alarm status and those.
Check out http://wiki.sa-mp.com/wiki/SetVehicleParamsEx for more information.