How can I make a key on the keyboard do something in game for example when i press 2 the engine turns on?
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys & KEY_LOOK_BEHIND && IsPlayerInAnyVehicle(playerid))
{
new EngineStatus, lights, alarm, doors, bonnet, boot, objective;
new vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid,EngineStatus,lights,alarm,doors,bonnet,boot,objective);
if(vid != INVALID_VEHICLE_ID && EngineStatus== 0)
{
SetVehicleParamsEx(vid, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective); //engine started
}
else if(vid != INVALID_VEHICLE_ID && EngineStatus== 1)
{
SetVehicleParamsEx(vid, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective); //engine stopped
}
}
return 1;
}