[HELP] WIP Lscutom config.IsMecanoJobOnly if mecano connected

Hello everyone, I’m trying to custom the esx_lscustom script by adding the config.IsMecanoJobOnly variable set to true if a mecano is connected and set to false if no mecano are online.

in config file:

Config.IsMecanoJobOnly = false

in main/client.lua line 409:

		if (PlayerData.job ~= nil and PlayerData.job.name == 'mecano') or IsMecanoJobOnly == false then

in main/server.lua line 12:

    if  IsMecanoJobOnly == true then

I’m able to count the number of mecano connected with this:

local MecanoConnected       	   = 0
local IsMecanoJobOnly = nil
local xPlayers = ESX.GetPlayers()

MecanoConnected = 0

for i=1, #xPlayers, 1 do
		local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
		if xPlayer.job.name == 'mecano' then
			MecanoConnected = MecanoConnected + 1
--				if MecanoConnected >= 1 then      ------don't works
--				IsMecanoJobOnly=true
--				else 
--				IsMecanoJobOnly=false
--				end
		end
	end

	SetTimeout(5000, CountMecano)

end

I’m not able to find a way to change the value of IsMecanoJobOnly in the config file when mecano >=1

This script could be applied to activate some functions or scripts when it can be managed by players, like activate the NoNPCcarSteal if taxi are connected. Can’t restore cars when assureurs are connected etc…

Thanks for the help

1 Like

I haven’t got a clue because I know nothing about scripting, but I’m watching this to see if it gets figured out

Is it possible to change the value of this variable located in the config.lua file when a mecano is connected or a player take the job ?

Config.IsMecanoJobOnly = false