24.05.2014, 12:15
try this
PHP код:
CMD:engine(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid, string[128];
vehicleid = GetPlayerVehicleID(playerid);
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(engine == VEHICLE_PARAMS_ON)
{
SetVehicleEngine(vehicleid, playerid);
}
else if((engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET))
{
if(Fuel[vehicleid] < 1.0)
{
SendClientMessageEx(playerid, COLOR_GRAD2, " Your vehicle is out of fuel, it won't start!");
}
else
{
for(new i=0; d<MAX_PLAYERVEHICLES; i++)
{
if(PlayerVehicleInfo[i][d][pvId] == vehicleid)
{
if(i == playerid)
{
else if(i == PlayerInfo[playerid][pVehicleKeysFrom])
{
if(!IsABike(vehicleid))
{
SendClientMessageEx(playerid, COLOR_WHITE, "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
{
SendClientMessageEx(playerid, COLOR_WHITE, "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 != playerid)
{
if(PlayerInfo[playerid][pHasCarJack] == 1)
{
if(PlayerInfo[playerid][pJackingCar] == 1)
{
SendClientMessageEx(playerid, COLOR_GRAD2, " You are already attempting to jack the car, please wait!");
return 1;
}
else
{
format(string, sizeof(string), "* %s takes out a set of tools and attempts to wire the ignition.", GetPlayerNameEx(playerid));
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SendClientMessageEx(playerid, COLOR_WHITE, "Attempting to wire the ignition...");
GameTextForPlayer(playerid, "~r~Attempting to wire the ignition...", 10000, 3);
SetTimerEx("WireIgnition", 10000, 0, "id", playerid, vehicleid);
PlayerInfo[playerid][pJackingCar] =1;
PlayerInfo[playerid][pJackAttempts] --;
if(PlayerInfo[playerid][pJackAttempts] == 0)
{
PlayerInfo[playerid][pHasCarJack] =0;
SendClientMessageEx(playerid, COLOR_WHITE, "This is your last attempt, the tool kit has worn down...");
}
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD2, " You do not have the keys for this vehicle / any car jacking items to start the ignition!");
}
}
}
}
}
}
}
return 1;
}