20.05.2015, 20:42
How to make a fast engine system!
Hello! In this tutorial I'll be teaching you how to make a fast and easy to use engine activation command and stock!
How to make a fast engine system!
What this does is allow you to activate an engine whenever and not only in a command.
How to make a fast engine system!
You will need the following includes!
To begin, place these at the top of your script!
Next, you will need to place some variables, these variables will tell if the engine is off or on!
Once you have placed this in, you will need to create a section for your stocks, these will be used to turn on and off your engine!
Now, you have the stocks, the variables, and the includes, you will then need to create the command itself, to do this, we'll be using zcmd as listed above. Using ZCMD will process the command tons faster then the usual command processor by SA-MP.
You can use this for other purposes too!
Below, you will find OnPlayerEnterVehicle and OnPlayerExitVehicle, these public functions detect if the player is entering or exiting a vehicle.
Or you may simply download/copy it from here.
PASTEBIN #1 - http://pastebin.com/0z4uQKkY
Hello! In this tutorial I'll be teaching you how to make a fast and easy to use engine activation command and stock!
How to make a fast engine system!
What this does is allow you to activate an engine whenever and not only in a command.
How to make a fast engine system!
You will need the following includes!
- zcmd
- a_samp
To begin, place these at the top of your script!
pawn Код:
#include <a_samp> // THIS IS THE MOST IMPORTANT INCLUDE BY THE SA-MP TEAM
#include <zcmd> // THIS IS USED TO PROCESS COMMANDS FASTER!
Next, you will need to place some variables, these variables will tell if the engine is off or on!
pawn Код:
new IsEngineOn[MAX_PLAYERS];// THIS IS A VARIABLE!
pawn Код:
stock TurnEngineOn(playerid); //THE START OF THE STOCK
{
new vehicleid = GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective; //THIS GETS THE VEHICLE ID
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); //THIS GETS THE PARAMS FOR THE VEHICLE!
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective); //THIS UPDATES THE PARAMS OF THE VEHICLE TO TURN THE ENGINE ON!
IsEngineOn[playerid] = 1; //THIS TELLS THE VARIABLE THAT IT'S ON!
}
stock TurnEngineOff(playerid);
{
new vehicleid = GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective; //THIS GETS THE VEHICLE ID
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); //THIS GETS THE PARAMS FOR THE VEHICLE!
SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective); //THIS UPDATES THE PARAMS OF THE VEHICLE TO TURN THE ENGINE OFF!
IsEngineOn[playerid] = 0; //THIS TELLS THE VARIABLE THAT IT'S OFF!
}
pawn Код:
CMD:engine(playerid, params[]) //THE COMMAND THE PLAYER TYPES
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You must be in a vehicle to use this command."); //IT TELLS THEM IF THEY'RE ARE NOT IN A VEHICLE!
if(IsEngineOn[playerid] == 1) // WE'RE USING THE VARIABLE WE STORED AND TELL IT IF IT'S (1 == ON) OR (0 == OFF)
{
TurnEngineOn(playerid);
}
else
{
TurnEngineOff(playerid);
}
return 1;
}
Below, you will find OnPlayerEnterVehicle and OnPlayerExitVehicle, these public functions detect if the player is entering or exiting a vehicle.
pawn Код:
public OnPlayerEnterVehicle(playerid) //THE PUBLIC FUNCTION
{
TurnEngineOn(playerid); //TURNS THE ENGINE ON
return 1;
}
public OnPlayerExitVehicle(playerid)// THE PUBLIC FUNCTION
{
TurnEngineOff(playerid); //TURNS THE ENGINE OFF
return 1;
}
PASTEBIN #1 - http://pastebin.com/0z4uQKkY