RegisterNetEvent(“SetVehicleFixed”)
AddEventHandler(‘SetVehicleFixed’, function(message)
Citizen.CreateThread(function() – Created a new thread
Citizen.Wait(50) – A wait function for 50 miliseconds.
local playerPed = GetPlayerPed(-1) – Gets the player that ran the command.
if playerPed and playerPed ~= -1 then – Checks if the player exists
local car = GetVehiclePedIsIn(playerPed,false)
SetVehicleEngineHealth(car, 1000)
TriggerEvent(‘chatMessage’, ‘VehicleRepair:’, {0, 255, 0}, “Vehicle fixed.”)
elseif IsPedOnFoot(GetPlayerPed(-1)) then
TriggerEvent(‘chatMessage’, ‘VehicleRepair:’, {255, 0, 0}, “You are not in a car!”)
end
end
end)
end)
^ Whats wrong with this… this should work!!! ^
RegisterServerEvent(“chatCommandEntered”)
AddEventHandler(‘chatCommandEntered’, function(fullcommand)
command = stringsplit(fullcommand, " ")
if(command[1] == "/fix") then -- Captures the command
TriggerClientEvent("SetVehicleFixed", source, command[2])
end
end)
function stringsplit(self, delimiter) – A function
local a = self:Split(delimiter) – Splits the string.
local t = {} – Creates a table
for i = 0, #a - 1 do – For loop to loop through all the arguments.
table.insert(t, a[i]) – Inserts the arguments into a table
end
return t – Returns the table
end
^ Also this is messed up and i need help fixing it. ^