09.08.2017, 01:50
Try this
pawn Код:
CMD:engine(playerid, params[])
{
new playername[25];
if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage2(playerid, COLOR_RED, "You must be the driver of a vehicle!");
new giveplayerid = GetPlayerVehicleID(playerid);
new moneys1 = GetVehicleModel(giveplayerid);
if (moneys1 == 481 || moneys1 == 509 || moneys1 == 510) return SendClientMessage2(playerid, COLOR_RED, "Error: This vehicle doesn't have an engine!");
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(giveplayerid, engine, lights, alarm, doors, bonnet, boot, objective);
new en = random(2);
for(new i = 0, playercount=GetPlayerPoolSize(); i <= playercount; i++)
{
if (PlayerVehicle(i, giveplayerid) != -1)
{
if (pvkeys[playerid][giveplayerid] == 0) return SendClientMessage(playerid, COLOR_RED, "Error: You dont have this vehicles keys.");
}
}
if (engine != 1)
{
if (floatround(Gas[giveplayerid]) <= 0) return SendClientMessage2(playerid, COLOR_RED, "Error: You have ran out of fuel!");
new vid = GetPlayerVehicleID(playerid);
new Float:Hel; GetVehicleHealth(vid, Hel);
if(Hel < 300.0)
{
return SendClientMessage(playerid, COLOR_RED, "Failed to start the engine, the engine is so much damaged.");
}
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
if (DoesVehicleTakeFuel(giveplayerid) && drivscstats[playerid][0] == 0)
{
if (IsVehicleBike(giveplayerid) && !dini_Isset(AddDirFile(dir_userfiles, playername), "licenseb")) return SendClientMessage2(playerid, COLOR_RED, "You don't have a bike license!");
else if (IsVehicleAircraft(giveplayerid) && !dini_Isset(AddDirFile(dir_userfiles, playername), "licensef")) return SendClientMessage2(playerid, COLOR_RED, "You don't have a flying license!");
}
if ((vorgo[giveplayerid] == 0 || vorgo[giveplayerid] == GetPVarInt(playerid, "playerorg")) && (vehstored[giveplayerid] == -1 || PlayerVehicle(playerid, giveplayerid)) && cfs[giveplayerid][0] != 1 && (en == 0 || GetPVarInt(playerid, "Engine") >= 2)) SetVehicleParamsEx(giveplayerid, 1, lights, alarm, doors, bonnet, boot, objective);
if (ptextdraw[playerid] == cartext1)
{
TextDrawHideForPlayer(playerid, cartext1);
KillTimer(textdtimer[playerid]);
}
if(en == 0 || GetPVarInt(playerid, "Engine") >= 2) {
SendClientMessage2(playerid, COLOR_GREEN, "~ Engine turned on!");
SetPVarInt(playerid, "Engine", 0);
}
}
else
{
SetVehicleParamsEx(giveplayerid, 0, lights, alarm, doors, bonnet, boot, objective);
SendClientMessage2(playerid, COLOR_WHITE, "~ Engine turned off!");
}
return 1;
}