29.10.2015, 16:36
I did it so you have to do /engine to start the car but if you do not own the vehicle you cannot start it and only the owner can and this works but it stops factions/jobs employees from starting their vehicles.
Код:
CMD:engine(playerid, params[]) { new engine,lights,alarm,doors,bonnet,boot,objective,vehicleid, string[128]; vehicleid = GetPlayerVehicleID(playerid); if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessage(playerid,COLOR_WHITE,"{F81414}[ERROR]: {FFFFFF}This command can't be used in this vehicle."); GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective); if(engine == VEHICLE_PARAMS_ON) { format(string, sizeof(string), "*[SERVER]: %s twists the key in the ignition, turning the engine off.", GetPlayerNameEx(playerid)); ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); SetVehicleEngine(vehicleid, playerid); } else if((engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET)) { { foreach(Player, i) { for(new d=0; d<MAX_PLAYERVEHICLES; d++) { if(PlayerVehicleInfo[i][d][pvId] == vehicleid) { if(i == playerid) { if(!IsABike(vehicleid)) { SendClientMessage(playerid, COLOR_WHITE, "[SERVER]: Vehicle engine starting, please wait..."); SetTimerEx("SetVehicleEngine", 1000, 0, "dd", vehicleid, playerid); format(string, sizeof(string), "* %s twists the key in the ignition, turning the engine on.", GetPlayerNameEx(playerid)); ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); return 1; } else { SendClientMessage(playerid, COLOR_WHITE, "[SERVER]: Vehicle engine starting, please wait..."); SetTimerEx("SetVehicleEngine", 700, 0, "dd", vehicleid, playerid); format(string, sizeof(string), "* %s flips the killswitch to the on position and depresses the ignition switch, turning the engine on.", GetPlayerNameEx(playerid)); ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); return 1; } } else if(i == PlayerInfo[playerid][pVehicleKeysFrom]) { if(!IsABike(vehicleid)) { SendClientMessage(playerid, COLOR_WHITE, "[SERVER]: Vehicle engine starting, please wait..."); SetTimerEx("SetVehicleEngine", 1000, 0, "dd", vehicleid, playerid); format(string, sizeof(string), "* %s twists the key in the ignition, turning the engine on.", GetPlayerNameEx(playerid)); ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); return 1; } else { SendClientMessage(playerid, COLOR_WHITE, "[SERVER]: Vehicle engine starting, please wait..."); SetTimerEx("SetVehicleEngine", 700, 0, "dd", vehicleid, playerid); format(string, sizeof(string), "* %s flips the killswitch to the on position and depresses the ignition switch, turning the engine on.", GetPlayerNameEx(playerid)); ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); return 1; } } else { SendClientMessage(playerid, COLOR_GRAD2, "{F81414}[ERROR]: {FFFFFF}You do not have the keys for this vehicle / any car jacking items to start the ignition!"); return 1; } } } } } } return 1; }