Running code after you have been initialized

Hey guys,
Does anyone know a way to run client side code after you have been made visible to lua? I want to run a RunConsoleCommand right when I spawn, but you can’t just put that in the code or it’ll run too soon to do anything. Any client side hooks for waiting until you yourself have spawned?

There’s no hook specifically for that, but you could try some of the rendering hooks and see if one gets called at a time that suits you, for instance Gamemode.HUDShouldDraw

Ah, thank you very much, that’ll probably work.

A timer is helpful in this case, it’ll start running as soon as you’re loaded:

[lua]timer.Simple( 0.1, function( )
RunConsoleCommand( “lulz” )
end )[/lua]

Yeah I knew timers worked, but I did not know that they started when you’re loaded. That means that you don’t have to try and figure out the time between the timer starting and you loading, like I thought. :smiley: This is even better.

Don’t talk shit. InitPostEntity is only called after entitys (Including yourself) have spawned.

Right, I don’t know why but I forgot about shared hooks for a moment. No need to get angry. :slight_smile:

Well it’s pointless anyways, you can’t run alias console commands in lua.

-snip-