AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   GetClientOfUserId (https://forums.alliedmods.net/showthread.php?t=88963)

BenSib 03-31-2009 05:06

GetClientOfUserId
 
something that I still dont understand is the handling of userid. if I use for example GetClientOfUserId(i) and GetClientOfUserId(target) it does NOT return the userid displayed when you type "status" in console.

In SM documentation it says that GetClientOfUserId "Translates an userid index to the real player index". Could you quickly explain me what exactly it does?

If I define i:
Code:

        new maxClients = GetMaxClients();       
        for (new i = 1; i < maxClients; i++)

How would you get the userid of "i" for ex.?

CrimsonGT 03-31-2009 05:08

Re: GetClientOfUserId
 
That returns the client index. You are looking for GetClientUserId().

Also...As of SM 1.2 you can just use MaxClients. Theres no reason to use GetMaxClients() anymore.

BenSib 03-31-2009 05:17

Re: GetClientOfUserId
 
ok thanks, but I can get the client name of "i" with:

GetClientName(i, playerName, sizeof(playerName));

where is the userid?

btw: Maybe there is something that I completely ignore ;)

CrimsonGT 03-31-2009 05:19

Re: GetClientOfUserId
 
Im not exactly sure what you are trying to do. In your code, "i" would be the player index, so doing GetClientUserId(i) would return the client's userid.

BenSib 03-31-2009 05:30

Re: GetClientOfUserId
 
right thanks, the return can obviously not be print to chat:

PrintToChat(target, "That is the userid: %s", GetClientUserId(i));

CrimsonGT 03-31-2009 05:55

Re: GetClientOfUserId
 
GetClientUserId(i) returns an index, so you need %d (an integer value), not %s (a string)

BenSib 03-31-2009 05:58

Re: GetClientOfUserId
 
omg thats it. Much thanks CrimsonGT!

BAILOPAN 03-31-2009 08:39

Re: GetClientOfUserId
 
You're missing the last client, that should be <= not <


All times are GMT -4. The time now is 02:13.

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