How does GetGameTimer() work?


#1

Hello,

I’m trying to create a system whereby every 30 minutes I would be able to do a certain command. Let’s say I have a resource named A.

So every 30 minutes, it will send a command to the rcon that says ‘restart a’.

However, I don’t understand how the GetGameTimer() works as I thought it would be dependent on the time the server has been up in terms of milliseconds but for some reason it doesn’t work.

Tried to test it out whereby it will sends a ‘test’ per 1 minute in terms of seconds but it doesn’t work as it doesn’t even send one ‘test’.

time = GetGameTimer() 

Citizen.CreateThread(function()
	while(time % 60000 == 0)
	do
		print('test)	
	end
	
	end
)

Help is appreciated.

Regards
Marty


#2
Citizen.CreateThread(function()
  while true do
    Citizen.Wait(1000*60*30)
    -- run code here
  end
end)

Something like that should work, currently on my phone so don’t mind the messy example.


#3

Thanks for the help man, works like a charm! :slight_smile:


#4

By any chance, do you know why when I do an executecommand(‘restart resource’) it basically tells me access denied for command restart?


#5

Add this to your server.cfg:
add_ace resource.<resource name> command.restart allow
add_ace resource.<resource name> command.start allow
add_ace resource.<resource name> command.stop allow