27.12.2015, 19:36
PHP код:
enum vInfo{
bool:pLuces,
bool:pMotor,
};
new pFunctionVehicles[MAX_VEHICLES][vInfo];
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys){
static
engine,lights,alarm,doors,bonnet,boot,objective;
new
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
// luces
if( newkeys & KEY_SUBMISSION ){
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "no estas en un vheiculo");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "no eres conductor");
if( !pFunctionVehicles[vehicleid][pLuces] ){
pFunctionVehicles[vehicleid][pLuces] = true;
SetVehicleParamsEx(vehicleid,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
}else{
pFunctionVehicles[vehicleid][pLuces] = false;
SetVehicleParamsEx(vehicleid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
}
}
// motor
if( newkeys & KEY_FIRE ){
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "no estas en un vheiculo");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "no eres conductor");
if( !pFunctionVehicles[vehicleid][pMotor] ){
pFunctionVehicles[vehicleid][pMotor] = true;
SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
}else{
pFunctionVehicles[vehicleid][pMotor] = false;
SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
}
}
return true;
}