for(new i; i < MAX_VEHICLES; i++) // This is the loop if i is greater then MAX VEHICLES it will continue.
{
new engine, lights, alarm, doors, bonnet, boot, objective; // Required variables.
engine = 0; // 0 means OFF, so when the server start's all car's are off.
lights = 0; // Same as engine.
SetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
}
return 1;
// Put the code above at end of InGameInit().
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) // This is when the player taps a button in keyboard.
{
if(newkeys & KEY_SUBMISSION) Number 2 or + in your keyboard.
{
if(IsPlayerInAnyVehicle(playerid)) // If the player is in any vehicle (I should have done this to state driver but anyways).
{
new engine, lights, alarm, doors, bonnet, boot, objective; // Variables to store the status.
new vid = GetPlayerVehicleID(playerid); // We need to get players vehicle to get the params.
GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective); // We need to get vehicle params in order to change them.
if(engine == 0) // If engine is OFF the code below turns on the engine.
{
SetVehicleParamsEx(vid,1,1,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid,-1,"You turned ON your vehicle engine and lights.");
return 1;
}
else if(engine == 1) // If the engine is ON so we turn it off.
{
SetVehicleParamsEx(vid,0,0,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid,-1,"You turned OFF your vehicle engine and lights.");
return 1;
}
else if(engine == -1) // If the params are unset let's take a example when you spawn a car as admin.
{
SetVehicleParamsEx(vid,1,1,alarm,doors,bonnet,boot,objective);
}
}
}
return 1;
}
if(newkeys & KEY_SUBMISSION) Number 2 or + in your keyboard. |
if(newkeys & KEY_SUBMISSION) //Number 2 or + in your keyboard. |
new engine, lights, alarm, doors, bonnet, boot, objective; // Required variables.
for(new i; i < MAX_VEHICLES; i++) // This is the loop if i is smaller then MAX VEHICLES it will continue.
{
if (GetVehicleModel(i) != 0) // Check if the vehicle exists
{
GetVehicleParamsEx(i, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(i, 0, 0, alarm, doors, bonnet, boot, objective); // Keep all parameters, but turn engine and lights off
}
}
return 1;
// Put the code above at end of InGameInit().