• How could I edit/create a GM function from an addon?
    2 replies, posted
'GM' doesn't get recognized outside of the gamemode's code, so what would I put in it's place? Would it be like DARKRP.Initialize?
[QUOTE=Sheeplie;50757557]'GM' doesn't get recognized outside of the gamemode's code, so what would I put in it's place? Would it be like DARKRP.Initialize?[/QUOTE] what are you even trying to do? i think you should look for this: [url]http://wiki.garrysmod.com/page/hook/Add[/url]
All functions in "GAMEMODE" (the same as "GM") table automatically calling hooks, i.e. GM.PlayerDisconnected will call hook "PlayerDisconnected". You can hook to a function like this: [CODE]hook.Add( "PlayerDisconnected", "SomeUniqueName", function( arguments ) --do something end)[/CODE] If you really want to override gamemode function, GM table is exists only in gamemode Lua files. If you want to access GM table outside of them, you should use GAMEMODE table instead - they are the same, just different names. You can make your script universal (run everywhere) by adding something like this at the start of your Lua script: [CODE]local GM = GM or GAMEMODE[/CODE] and then using GM in your script. You can also use gmod.GetGamemode function instead of GM/GAMEMODE. Don't ask me why GM and GAMEMODE are separated, I have no idea.
Sorry, you need to Log In to post a reply to this thread.