• cvars.AddChangeCallback not working with settings from gamemode.txt?
    5 replies, posted
So I've made a gamemode which includes a few sub-gametypes, and when switching between these via the console, the round should restart. The problem is, if the command is created from the gamemode.txt file, it doesn't seem to want to add the callback; it seems like the client adds the callback instead of previously where it was only the server. I've since then moved it to init.lua, but then the callback is just not triggered at all. The setting looks like this: [CODE]"settings" { 1 { "name" "ytl_gametype" "text" "Starting Gametype" "help" "Choses which gametype to start the server as" "type" "Numeric" "default" "1" }[/CODE]
[quote=http://wiki.garrysmod.com/page/Gamemode_Creation]It's completely optional. Your text file doesn't have to have a settings section.[/quote] Why not use CreateConVar/CreateClientConVar? It's a lot easier.
Interesting, for now I'd just switch to the convar creation commands instead of the gamemode.txt. You should probably open a issue on the [url=https://github.com/Facepunch/garrysmod-issues/issues]facepunch-issues[/url] github. You're saying this used to work properly or it never has since you started working on the gamemode?
I noticed something like this or exactly like this when I tried adding main menu options for Garry's Mod Stranded, ended up writing my own system for synching these convars with the admins + a menu for changing them.
(Can't multiquote?) @stev_ When creating simple gamemodes for casuals, you'd much rather like settings that can be chosen on the main menu when launching a server. Much more clean and user friendly. @mcd1992 It never worked to begin with, although it worked before I used the settings feature, back when it was only a convar. For now I've just disabled this setting so the convar is the one that counts. @Robotboy655 Interesting, you could make two separate convars, one of which is only in the settings and is only used to set the gamemode one itself, which is then the one with the callback and the one it actually checks. Sounds like a good workaround.
[QUOTE=Zet0r;47817399](Can't multiquote?) @stev_ When creating simple gamemodes for casuals, you'd much rather like settings that can be chosen on the main menu when launching a server. Much more clean and user friendly. @mcd1992 It never worked to begin with, although it worked before I used the settings feature, back when it was only a convar. For now I've just disabled this setting so the convar is the one that counts. @Robotboy655 Interesting, you could make two separate convars, one of which is only in the settings and is only used to set the gamemode one itself, which is then the one with the callback and the one it actually checks. Sounds like a good workaround.[/QUOTE] Sounds so unnecessary I don't even want to bother.
Sorry, you need to Log In to post a reply to this thread.