[Release][FX] Fix-Clean Vehicle Command

This was requested, so here it is! I created this fairly quickly (~5-10 minutes) and I’m pretty new to this so please critique if possible! I also didn’t comment anything because, as I said, I made it quickly. Have fun! :slight_smile:

Installation
Install it as any normal script.

Config
Open server.lua
Don’t touch the code. Look at the Config.

everyoneAllowed - It is False at default.

  • True - Everyone is allowed to use the command, you do not need to add anyone to the allowed table
  • False - You need to add people to the allowed table to give them permission to use the table

allowed - Enter your steam IDs and IPs. DO NOT forget the commas and do not add a comma at the end.

Usage
Get in a vehicle and type “/fix” to fix it or type “/clean” to clean it in chat.

Download
V 1.0
Fix.zip (1.0 KB)
V 1.1
Fix.zip (1.1 KB)
V 1.2.5
FCV v1.2.5.zip (13.7 KB)

Changelog
V 1.0

  • Released

V 1.1

  • FX-Server Compatible
  • Notification if not in vehicle

V 1.2.5

  • Added whitelist for steamIDs and IPs
  • Added /clean command
  • Refined /fix’s functionality
22 Likes

Hello,
Just checking is this for FX Server or CFX?
I am on FX Server - When I type the command no error or chat message, but car doesn’t get repaired.

I grabbed a random civ car - or do you have to own it?

Thank you!

Murfasa built this based off of CFX-Server, which is what our server still runs, so that’s what he’s been familiarised with is CFX, not FX.

1 Like

Yeah, this is CFX. I’ll update that in the title.

1 Like

Updated for FX
Fix.zip (889 Bytes)

2 Likes

All thats needed to make it work is change the splitstring

Update V 1.1

  • FX-Server Compatible
  • Notification if not in vehicle

works great, is there a way to add a cooldown after using the command so people can’t spam it after every accident?
Another idea, can we charge money for a repair?

thanks for the scripts.

Yeah, I can work on adding a cool down. There is a way to charge money for a repair but it would depend on the system you are using for money. I’m still new to scripting and haven’t figured out how to get it to work with things such as essentialsmode. I’ll look into it at a later time :stuck_out_tongue: Stay tuned!

1 Like

Can you make a white list for it? Also you could do /fix to the nearest car to fix without being in ti

I could make a whitelist for it. In what case would you need to repair the nearest car? Just wondering…

I’m just saying like if you get out of your car and see damage you can repair it still without getting back in. Or you can do last entered car. idk just a suggestion

Maybe… I’ll see what I can do regarding that but not sure. Thanks for the suggestion anyways!

Changelog
V 1.2.5

  • Added whitelist for steamIDs and IPs
  • Added /clean command
  • Refined /fix’s functionality

Hi, I have this in my server and whenever i do the /fix an error message shows up in the chat box but it still fixes the vehicle .How do i stop the error message from showing in the chat box??

The error command might be from a whole different plugin, please screenshot whatever comes up.

I already removed it aha, and now the error message has dissapered???

That’s weird, no idea what the problem was, sorry. ;p

Works fine for me.

I added a repairing wait for this script (30 seconds). It basically puts in a delay b4 the fix script actually executes. There is also a notification that I added to tell the player that you have to wait 30 secs. After the time it repairs, I changed the true values to false for engine on, so the player has a bit of more immersion.

s_fcv.lua (just the code section, not configs)

AddEventHandler('chatMessage', function(source, n, msg)
	local msg = string.lower(msg)
	local identifier = GetPlayerIdentifiers(source)[1]
	if msg == "/fix" then
		CancelEvent()
		TriggerClientEvent('murtaza:delay', source)
		Citizen.Wait(15000)
		if everyoneAllowed == true then
			TriggerClientEvent('murtaza:fix', source)
		else
			if checkAllowed(identifier) then
				TriggerClientEvent('murtaza:fix', source)
			else
				TriggerClientEvent('murtaza:noPerms', source)
			end
		end
	elseif msg == "/clean" then 
		CancelEvent()
		if everyoneAllowed == true then
			TriggerClientEvent('murtaza:clean', source)
		else
			if checkAllowed(identifier) then
				TriggerClientEvent('murtaza:clean', source)
			else
				TriggerClientEvent('murtaza:noPerms', source)
			end
		end
	end
end)

function checkAllowed(id)
	for k, v in pairs(allowed) do
		if id == v then
			return true
		end
	end
	
	return false
end

Also, add this to
c_fcv.lua (just the code section again)

RegisterNetEvent('murtaza:delay')
AddEventHandler('murtaza:delay', function()
	notification("~g~Please wait 30 seconds for car to fully repair")
end)

and in the same lua file, put SetVehicleEngineOn( vehicle, false, false ) under RegisterNetEvent('murtaza:fix')

1 Like

Does this work with vRP?