YES this is a gmod and a lua question! I would like to know if its possible to run LUA commands though an addon when the user has just launched the game and if so how?
Asked
Active
Viewed 1,925 times
1 Answers
0
It is not possible to run Lua commands in the menu state when the user has launched the game. This is unless you mean when they first spawn into a map, which is possible - and is what I'm about to describe.
You can use the hook system to hook onto events that happen in the game. One of these hooks is Initialize
which is called when the game first loads and Lua is initialized. Another option is InitPostEntity
which is called after all map entities have been spawned.
To use the hook system, call hook.Add("Hook name", "Custom identifier", function(...) end)
For example, to use the Initialize
hook, use this code:
hook.Add("Initialize", "myidentifier", function()
-- put your code here
end)

MattJeanes
- 268
- 2
- 10
-
That's not what i meant but thank you fore telling me. :D i hope someone dose find a way though... – berrixsez Apr 21 '15 at 19:33