[FREE] Simple Carwash

SIMPLE CARWASH

The car wash script is designed to be a seamless addition to any FiveM server, offering a simple yet effective vehicle cleaning solution. With its user-friendly configuration, this script integrates smoothly into your server and enhances the role-playing experience. For optimal performance, we recommend using GameBuild “2944”.

Key Features

  • Easy installation
  • Simple configuration
  • Realistic car wash effects
  • Progress display
  • Particle effects for a realistic touch

DOWNLOAD HERE

Important Note: Should you encounter any bugs or issues, please report them promptly so we can address them.

Code is accessible Yes
Subscription-based No
Lines (approximately) 100+
Requirements N/A
Support Yes.
7 Likes

any preview? :slight_smile:

Preview is in the making

Nice one! But you got 2 locations; 1 in the middle of the sea and 1 in a non existing building in the industrial part :stuck_out_tongue: (I removed it)

1 Like

We will remove it - thank you

Carwash Script Update - 31.07.2024

Changes:

Price Notification:

  • The amount is deducted from the player’s account immediately after the washing process.
  • The text adapts depending on whether a price is set or not.

Marker and Text Display:

  • Markers and text are only displayed when the player is in a vehicle.
  • Improved logic for displaying markers and texts near car washes.

Washing Process:

  • The washing process only starts when the player is in a vehicle.
  • Progress bar and particle effects have been maintained and optimized.

Server Callback for Price Verification:

  • New server callback carwash:chargePlayer to check the player’s account and deduct the money if sufficient funds are available.

General Improvements:

  • General improvements and optimizations have been made to the script.

Note:
We recommend a complete reinstallation of the Carwash script to take advantage of all the new features and improvements.

Thank you for your support and have fun playing!


If you have any questions or issues, please don’t hesitate to contact us in the support channel!

1 Like

Update is available and even got a few more improvements! :slightly_smiling_face:

1 Like

check pull request

1 Like

Looks pretty good! You did a great job my friend.

1 Like

You know that you are awesome right?

2 Likes

Thanks a lot Buddy

here is the client sided code to make it standalone

Config = {}
Config.CarWash = { positions = {} }

function LoadConfig()
    local configFile = LoadResourceFile(GetCurrentResourceName(), 'shared/config.lua')
    assert(load(configFile))()
end

LoadConfig()

local function createMarker(coord, size)
    local markerConfig = Config.CarWash.marker
    DrawMarker(
        markerConfig.type,
        coord.x, coord.y, coord.z - 1.2,
        0, 0, 0, 
        0, 0, 0, 
        size.x * markerConfig.scale.x,
        size.y * markerConfig.scale.y,
        size.z * markerConfig.scale.z,
        markerConfig.color.r,
        markerConfig.color.g,
        markerConfig.color.b,
        markerConfig.color.a,
        false, false, 2, false, nil, nil, false
    )
end

local function drawText3D(x, y, z, text)
    local onScreen, _x, _y = World3dToScreen2d(x, y, z)
    local px, py, pz = table.unpack(GetGameplayCamCoords())
    
    SetTextScale(0.35, 0.35)
    SetTextFont(4)
    SetTextProportional(1)
    SetTextColour(255, 255, 255, 215)
    SetTextEntry("STRING")
    SetTextCentre(1)
    AddTextComponentString(text)
    DrawText(_x, _y)
    
    local factor = (string.len(text)) / 370
    DrawRect(_x, _y + 0.0125, 0.015 + factor, 0.03, 41, 11, 41, 68)
end

local isWashing = false

for _, v in pairs(Config.CarWash.positions) do
    local zone = lib.zones.box({
        coords = v.coord,
        size = v.size,
        rotation = v.rot,
        debug = v.debug,
    })
    v.zone = zone

    function zone:onEnter()
        if not IsPedInAnyVehicle(cache.ped, false) then
            return
        end
        if Config.useRadial then
            lib.addRadialItem({
                id = 'carwash',
                icon = Config.radialData.icon,
                label = Config.radialData.label,
                onSelect = function()
                    TriggerEvent('nbw_carwash:CanWash')
                end
            })
            if Config.radialData.useNotify then
                lib.notify({
                    id = 'carwash_notify',
                    title = 'Carwash Available',
                    description = 'Drive into the zone to start the wash',
                    showDuration = false,
                    position = 'top-right',
                    style = {
                        backgroundColor = '#141517',
                        color = '#C1C2C5',
                        ['.description'] = {
                            color = '#909296'
                        }
                    },
                    icon = 'car-wash',
                    iconColor = '#C53030'
                })
            end
            return
        end
    end

    function zone:inside()
        if not IsPedInAnyVehicle(cache.ped, false) then
            return
        end
        if Config.useRadial then
            return
        end
        if IsControlJustReleased(0, 38) then
            TriggerEvent('nbw_carwash:CanWash')
        end
    end
end

AddEventHandler('nbw_carwash:CanWash', function()
    TriggerServerEvent('nbw_carwash:checkWash')
end)

function startWash()
    if isWashing then
        return
    end

    if not IsPedInAnyVehicle(PlayerPedId(), false) then
        lib.notify({
            id = 'no_vehicle',
            title = 'Car Wash',
            description = 'You must be in a vehicle to use the car wash.',
            showDuration = false,
            position = 'top-right',
            style = {
                backgroundColor = '#141517',
                color = '#C1C2C5',
                ['.description'] = {
                    color = '#909296'
                }
            },
            icon = 'exclamation-triangle',
            iconColor = '#C53030'
        })
        return
    end

    isWashing = true
    local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
    local dist = 'cut_family2'
    local fxName = 'cs_fam2_ped_water_splash'
    FreezeEntityPosition(vehicle, true)

    RequestNamedPtfxAsset(dist)
    while not HasNamedPtfxAssetLoaded(dist) do
        Wait(1)
    end
    UseParticleFxAssetNextCall(dist)
    local particle = StartParticleFxLoopedAtCoord(fxName, GetEntityCoords(PlayerPedId()), 0.0, 0.0, 0.0, 8.0, false, false, false, 0)

    if lib.progressCircle({
            duration = Config.CarWash.progress.duration,
            label = Config.CarWash.progress.label,
            position = Config.CarWash.progress.position,
            useWhileDead = false,
            canCancel = false,
            disable = {
                car = true,
                move = true,
                combat = true
            }
        })
    then
        StopParticleFxLooped(particle, false)

        SetVehicleDirtLevel(vehicle, 0.0)
        WashDecalsFromVehicle(vehicle, 1.0)

        FreezeEntityPosition(vehicle, false)

        isWashing = false

        lib.notify({
            id = 'wash_complete',
            title = 'Carwash Complete',
            description = Config.CarWash.washCompletionMessage,
            showDuration = false,
            position = 'top-right',
            style = {
                backgroundColor = '#141517',
                color = '#C1C2C5',
                ['.description'] = {
                    color = '#909296'
                }
            },
            icon = 'check-circle',
            iconColor = '#28a745'
        })
    end
end

RegisterNetEvent('nbw_carwash:startWash', startWash)

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        local playerCoords = GetEntityCoords(PlayerPedId())
        for _, location in ipairs(Config.CarWash.positions) do
            local coord = location.coord
            local size = location.size
            if Vdist(playerCoords, coord.x, coord.y, coord.z) < 10.0 then
                createMarker(coord, size)
                drawText3D(coord.x, coord.y, coord.z + 0.5, Config.CarWash.washText)
                if Vdist(playerCoords, coord.x, coord.y, coord.z) < 5.0 then
                    if IsControlJustReleased(1, 51) then
                        TriggerEvent('nbw_carwash:CanWash')
                    end
                end
            end
        end
    end
end)
1 Like

I will test it in a few Days!

It’s absolutely not “standalone”, the code still depends on Ox Lib.

and avoid using native vdist, which is not at all optimal.