AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Player index question (https://forums.alliedmods.net/showthread.php?t=241446)

CHE4TER 06-03-2014 17:22

Player index question
 
When getting user auth id/name/etc, I need a index of [33] or higher?

PHP Code:

new steam[33]
get_user_authid(id,steam32)

new 
player[33
get_user_name(idplayer32

Does it matter? Or at different functions I will need to use more then that [33]?

!Morte 06-03-2014 18:33

Re: Player index question
 
To index an array for a player, you must use the [33], for every else you can use the number you want.

There you're trying to get the name/user id for a player, you must create an array in which you will keep the name, the number you put on that array is the length of the player name, in this case use 32 or less, because the engine has a limit of the name length. (It's not necessary to put a biggest number if you won't use all the array slots)

PHP Code:

new name32 ]
get_user_nameidname31 

Whatever, i suggest to you to take a look to this post: https://forums.alliedmods.net/showthread.php?t=172936 because my explanation it's a shit :3

Flick3rR 06-03-2014 18:40

Re: Player index question
 
Also is good to avoid hardcoding and use charsmax() or sizeof() - 1, isntead of just puttign 31 in the native. Not a big deal, but if you change some array size somewhere, the hardcoding may f*ck up everything.
PHP Code:

get_user_nameidname31 

-->
PHP Code:

get_user_nameidnamecharsmax(name) ) 


Fr33m@n 06-04-2014 18:05

Re: Player index question
 
more clear information about array and string size are available here.
https://forums.alliedmods.net/showth...t=94381#arrays


All times are GMT -4. The time now is 09:38.

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