I’d like to comment that I have no professional training related to programming, so fails may happen.
VRP server-side only
I’m going to explain how to make the lscustoms to only be available to mechanics.
-------- Client-Side --------
First of all, create the variable.
local mecanico = false
Then create a Net Event to change the value if the client is mechanic.
RegisterNetEvent('verificacion')
AddEventHandler('verificacion', function(mech)
mecanico = mech
end)
To finish, add an if into the main thread in the first position to consume less (this way, if the client is not a mechanic, nothing else is executed).
Citizen.CreateThread(function()
while true do
if mecanico == true then
-- stuff
end
end
end)
(Optional)
If you want to consume less Client-Side you might add
Citizen.CreateThread(function()
while true do
if mecanico == true then
-- stuff
else
Citizen.Wait(X)
end
end
end
X would be an integer in ms. The script would wait client-side to re-check if the client is a mechanic. This is useful when a new mechanic is whitelisted by staff not to have to exit and re-enter to the server.
-------- Server-Side --------
In the server part you will have to take into account when the user joins, enters a group and exits a group.
This is the code I use:
AddEventHandler("vRP:playerSpawn", function(user_id, source, first_spawn)
if first_spawn then
if vRP.hasPermission({tonumber(user_id),"vehicle.repair"}) then
TriggerClientEvent('verificacion', -1, true)
end
end
end)
AddEventHandler("vRP:playerJoinGroup", function(user_id, group, gtype)
if group == "Mecánico" then
TriggerClientEvent('verificacion', -1, true)
end
end)
AddEventHandler("vRP:playerLeaveGroup", function(user_id, group, gtype)
if group == "Mecánico" then
TriggerClientEvent('verificacion', -1, false)
end
end)
You might change “vehicle.repair” to the main mechanics group (any that every mechanic has) and “Mecánico” to the whitelisted group/s.
Any feedback and is much appreciated.
Edit: This function only restrict the access to lscustoms. If your current lscustoms script does not allow other players to tune the cars, this won’t work. If you want that feature PM me.