📱
Shawn's Scripting
  • Overview
    • 💡Documentation
  • Products
    • 🛠️Shawn's Chat V2
      • ✔️Dependencies
      • 🧠Installation
      • 📝Admin Groups
      • 🔨Ace Perms Usage
      • ESX Notify To Overextended Notify
      • AdmWarn for ox_inventory giveitem
      • AdmWarn for fivem_appearance
      • AdmWarn for illenium-appearance
      • AdmWarn for /car
Powered by GitBook
On this page
  1. Products
  2. Shawn's Chat V2

AdmWarn for /car

Go to es_extended > server > commands.lua

Find the /car command and replace it with this:

ESX.RegisterCommand(
    "car",
    "admin",
    function(xPlayer, args, showError)
        if not xPlayer then
            return showError("[^1ERROR^7] The xPlayer value is nil")
        end

        local playerPed = GetPlayerPed(xPlayer.source)
        local playerCoords = GetEntityCoords(playerPed)
        local playerHeading = GetEntityHeading(playerPed)
        local playerVehicle = GetVehiclePedIsIn(playerPed)

        if not args.car or type(args.car) ~= "string" then
            args.car = "adder"
        end

        if playerVehicle then
            DeleteEntity(playerVehicle)
        end

        if Config.AdminLogging then
            ESX.DiscordLogFields("UserActions", "Spawn Car /car Triggered!", "pink", {
                { name = "Player", value = xPlayer and xPlayer.name or "Server Console", inline = true },
                { name = "ID", value = xPlayer and xPlayer.source or "Unknown ID", inline = true },
                { name = "Vehicle", value = args.car, inline = true },
            })
        end

        ESX.OneSync.SpawnVehicle(args.car, playerCoords, playerHeading, upgrades, function(networkId)
            if networkId then
                local vehicle = NetworkGetEntityFromNetworkId(networkId)
                for _ = 1, 20 do
                    Wait(0)
                    SetPedIntoVehicle(playerPed, vehicle, -1)

                    if GetVehiclePedIsIn(playerPed, false) == vehicle then
                        break
                    end
                end
                if GetVehiclePedIsIn(playerPed, false) ~= vehicle then
                    showError("[^1ERROR^7] The player could not be seated in the vehicle")
                end
            end
        end)

        TriggerEvent("shawn_rpchat:admwarn:car", xPlayer.source, xPlayer.source, args.car)
    end,
    false,
    {
        help = TranslateCap("command_car"),
        validate = false,
        arguments = {
            { name = "car", validate = false, help = TranslateCap("command_car_car"), type = "string" },
        },
    }
)

PreviousAdmWarn for illenium-appearance

Last updated 2 months ago

🛠️