23.09.2012, 14:03
I can't find the keybind for car engine! I got some shit keybinds if i press S the engine will start and stop. Need help!
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_SUBMISSION)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == 1)
{
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0, lights, alarm, doors, bonnet, boot, objective);
SendClientMessage(playerid, 0xFF0000FF, "You Have Turned Your Vehicle's Engine Off."); //This line is not necessary and is completely optional.
}
else
{
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, lights, alarm, doors, bonnet, boot, objective);
SendClientMessage(playerid, 0x00FF00FF, "You Have Turned Your Vehicle's Engine On."); //Once again, this line is completely optional.
}
}
}
return 1;
}
CMD:car(playerid, params[]) { if(isnull(params)) { SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /car [name]"); SendClientMessageEx(playerid, COLOR_GREY, "Available names: Status, Engine, Lights, Trunk, Hood, Fuel"); return 1; } if(strcmp(params, "engine", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { new engine,lights,alarm,doors,bonnet,boot,objective,vehicleid; new Float:X, Float:Y, Float:Z; new string[128]; vehicleid = GetPlayerVehicleID(playerid); GetVehiclePos(vehicleid, X, Y, Z); if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_WHITE,"This command can't be used in this vehicle."); GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective); if(VehicleBomb[vehicleid] == 1) { SendClientMessageEx(playerid, COLOR_GRAD2, "**Your engine had a bomb in the engine**"); CreateExplosion(X, Y, Z, 7, 20); CreateExplosion(X, Y, Z, 2, 1); format(string, sizeof(string), "%s has blown up due to the engine was wired with a bomb",GetPlayerNameEx(playerid)); ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); VehicleBomb[vehicleid] = 0; return 1; } else { if(engine == VEHICLE_PARAMS_ON) { SetVehicleEngine(vehicleid, playerid); format(string, sizeof(string), "* %s has stopped his vehicle's engine", GetPlayerNameEx(playerid)); ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); } else if((engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET)) { SendClientMessageEx(playerid, COLOR_WHITE, "Vehicle engine starting, please wait..."); new rand = random(4); if(rand == 0) { SetTimerEx("SetVehicleEngine", 1000000000000, 0, "dd", vehicleid, playerid); SendClientMessage(playerid, COLOR_TWYELLOW, "Vehicle engine started"); format(string, sizeof(string), "* %s has started his vehicle's engine", GetPlayerNameEx(playerid)); ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); } if(rand == 1) { SendClientMessage(playerid, COLOR_TWYELLOW, "Vehicle engine failed to start"); format(string, sizeof(string), "* %s struggles to start the engine but fails", GetPlayerNameEx(playerid)); ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); } if(rand == 2) { SetTimerEx("SetVehicleEngine", 1000000000000, 0, "dd", vehicleid, playerid); SendClientMessage(playerid, COLOR_TWYELLOW, "Vehicle engine started"); format(string, sizeof(string), "* %s has started his vehicle's engine", GetPlayerNameEx(playerid)); ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); } if(rand == 3) { SetTimerEx("SetVehicleEngine", 100000000000, 0, "dd", vehicleid, playerid); SendClientMessage(playerid, COLOR_TWYELLOW, "Vehicle engine started"); format(string, sizeof(string), "* %s has started his vehicle's engine", GetPlayerNameEx(playerid)); ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); } } } }
SetTimerEx("SetVehicleEngine", 1000000000000, 0, "dd", vehicleid, playerid);
SetTimerEx("SetVehicleEngine", 1000, 0, "dd", vehicleid, playerid);