Functions

------------- 
--- Help Text
-------------
function showHelpText(text)
    SetTextComponentFormat("STRING")
    AddTextComponentString(text)
    DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end

------------- 
--- Notify
-------------
function Notify(msg, type)
    if type == "primary" then
        lib.notify({ title = 'Notification', description = msg, type = 'inform' })
    elseif type == "error" then
        lib.notify({ title = 'Notification', description = msg, type = 'error' })
    elseif type == "success" then
       lib.notify({ title = 'Notification', description = msg, type = 'success' })
    end
end


function SpawnVehicle(model)
    local coords = {
        x = 137.92,
        y = -3023.74,
        z = 7.04,
        w =  270.38,
    }

    ESX.Game.SpawnVehicle(model, coords, 100.0, function(veh)
        SetVehicleNumberPlateText(veh, "TUNNERS")
        SetEntityHeading(veh, 274.67)
        TaskWarpPedIntoVehicle(PlayerPedId(), veh, -1)
        SetVehicleFuel(veh, 100.0)
        SetEntityAsMissionEntity(veh, true, true)
        TaskWarpPedIntoVehicle(PlayerPedId(), veh, -1)
        SetVehicleEngineOn(veh, true, true)
    end)
end

RegisterNetEvent(Config.Prefix..":Client:ReturnVehicle", function()
    local InVehicle = IsPedInAnyVehicle(PlayerPedId())
    if InVehicle then
        ESX.Game.DeleteVehicle(GetVehiclePedIsIn(PlayerPedId()))
    end
end)


-------------------- Functions

function CleanVehicle(vehicle)
    local ped = PlayerPedId()
    local pos = GetEntityCoords(ped)
    TaskStartScenarioInPlace(ped, "WORLD_HUMAN_MAID_CLEAN", 0, true)
    lib.progressBar({
        duration = 10000,
        label = ProgressBars["LimparVeiculo"],
        useWhileDead = false,
        canCancel = false,
        disable = {
            car = true,
            move = true,
            cobat = true,
        },
    }) 
    Notify(Language["VeiculoLimpoComSucesso"])
    SetVehicleDirtLevel(vehicle, 0.1)
    SetVehicleUndriveable(vehicle, false)
    WashDecalsFromVehicle(vehicle, 1.0)
    TriggerServerEvent(Config.Prefix..":Server:RemoveItem", "cleaningkit", 1)
    ClearAllPedProps(ped)
    ClearPedTasks(ped)  
end

-------------------- Commands
RegisterCommand("cleanvehicle", function()
    CleanVehicle(vehicle)
end)

function Duty()
    -- You can change the event to your duty
end

Last updated