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

"userid" vs "player"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ratty
SourceMod Donor
Join Date: Jan 2006
Old 06-01-2008 , 06:53   "userid" vs "player"
Reply With Quote #1

I tried searching for the answer, but as you can imagine searching for "player" is pretty hard to sift through.

http://wiki.alliedmods.net/Team_Fortress_2_Events

Sometimes its player instead of userid, for example teamplay_teambalanced_player

How can I do a GetClientOfUserId on this value? Better question is, what is "player" ? I tried and it never returns anything. If I just print out the results of GetEventInt(event, "player") I actually do get something that looks unique to the player.
ratty is offline
raydan
Senior Member
Join Date: Aug 2006
Old 06-01-2008 , 08:16   Re: "userid" vs "player"
Reply With Quote #2

/**
* Translates an userid index to the real player index.
*
* @param userid Userid value.
* @return Client value.
* @error Returns 0 if invalid userid.
*/
native GetClientOfUserId(userid);

in css, type status in console
# userid name uniqueid connected ping loss state
# 1254 "me" STEAM_0:1xx 43:53 86 0 active

red colour is a userid,
real player index must >0 and < 64(or <=64?)

download any sourcemod plugin, look at the source code, most plugins include that

in "teamplay_teambalanced_player", "player" = "userid", it need to translate to real player index.
raydan is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 06-01-2008 , 12:07   Re: "userid" vs "player"
Reply With Quote #3

Quote:
Originally Posted by raydan View Post
real player index must >0 and < 64(or <=64?)
Close. The client index must be between 1 and the max number of clients available on the server (16/24/32/64/etc).
bl4nk is offline
ratty
SourceMod Donor
Join Date: Jan 2006
Old 06-01-2008 , 14:51   Re: "userid" vs "player"
Reply With Quote #4

So how do I translate "real player index" into userid?
I already looked at another plugin that used teamplay_teambalanced_player, and they seemed to just GetEventInt on userid like normal, but I dont know for sure if that worked for them anyway. It was the class limits plugin. Its sure not working for me.

Here is my plugin:


Code:
HookEvent("achievement_earned",LogAchievement);

public LogAchievement(Handle:event,const String:name[],bool:dontBroadcast) {

decl String:pname[64];

// doing "player" instead of userid on the next line didnt help either
new client = GetClientOfUserId(GetEventInt(event, "userid"));

// Get the name of the player from "client"
GetClientName(client, pname, sizeof(pname));

new achievement = GetEventInt(event, "achievement");

LogMessage("\tplayer %s\tachievement %d",pname,achievement);
}
It keeps printing the hostname of the server for pname.
After I get that working, I was going to look up how to match the achievement numbers with the names, I'll post a list on the wiki when I can figure that out.

And here is a snippit from MaxClass.sp:

Code:
HookEvent("teamplay_teambalanced_player", PlayerTeamBalanced);

public Action:PlayerTeamBalanced(Handle:event, const String:name[], bool:dontBroadcast){
        if(!isrunning)
                return;

        if(!GetConVarBool(IsMaxPlayersOn))
                return;

        new client = GetClientOfUserId(GetEventInt(event, "userid"));

...

Last edited by ratty; 06-01-2008 at 15:10.
ratty is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 06-01-2008 , 15:03   Re: "userid" vs "player"
Reply With Quote #5

"player" is just the name they assigned to the integer. Using GetEventInt will give you said integer, which points to a client's userid (or possibly their clientid).
bl4nk is offline
ratty
SourceMod Donor
Join Date: Jan 2006
Old 06-01-2008 , 15:35   Re: "userid" vs "player"
Reply With Quote #6

Thanks for helping me with this guys.

I found the problem, I didn't know what a client id looked like, the 1-32 number, so all I had to do is not run it through GetClientOfUserId

new client = GetEventInt(event, "player");

And now I can just GetClientName on that all day and get good stuff.
Thanks!

Last edited by ratty; 06-01-2008 at 15:39.
ratty is offline
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 05:06.


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