SA-MP Forums Archive
[HELP] Command /engine SC-RP - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] Command /engine SC-RP (/showthread.php?tid=593667)



[HELP] Command /engine SC-RP - AtomicSAMP - 08.11.2015

owners and faction members can start the engine of the vehicle
Код:
CMD:engine(playerid, params[])
{
        new vehicleid = GetPlayerVehicleID(playerid);

        if (!IsEngineVehicle(vehicleid))
                return SendErrorMessage(playerid, "You are not in any vehicle.");

        if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
            return SendErrorMessage(playerid, "You can't do this as you're not the driver.");

        if (CoreVehicles[vehicleid][vehFuel] < 1)
            return SendErrorMessage(playerid, "The fuel tank is empty.");

        if (ReturnVehicleHealth(vehicleid) <= 300)
            return SendErrorMessage(playerid, "This vehicle is totalled and can't be started.");

        if(Car_IsOwner(playerid, vehicleid))
        {

                        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.", ReturnName(playerid, 0));
                                }
                                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.", ReturnName(playerid, 0));
                                }
                        }
                	return 1;
                    SendClientMessage(playerid, COLOR_LIGHTRED, "Vocк nгo possui as chaves desse veiculo.");
        }