01.08.2016, 19:17
PHP код:
CMD:engine(playerid, params[])
{
new
vehicleid,
carid,
model;
if (IsPlayerInAnyVehicle(playerid)) {
vehicleid = GetPlayerVehicleID(playerid);
model = GetVehicleModel(vehicleid);
carid = Car_GetID(vehicleid);
}
else
{
SendErrorMessage(playerid, "You are not in any vehicle.");
}
if (!IsEngineVehicle(vehicleid))
{
SendErrorMessage(playerid, "This vehicle doesn't have an engine.");
}
if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
SendErrorMessage(playerid, "You can't do this as you're not the driver.");
}
if (PlayerData[playerid][pInjured])
{
SendErrorMessage(playerid, "You can't do this while being injured or dead.");
}
if (ReturnVehicleHealth(vehicleid) <= 300)
{
SendErrorMessage(playerid, "This vehicle is totalled and can't be started.");
}
if (CoreVehicles[vehicleid][vehFuel] < 1)
{
SendErrorMessage(playerid, "The fuel tank is empty.");
}
if (carid != -1 && Car_IsOwner(playerid, carid) || CoreVehicles[vehicleid][vehTemporary] || CoreVehicles[vehicleid][vehRental] && PlayerData[playerid][pRentedVehicle] == vehicleid || CoreVehicles[vehicleid][vehJob] || (PlayerData[playerid][pFaction] != -1 && CarData[carid][carFaction] == GetFactionType(playerid)) || PlayerData[playerid][pCarKeys] == carid)
{
switch (GetEngineStatus(vehicleid))
{
case false:
{
SetEngineStatus(vehicleid, true);
ShowPlayerFooter(playerid, "You have ~g~started~w~ the engine!");
SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s inserts the key into the ignition and starts the engine of the %s.", ReturnName(playerid, 0), ReturnVehicleModelName(model));
}
case true:
{
SetEngineStatus(vehicleid, false);
ShowPlayerFooter(playerid, "You have ~r~stopped~w~ the engine!");
SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s inserts the key into the ignition and stops the engine of the %s.", ReturnName(playerid, 0), ReturnVehicleModelName(model));
}
}
}
else SendErrorMessage(playerid, "You don't have the keys to this vehicle.");
return 1;
}