I have a static variable "public static bool testMode = false;" which I can change the value to true from an in game command, but when it is changed to true and I restart my plugin, the value remains true - even after specifically unloading (oxide.unload) and loading it (oxide.load). Is this an Oxide bug, or is there something I'm not aware of? This value is NOT being saved in any file.
Solved Static variables keeping valid after reload
Discussion in 'Rust Development' started by Abnormal Zombie, Jan 29, 2018.
-
It is because the variable is static which makes is stay in same condition after plugin is reload
-
Also I suggest avoiding statics in modular design in any cost. All your variables are/should be encapsulated into your class and not leaked out. Specially when having a conversation with other modules.
-
Ohhh.... so Oxide simply makes a new instance of the plugin when it is reloaded. I see now.