How to define and call a global timer DarkRP

I would like a timer that calls a function every x time, on my DarkRP server.

So, I made an addon folder to decouple it and added an init.lua file:

With the code:

function GameInitialize()
	timer.Create("lightTimer", 10, 0, PrintMessage(HUD_PRINTTALK, "Light mod message"))

hook.Add("Initialize", "gameInit", GameInitialize)

The console shows on start up that it is found and mounted, yet nothing happens.

What am I doing wrong?

[lua]function GameInitialize()
timer.Create(“lightTimer”, 10,0 function() for k,v in pairs(player.GetAll()) do v:PrintMessage(HUD_PRINTTALK, “Light Mod Message”) end end)
hook.Add(“Initialize”,“gameinit”, GameInitialize)[/lua]

Bo98 is right. Sorry, I searched for PrintMessage and missed the global function

[lua]function GameInitialize()
timer.Create(“lightTimer”, 10,0 function() PrintMessage(HUD_PRINTTALK, “Light Mod Message”) end)
hook.Add(“Initialize”,“gameinit”, GameInitialize)[/lua]

You don’t need to loop when you can use the PrintMessage global like the OP is.

You still need to wrap it in a function like you have done though.

Ahhhh thanks guys. Similar to JS.

edit: It’s still not working :confused: no Lua errors or anything. Should there be a cl_init.lua too?

Try just putting:
[lua]timer.Create(“lightTimer”, 10,0 function() PrintMessage(HUD_PRINTTALK, “Light Mod Message”) end)[/lua]
in a serverside file