20.04.2018, 03:31
why would I use big vars instead of PVars except for speed?
1) PVars can be shared/accessed across gamemode scripts and filterscripts, making it easier to modularise your code. 2) PVars are automatically deleted when a player leaves the server, meaning you don't have to manually reset variables for the next player who joins. 3) No real need for complex enums/player info structures. 4) Saves memory by not allocating pawn array elements for playerids which will probably never be used. 5) You can easily enumerate and print/store the PVar list. This makes both debugging and player info storage easier. 6) Even if a PVar hasn't been created, it still will return a default value of 0. 7) PVars can hold very large strings using dynamically allocated memory. |
1) True, but only useful for data that needs sharing, and as a general rule, you should provide function accessors, not shared global state. This is true for any variable type.
2) True, but hardly a hardship - you can reset an enum in one simple expression (even though many people don't). And if your default values aren't '0', you still need reset code. 3) Structured data is a GOOD thing! Though vast 'PlayerInfo' structures aren't. 4) False, PVars take WAY more space. 5) See 3 for why the 'PlayerInfo' pattern is bad. 6) In other words, it hides errors in yiur code, instead of having the compile pick them up instantly to fix them. 7) I've written a whole multi-language text library and not needed them yet. Oh, and contrary to popular belief, they are VASTLY slower, not just a little bit. |