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

Learning some coding: what does this line of code do?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
__37__
Junior Member
Join Date: Dec 2004
Old 05-15-2005 , 20:02   Learning some coding: what does this line of code do?
Reply With Quote #1

I am looking through Beetle's Mod trying to get familiar with the players themselves and this seems to be a line used quite often when finding a player. I am curious what it actually returns.

IPlayerInfo *playerinfo = playerinfomanager->GetPlayerInfo(pEntity);

In this, what is playerinfo getting set to?

I would have searched, but I am not sure what to search for.
__37__ is offline
BeetleFart
SourceMod Donor
Join Date: Apr 2004
Old 05-15-2005 , 20:08   Re: Learning some coding: what does this line of code do?
Reply With Quote #2

Quote:
Originally Posted by __37__
I am looking through Beetle's Mod trying to get familiar with the players themselves and this seems to be a line used quite often when finding a player. I am curious what it actually returns.

IPlayerInfo *playerinfo = playerinfomanager->GetPlayerInfo(pEntity);

In this, what is playerinfo getting set to?

I would have searched, but I am not sure what to search for.
IPlayerInfo * playerinfo is a pointer to a class that contains information about each player
like score..team..health..etc

its used in CSSource..and wasnt last time I checked in HL2DM (though may be now)..

open playerinfomanager.h to see
__________________
CSource Server:
69.90.34.10:27015 Beetlesmod.com And CS-Addicts{US}



http://www.clanuseast.com
BeetleFart is offline
__37__
Junior Member
Join Date: Dec 2004
Old 05-15-2005 , 20:46  
Reply With Quote #3

hey Beetle, just want to say that your mod is awesome and we run it on both of our servers. thanks for the quick reply here also.

i guess what i am wondering is, what is playerinfomanager->GetPlayerInfo(pEntity) setting playerinfo to and what is the value that pEntity holds? is it like their steam id or slot number within the server? where does pEntity obtain the value used that is sent to GetPlayerInfo?

i see that when a client connects, the CEmptyServerPlugin::ClientActive function is called, and it is passed an (edict_t *pEntity). I have also noticed that edict_t is used everytime referencing a player. What is endict_t ?

Sorry for all the low level questions here, and i know that there are several resources out there that probably explain this, i just don't know where to start or what keywords to search for.
__37__ is offline
BeetleFart
SourceMod Donor
Join Date: Apr 2004
Old 05-15-2005 , 21:12  
Reply With Quote #4

Quote:
Originally Posted by __37__
hey Beetle, just want to say that your mod is awesome and we run it on both of our servers. thanks for the quick reply here also.

i guess what i am wondering is, what is playerinfomanager->GetPlayerInfo(pEntity) setting playerinfo to and what is the value that pEntity holds? is it like their steam id or slot number within the server? where does pEntity obtain the value used that is sent to GetPlayerInfo?

i see that when a client connects, the CEmptyServerPlugin::ClientActive function is called, and it is passed an (edict_t *pEntity). I have also noticed that edict_t is used everytime referencing a player. What is endict_t ?

Sorry for all the low level questions here, and i know that there are several resources out there that probably explain this, i just don't know where to start or what keywords to search for.

and edict_t * pEntity is the internal structure valve uses to represent all entities..

its not really usuable by u or me in it self (there are class pointers you can use but thats for more advanced programmers)

IPlayerInfo * is a pointer that valve provides to allow programmers to access more information about the pEntity..
IPlayerInfo * playerinfo has many class members that allow you to find out more info about the entity..

playerinfo->GetUserId(); returns the UserId ...the unique interger value for each player that increments for every new player...
theres playerinfo->GetNetworkIDString(); which returns a const char * to there steamid
(u can also use engine->GetPlayerNetworkIDString(pEntity); to get steamid as well bypassing the use of playerinfo)
theres int index=engine->IndexOfEdict(pEntity);
which gives the slot number (integer value from 1 to PlayersMax).
__________________
CSource Server:
69.90.34.10:27015 Beetlesmod.com And CS-Addicts{US}



http://www.clanuseast.com
BeetleFart is offline
__37__
Junior Member
Join Date: Dec 2004
Old 05-15-2005 , 21:24  
Reply With Quote #5

great Beetle. let me make sure i am understanding here.

there are basically 3 ways to refer to the player. their steamid, slot number and userID.

thanks a lot for your help man. once again.. great mod.
__37__ 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 10:17.


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