I need /fix command which will automaticly repair car

I need /fix command which will automaticly repair car,thank you

Client.lua

RegisterCommand("fix", function() -- Change "fix" if you wanna change the command
    local ped = PlayerPedId() -- Gets Player
    local veh = GetVehiclePedIsIn(ped) -- Get Vehicle Player Is In

    if IsPedSittingInAnyVehicle(ped) == false then -- Makes Sure Ped In In The Car
            return -- If Not In Vehicle Script Ends
        end
            if IsPedSittingInAnyVehicle(ped) == true then -- Makes Sure Ped In In The Car
            BringVehicleToHalt(veh, 2, 2, true) -- Stops Car
            SetVehicleFixed(veh) -- Fixes Car
            SetVehicleEngineOn(veh, true, true, false) -- Turns Engine On
            TriggerEvent('chatMessage', "Repair", {200,0,0}, "Your Car Is A lot Better!") -- A Little Message
    end
end)

fxmanifest.lua

fx_version 'cerulean'
games {'gta5'}

client_scripts {
    'client.lua',
}

Bro, this topic is over 2 years old xD haha
I think I commented on another of your posts earlier today too, where you used functions that served no purpose. Similarly here, you call the same one twice, for now reason. You should work on optimising your code. Why call “IsPedSittingInAnyVehicle” and return if false, then call it again to check if true? Bizarre… Also, if “GetVehiclePedIsIn” returns 0, then they aren’t in a vehicle, so calling “IsPedSittingInAnyVehicle” at all, after that, is redundant.

It’s good that you are trying to help people and answer threads, release scripts, etc. But the code should be better or you are teaching other people bad habits. Food for thought and I do wish you the best in becoming a better coder. Please take no offence, mate.

Anyway, for anyone that needs it.

RegisterCommand("fix", function()
	local ped = PlayerPedId()
	local vehicle = GetVehiclePedIsIn(ped, false)
	if vehicle ~= 0 and GetPedInVehicleSeat(vehicle, -1) == ped then
		SetVehicleFixed(vehicle)
		SetVehicleDeformationFixed(vehicle) -- Unsure if needed after SetVehicleFixed
		SetVehicleUndriveable(vehicle, false)
	end
end)

did not realize how old the post was lmfao

ye idky I called the IsPedSittingInAnyVehicle twice lol

the other things I had like ’ BringVehicleToHalt’ was to just give it a little customization