Quote:
Originally Posted by vamppa
what about replacing new with static ?
will that use less CPU ?
|
Regarding static variable and CPU usage, it's more important to understand the context of the variable in question. Static variables are most often used in functions that are called really often so you don't take the time to reallocate the memory for it. If you are using it in a chat command or admin command, you don't need it.
Most of the time, you can get a way with using a plain global.
Quote:
Originally Posted by vamppa
to Yamkikaitoe, I dont follow why it would be most resource friendly to get name each time I need it.
since that is what im asking, I dont mind if the nick gets changed.
rather get it one time and use memory, saving CPU usage.
or could it show up someone else his name due to player indexing over time?
|
Getting the name when you need it is usually done because it makes sense. If, for some odd reason, you don't care if the name is correct then you can cache it (if you don't care about the accurateness of the name then you should just get rid of it entirely, IMO). Also, depending on how you use the name, it might not work if it's not up-to-date.
There are ways to cache and keep names up-to-date but I would not recommend them for you.
Quote:
Originally Posted by vamppa
how exactly is caching an user steamid done?
|
SteamID is a string.
__________________