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)