• Running code after you have been initialized
    8 replies, posted
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 [url=http://wiki.garrysmod.com/?title=Gamemode.HUDShouldDraw]Gamemode.HUDShouldDraw[/url]
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. :D This is even better.
[QUOTE=Crazy Quebec;17227259]There's no hook specifically for that,[/QUOTE] Don't talk shit. InitPostEntity is only called after entitys (Including yourself) have spawned.
[QUOTE=|FlapJack|;17227596]Don't talk shit. InitPostEntity is only called after entitys (Including yourself) have spawned.[/QUOTE] Right, I don't know why but I forgot about shared hooks for a moment. No need to get angry. :)
Well it's pointless anyways, you can't run alias console commands in lua.
-snip-
Sorry, you need to Log In to post a reply to this thread.