AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Small question for get_user_name (https://forums.alliedmods.net/showthread.php?t=154566)

bibu 04-10-2011 10:28

Small question for get_user_name
 
And my question is this, I used this before:

PHP Code:

        new targetname[32]
        
get_user_name(tempidtargetname31)
        
        
client_print(idprint_chat"%s",  targetname

Now I found this somewhere and it works perfectly and I also like the way, I don't need to add make everytime a holder.

PHP Code:

client_print(idprint_chat"%s"username(tempid))

stock username(id)
{
    new 
player_name[32]
    
get_user_name(idplayer_namesizeof(player_name))
    
    return 
player_name


Is it ok to use it like that and would there be any big difference?

Arkshine 04-10-2011 10:29

Re: Small question for get_user_name
 
It's fine, though depending where you will use it, it may not work properly. I, personally, use often such stocks to have a code more readable.

bibu 04-10-2011 10:57

Re: Small question for get_user_name
 
Quote:

Originally Posted by Arkshine (Post 1447149)
it may not work properly. I, personally, use often such stocks to have a code more readable.

That was also the reason for me too. :)
And in which cases would it give me a problem then?

Arkshine 04-10-2011 11:32

Re: Small question for get_user_name
 
Don't remember exactly. Just remember having problem doing specific operation. When I will remember, I will post.

ConnorMcLeod 04-10-2011 12:02

Re: Small question for get_user_name
 
Change sizeof with charsmax in that stock, it will be more correct even if you can't have any error due to name length limitation.


All times are GMT -4. The time now is 19:53.

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