27.08.2012, 11:56
Engine and lights with a key!
We need to define pressing keys.
pawn Code:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) //Detecting keys
pawn Code:
ManualVehicleEngineAndLights();//Instead of vehicle engines and lights automatic, they are now manual.
pawn Code:
if(PRESSED(KEY_SUBMISSION))//If the player pressed KEY_SUBMISSION (2)
{
pawn Code:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)//Checks if the player is the driver
{
pawn Code:
new vehicle = GetPlayerVehicleID(playerid);//Getting the players vehicle id.
pawn Code:
new engine,lights,alarm,doors,bonnet,boot,objective;//The vehicle params
pawn Code:
GetVehicleParamsEx(vehicle,engine,lights,alarm,doors,bonnet,boot,objective);//Getting the vehicle params
pawn Code:
if(engine == 0)//If the engine is off
{
pawn Code:
SetVehicleParamsEx(vehicle,1,1,alarm,doors,bonnet,boot,objective);//We turn on the engine and lights
pawn Code:
SendClientMessage(playerid,-1,"You started the engine!");
pawn Code:
}
else//Else is the engine is on
{
pawn Code:
SetVehicleParamsEx(vehicle,0,0,alarm,doors,bonnet,boot,objective);//We turn off the engine and lights
pawn Code:
SendClientMessage(playerid,-1,"You stopped the engine!");//Sends a message to the player telling him he stopped the engine.
}
pawn Code:
}
}
return 1;
}
Compile, now you have your own engine system using keys!.
If theres any bugs,spelling mistakes or anything else.
Please post here.
Hope i helped.