AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_user_name vs client_infochanged variable (https://forums.alliedmods.net/showthread.php?t=299144)

eyal282 07-04-2017 11:00

get_user_name vs client_infochanged variable
 
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?

klippy 07-04-2017 11:53

Re: get_user_name vs client_infochanged variable
 
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().

Craxor 07-04-2017 12:17

Re: get_user_name vs client_infochanged variable
 
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().

fysiks 07-04-2017 13:11

Re: get_user_name vs client_infochanged variable
 
Quote:

Originally Posted by Craxor (Post 2533392)
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.

HamletEagle 07-04-2017 13:14

Re: get_user_name vs client_infochanged variable
 
I agree with fysiks. Just use the native...

eyal282 07-04-2017 13:15

Re: get_user_name vs client_infochanged variable
 
Quote:

Originally Posted by KliPPy (Post 2533388)
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 (Post 2533403)
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?

fysiks 07-04-2017 13:19

Re: get_user_name vs client_infochanged variable
 
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.

eyal282 07-04-2017 13:28

Re: get_user_name vs client_infochanged variable
 
Quote:

Originally Posted by fysiks (Post 2533405)
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); 


fysiks 07-04-2017 13:39

Re: get_user_name vs client_infochanged variable
 
Quote:

Originally Posted by fysiks (Post 2533405)
We can't give you any more specific information without specific context.

I.e. attach your plugin.

PRoSToTeM@ 07-04-2017 14:16

Re: get_user_name vs client_infochanged variable
 
Quote:

Originally Posted by eyal282 (Post 2533407)
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


All times are GMT -4. The time now is 23:08.

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