Raised This Month: $51 Target: $400
 12% 

get_user_name vs client_infochanged variable


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eyal282
Veteran Member
Join Date: Aug 2011
Old 07-04-2017 , 11:00   get_user_name vs client_infochanged variable
Reply With Quote #1

Which one is better? using the native get_user_name or creating a variable on client_authorized and hooking the change on client_infochanged?

Also I tried to do get_user_name in client_infochanged, no success although it works to hook post FM_ClientUserInfoChanged in fakemeta, why?

Last edited by eyal282; 07-04-2017 at 11:09.
eyal282 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-04-2017 , 11:53   Re: get_user_name vs client_infochanged variable
Reply With Quote #2

Unless you are going to retrieve users' names hundreds of times a second (if you are, you are probably doing something seriously wrong), it doesn't matter, just use get_user_name().
klippy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 07-04-2017 , 12:17   Re: get_user_name vs client_infochanged variable
Reply With Quote #3

Because using get_user_name() in client_infochanged() it's retrieving the 'Old Name' you have to use get_user_info to retrieve the new name.

For the sake of doing good things i believe is better to use the second operation, taking the name in an variable ant connnect+/and at client_infochanged().
__________________
Project: Among Us

Last edited by Craxor; 07-04-2017 at 12:18.
Craxor is offline
Send a message via ICQ to Craxor
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-04-2017 , 13:11   Re: get_user_name vs client_infochanged variable
Reply With Quote #4

Quote:
Originally Posted by Craxor View Post
For the sake of doing good things i believe is better to use the second operation, taking the name in an variable ant connnect+/and at client_infochanged().
It is extremely unlikely that this method is better. 99% of use cases, simply getting the user name when you need the user name is the best method.
__________________
fysiks is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-04-2017 , 13:14   Re: get_user_name vs client_infochanged variable
Reply With Quote #5

I agree with fysiks. Just use the native...
__________________

Last edited by HamletEagle; 07-04-2017 at 13:15.
HamletEagle is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 07-04-2017 , 13:15   Re: get_user_name vs client_infochanged variable
Reply With Quote #6

Quote:
Originally Posted by KliPPy View Post
Unless you are going to retrieve users' names hundreds of times a second (if you are, you are probably doing something seriously wrong), it doesn't matter, just use get_user_name().
Using a variable is much better when it comes to preferences, can I still use it or it doesn't matter and all ways are good?

Quote:
Originally Posted by HamletEagle View Post
I agree with fysiks. Just use the native...

If it's more comfortable to use a variable, should I or this way is a waste of resources?

Last edited by eyal282; 07-04-2017 at 13:16.
eyal282 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-04-2017 , 13:19   Re: get_user_name vs client_infochanged variable
Reply With Quote #7

We can't give you any more specific information without specific context. In general, if you need the player's name, just get the player's name.
__________________
fysiks is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 07-04-2017 , 13:28   Re: get_user_name vs client_infochanged variable
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
We can't give you any more specific information without specific context. In general, if you need the player's name, just get the player's name.
It's annoying to put this every time, are both methods good or mine is bad?
PHP Code:
new Name[32];
get_user_name(idName31); 
eyal282 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-04-2017 , 13:39   Re: get_user_name vs client_infochanged variable
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
We can't give you any more specific information without specific context.
I.e. attach your plugin.
__________________

Last edited by fysiks; 07-04-2017 at 13:40.
fysiks is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 07-04-2017 , 14:16   Re: get_user_name vs client_infochanged variable
Reply With Quote #10

Quote:
Originally Posted by eyal282 View Post
It's annoying to put this every time, are both methods good or mine is bad?
PHP Code:
new Name[32];
get_user_name(idName31); 
Write function that will return array, it is very comfortable. https://forums.alliedmods.net/showth...44#post2531044
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Reply



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 22:32.


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