question get_user_name
for information like getting players name, steamid would it more efficient to get them one time on client_putinserver and use i.e. zName where ever u need them through out a large plugin?
or to get the information only where u need them? PHP Code:
i.e. = In example |
Re: question get_user_name
with player name its best to use in local functions as a players name could change during gameplay.
|
Re: question get_user_name
ah I see in terms of having it working properly.
how about just plugin/CPU resource efficiency? |
Re: question get_user_name
There is no reason to cache the information unless you use it often or need to loop through all of them quickly. Also, your example will only work correctly for mapname and hostname (assuming the hostname doesn't change).
|
Re: question get_user_name
yeah I will be using name and steamid often. maybe IP as well.
so in this case in terms of plugin/CPU resource efficiency these would be best fetched on client_putinserver ? it wont matter if someone changes name during game and thus not displaying the correct name after fetching it. as long as the steamid shows up correctly. |
Re: question get_user_name
It is best to get the name each time you need to use it. A player's SteamID will never change though, so that can be cached if you need it to be.
|
Re: question get_user_name
what about replacing new with static ?
will that use less CPU ? http://forums.alliedmods.net/showthread.php?t=40340 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? how exactly is caching an user steamid done? |
Re: question get_user_name
Quote:
Most of the time, you can get a way with using a plain global. Quote:
There are ways to cache and keep names up-to-date but I would not recommend them for you. Quote:
|
Re: question get_user_name
:) thanks, so I can use static for getting steamid?
PHP Code:
do statics get refreshed on map change? Quote:
otherwise we look up their steamid in our database, it saves a lot of time if we dont always have to do this. I do have concerns about it not working propperly on One idea I have in mind but not yet started working on, so will see : ) Quote:
which wouldn't make sense as it sounds like thats what the method is trying to avoid. could you give me an example of how to cache getting steamid ? am pretty new to this and want to learn. |
Re: question get_user_name
You are digging way to much into this "optimization" thing. Don't optimize because you can, optimize because it should be. There are some things that you should not optimize as it ends up hurting the usability or readability of the plugin
|
| All times are GMT -4. The time now is 06:22. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.