vRP LSCustoms whitelisted & other player tuning

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 :heart: 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.

3 Likes

Hello, could you pass the full vrp_lscustom resources that you have edited? it does not work for me

@Inmortalesrp The lscustoms I use is private, I think it shouldn’t be difficult to follow that steps.

@jorwev Sorry for my English, I have a problem with vrp_lscustom, when a player modifies the car of another player does not save the changes, do you have the solution for that? or you know how to do so that any player can modify another player’s car

@Inmortalesrp 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. I’ll make a post explaining how to allow tunning to other players as soon as I have time.

@jorwev I would like you to do that publication and thank you

@jorwev I sent you a private message

@jorwev Hi, first of all thx for sharing your code, i tried using it but it doesnt seem to work, so imagine that the job on my server is called MechanicJob, i change your code “vehicle.repair” to MechanicJob and what about “Mecánico” i didnt understand what that is.

@David_Fernandes Vehicle.repair must be replaced by the main permission given to the mechanics. Mecánico must be changed by the group of mechanics.

For example:

  ["Mechanic"] = {  -- This is the GROUP NAME.
    _config = { gtype = "job",
	onspawn = function(player) vRPclient.notify(player,{"You are Mechanic, salary : $2000."}) end
	},
    "vehicle.repair", -- This could be the main PERM
    "vehicle.replace",
    "repair.service",
	"mission.repair.satellite_dishes",
	"mission.repair.wind_turbines",
	"repair.vehicle",
	"repair.market",
	"repair.paycheck"
  },

Send me a PM if you want me to make it for you.

I have developed the feature that a person (mechanic) can tune other person’s car saving tuning.

If you want it don’t hesitate to PM me.

2 Likes

Grande

did someone get it to work?

Does it work?

Someone knows how to do to save the tuning other person´s cars?

Someone knows how to do to save the tuning other person´s cars?

can someone help me make lscustom a job and that only he can tune other players cars? ^^

¡It doesn’t work!

I can’t make it work either !! can you help me?

hi, i’m new in this. i’m not understanding how u have make it, can u help me please