• How to get current gamemode of server?
    7 replies, posted
So I have a decent amount of lua scripts for my server, but most of them work only with TTT and break/cause ungodly amounts of errors in other gamemodes. How would I check what gamemode the server is in to make these scripts run only in ttt?
GAMEMODE_NAME is a global variable containing the name of a gamemode. [code]if ( not GAMEMODE_NAME == "terrortown" ) then return end[/code]
much thanks!
[QUOTE=code_gs;45708140]GAMEMODE_NAME is a global variable containing the name of a gamemode. [code]if ( not GAMEMODE_NAME == "terrortown" ) then return end[/code][/QUOTE] GAMEMODE_NAME indeed works...But You shouldn't use return if you aren't gonna return something on a hook
[QUOTE=gonzalolog;45710246]GAMEMODE_NAME indeed works...But You shouldn't use return if you aren't gonna return something on a hook[/QUOTE] I assumed he was going to be running it inside a function. It was just an example.
[QUOTE=gonzalolog;45710246]GAMEMODE_NAME indeed works...But You shouldn't use return if you aren't gonna return something on a hook[/QUOTE] You shouldn't return actual value, like true or false, returning nil shouldn't do anything.
If you want to prevent an addon from loading, use: [code]if ( string.lower( engine.ActiveGamemode( ) ) != "darkrp" ) then return; end[/code]
[QUOTE=Acecool;45712298]If you want to prevent an addon from loading, use: [code]if ( string.lower( engine.ActiveGamemode( ) ) != "darkrp" ) then return; end[/code][/QUOTE] That's an extra function call. Why use that when you can access the variable directly?
Sorry, you need to Log In to post a reply to this thread.