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!
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.
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?
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 Stay tuned!
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
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??
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')