How do I make a function run every so and so seconds?

How do I make it so that it runs this function after a set amount of time:


function PrintSteamIDS()
    for _, v in ipairs( player.GetAll() ) do
        print( v:Nick().."'s SteamID is: "..v:SteamID() ) )
    end
end

I want this so that moderators and admins will know every players Steam Id incase they do something rule breaking worthy and then leave before they can get their SteamId.

Got that, how do I get that to work for just admins?

Tell your admins/mods to use “status” console command.

[editline]29th June 2013[/editline]

Running this seams counter-intuitive though. I’d recommend printing out steam-ids of players to admins as they connect/disconnect.

[lua]timer.Create( “mytimer”, 60, 0, PrintSteamIDS );

function PrintSteamIDS()
if ( !LocalPlayer( ):IsAdmin( ) ) then timer.Destroy( “mytimer” ); return; end
for _, v in ipairs( player.GetAll() ) do
print( v:Nick()…"'s SteamID is: "…v:SteamID() ) )
end
end[/lua]

The best way to do this is to store all ids of ever connected players into a table and print them via console command. And not to store them across server restarts.

That’s actually how I do it on one of the servers I code for. I just provided him help with what he wanted help with.

PrintSteamIDS is nil when you create the timer. Can’t have a pointer to something that doesn’t exist.