AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   Learning some coding: what does this line of code do? (https://forums.alliedmods.net/showthread.php?t=37937)

__37__ 05-15-2005 20:02

Learning some coding: what does this line of code do?
 
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.

BeetleFart 05-15-2005 20:08

Re: Learning some coding: what does this line of code do?
 
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

__37__ 05-15-2005 20:46

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.

BeetleFart 05-15-2005 21:12

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).

__37__ 05-15-2005 21:24

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.


All times are GMT -4. The time now is 11:58.

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