How would i change the Convar server info when a resource stops or starts?

hello i am trying to create a simple lua script so when a script starts/stops it updates a value in SetConvarServerInfo()

but it is not working.

code:

local config = json.decode(LoadResourceFile(GetCurrentResourceName(), 'config.json'))[1]

SetConvarServerInfo('Discord', config.Discord)
SetConvarServerInfo('Website', config.Website)
SetConvarServerInfo('Cad', config.Cad)
SetConvarServerInfo('Store', config.Store)
SetConvarServerInfo('Access Rank', config.AR)

local rname = GetCurrentResourceName()
RegisterServerEvent('checkr')
AddEventHandler('onResourceStart', function()
if rname == "usrp_password" then
	SetConvarServerInfo('Password', 'Enabled')
	ExecuteCommand("heartbeat")
			else
		SetConvarServerInfo('Password', 'Disabled')
		ExecuteCommand("heartbeat")
	end
end)


function check()
	TriggerEvent('checkr')
end

Citizen.CreateThread(function()
	while(true) do
	Citizen.Wait(0)
		check()
end
end)

PS: i have never done this before but i have done other lua code before.