PC-Carwash

PC-carwash

PC-carwash is a versatile and user-friendly FiveM script that enhances your server’s roleplay experience by adding customizable car wash locations. This script allows server owners to easily create and manage multiple car wash zones across the map, providing players with convenient locations to clean their vehicles. With adjustable washing durations, pre-configured default locations, and the ability to add custom car washes, PC-carwash offers a seamless and immersive feature for any FiveM server.

Dependencies

  • Ox Lib 3.22.2 or above.

Download - GitHub - Valocai/pc-carwash

Features

  • Customize how long it takes the wash the car
  • Easily add custom carwashes
  • Comes with 2 default carwashes (Davis and Strawberry)
  • User friendly.
  • Welcome message when entering the carwash and exit message when leaving it.

Installation

  1. Add pc-carwash to your servers resource folder.
  2. Add ox_lib to your resource folder and enusre it.
  3. Add ensure pc-carwash to your server.cfg
  4. Restart your server
  5. Enjoy!

Adding custom carwashes.

  1. Go into game and create a polyzone with ox-lib (/zone poly)
  2. When done, go to your ox_lib folder and then open created_zones.lua
  3. Copy the zone with the the name you put and add it to pc-carwash config.lua
  4. Restart pc-carwash or restart your server.
  5. Enjoy your new custom carwashes!

Showcase

3 Likes

Nice!!!

Little note: Preview video is not showing up.

1 Like

Hey mate, preview video should be showing up it is all fine on my end. Sadly if it isnt showing for you that is a forum issue. There is another preview on the github.

1 Like

GitHub video also not working for me. Even tried downloading the video and playing it locally.

I’ll try again later today. I’m currently not home and on my tablet. Usually don’t have issues with video, but I’ll assume it is on my end until I test it on my PC.

Either way, I starred you. :smirk:

I’m sure it’s fine, it’s a car wash. Not much can go wrong. I’m impressed that you made it totally standalone, aside from ox_lib. It’s nice to see more open source, framework agnostic resources again. Please, keep it up!

Thank you very much!

I love the idea of standalone resources and love making them (this is my second one and second ever script I made. Still learning!) I do plan to make alot more in the future standalone + have config options to work on other frameworks like qbcore, esx and qbox.

If you have any ideas lmk.

I’m learning, too. Not released anything yet.

I’ve been experimenting with bridge files. The idea is to write the resource once and let the bridge do the conversion between the various frameworks. This has been a challenge, and I need more practice.

I’m an old dude (56) so learning new skills, even Lua, has been difficult for me. I have worked with servers and in IT my whole adult life, but never learned programming. My brain just doesn’t think like a computer.

So, after three years of this, I can at least visualize the process. I know what needs to be done, just not how to write the solution. Not yet, anyway. I’ll get there.

Good Luck Mate!

You will get there.

Hey, awesome way of doing it, love it! Would you mind if I made some new additions to enhance even more your script?

Then If permitted, I’ll show how it changed with a short video preview, Cheers <3

Look how I modified :slight_smile:
* I HAVE NOT POSTED THIS RESOURCE AS I DID NOT GOT APPROVAL FROM YOU! Just posting the result to see if you liked

  • ¹Removed ox_lib dependency and replaced with draw3DText and zone detection via radius.

  • ²Dirt decreases overtime based on checking which state of dirt your vehicle is and procceds to clean gradually.

    • Speed of cleaning is based on your time set in config.lua, this line in the client is responsible:
      local totalTime = Config.Settings.wash_time.
  • Added rollers prop_carwash_roller_vert that will rotate accordingly within the cleaning time.

  • Added Custom roller Sound using the free resource PlayCustomSounds.

  • Added car wash water PTFX {dict = "scr_carwash", name = "ent_amb_car_wash_jet" .

  • Added DoScreenFadeOut and DoScreenFadeIn that prevents players from seeing the props spawn.

  • Added Rotation to the rollers as I said above:

    • local function rotateRollers() while true do Citizen.Wait(10) -- Adjust as needed for rotation speed for _, roller in ipairs(RollerObjects) do local currentRot = GetEntityRotation(roller) SetEntityRotation(roller, currentRot.x, currentRot.y, currentRot.z + 0.5, true) end end end

2:

    local function washCar()
    assert(IsPedInAnyVehicle(PlayerPedId(), false), "Player not in a vehicle")
    local playerVeh = GetVehiclePedIsIn(PlayerPedId(), false)
    
    local initialDirtLevel = GetVehicleDirtLevel(playerVeh)
    local targetDirtLevel = 0.0
    local currentTime = 0
    local totalTime = Config.Settings.wash_time * 1000

1:

 local function draw3DText(coords, text)
    local onScreen, _x, _y = World3dToScreen2d(coords.x, coords.y, coords.z)
    local camCoords = GetGameplayCamCoords()
    local dist = #(camCoords - coords)
    local scale = (1 / dist) * 2
    local fov = (1 / GetGameplayCamFov()) * 100
    scale = scale * fov
    
    if onScreen then
        SetTextScale(0.0, 0.35)
        SetTextFont(4)
        SetTextProportional(1)
        SetTextColour(255, 255, 255, 255)
        SetTextDropshadow(0, 0, 0, 0, 255)
        SetTextEdge(2, 0, 0, 0, 150)
        SetTextDropShadow()
        SetTextOutline()
        SetTextEntry("STRING")
        SetTextCentre(1)
        AddTextComponentString(text)
        DrawText(_x, _y)
    end
end

local function isInZone(zone)
    local playerCoords = GetEntityCoords(PlayerPedId())
    local dist = #(playerCoords - zone.coords)
    return dist < zone.radius
end

Hiya!

I love some of the changes you made but I do see a few issues.

  1. The rollers - While they are awesome to look at they do limit on where the carwash can be places (Example, a small carwash for motorbikes)

  2. I do plan on adding particles in the future and will defo use this as a reference.

  3. I did use location referencing before but moved to ox lib over 1, many recomendations and 2 was able to keep the script at a constant 0.00ms and 0.01ms when being used. So I will be keeping with ox-libs polyzones.

  4. Continuing with ox-lib. I much prefer the UI design that ox comes with, another reason I will be sticking with them.

Apologies if this is not the answer you where expecting but hey! We all prefer things being done a different way. I am more than happy for you to keep your code in here incase someone in the future does prefer your version and can easily swap it out.

I will look into implanting the gradual dirt while washing in the future also.

Thanks!

P.s, some cool looking scripts youve made.

1 Like

Hey!

Just to explain things to you. I never intended to say that your script was in need of these changes, and I know the reason of using ox_lib, I use it too, but for the sake of doing the way I thought that time, I had to remove ox_lib at the moment, as I did not know how to properly do what I wanted, so I just removed because of this reason.

The resmon was kept 0.03ms constant, it went up a little obviously, but I’ve never intended to seriously make this as a resource to be posted, I praise what you did, and you inspired me to do something I did not know I could do it!

It was fun learning how to properly use PTFX and the rollers, I know they do not fit correctly everytime, just know that you were a base for my learning and not the contrary, I’ll keep the resource I made to me as it’s obviously not ready to ship.

I was not expecting any other answer, just shared my thoughts and how I’ve used your ideas to create another thing.

P.S: For the gradual dirt, you can look at this, it was what I made to get it working better!

local function washCar()
    assert(IsPedInAnyVehicle(PlayerPedId(), false), "Player not in a vehicle")
    local playerVeh = GetVehiclePedIsIn(PlayerPedId(), false)
    
    local initialDirtLevel = GetVehicleDirtLevel(playerVeh)
    local targetDirtLevel = 0.0
    local currentTime = 0
    local totalTime = Config.Settings.wash_time * 800 
    
    while currentTime < totalTime do
        Citizen.Wait(800)  
        
        
        local progress = currentTime / totalTime
        
        
        local currentDirtLevel = initialDirtLevel * (1 - progress) + targetDirtLevel * progress

        SetVehicleDirtLevel(playerVeh, currentDirtLevel)
        
        currentTime = currentTime + 800  
    end

    deleteProps()
    TriggerEvent('chat:addMessage', {
        color = { 255, 0, 0},
        multiline = true,
        args = {"Car Wash", "Your vehicle has been washed!"}
    })
end

Thank you for appreciating my resources!