Raised This Month: $ Target: $400
 0% 

question get_user_name


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-24-2013 , 14:13   Re: question get_user_name
Reply With Quote #8

Quote:
Originally Posted by vamppa View Post
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 View Post
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 View Post
how exactly is caching an user steamid done?
SteamID is a string.
__________________

Last edited by fysiks; 07-24-2013 at 14:14.
fysiks is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode