Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » [Code] Getting a player's cPlayer Object?
[Code] Getting a player's cPlayer Object? [message #368266] Wed, 21 January 2009 11:29 Go to next message
Genesis2001
Messages: 1397
Registered: August 2006
Karma: 0
General (1 Star)
How do you fetch a player's cPlayer object inside a script?

Can you, for instance, take the following script and cast 'o' as a cPlayer*?

void A_Script::Created(GameObject *o)
{
   cPlayer *p = (cPlayer *)o;
}


Thanks in advance!
Re: [Code] Getting a player's cPlayer Object? [message #368267 is a reply to message #368266] Wed, 21 January 2009 11:37 Go to previous messageGo to next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)
inline cPlayer *GetPlayercPlayer(int ID)
{
	for(GenericSLNode *x = PlayerList->HeadNode; x != 0; x = x->NodeNext)
	{
		cPlayer *p = (cPlayer *)x->NodeData;
		if(p && p->IsActive && ID == p->PlayerId)
		{
			return p;
                }
        }
	return 0;
}
Re: [Code] Getting a player's cPlayer Object? [message #368268 is a reply to message #368267] Wed, 21 January 2009 11:40 Go to previous message
Genesis2001
Messages: 1397
Registered: August 2006
Karma: 0
General (1 Star)
RoShamBo wrote on Wed, 21 January 2009 11:37

inline cPlayer *GetPlayercPlayer(int ID)
{
	for(GenericSLNode *x = PlayerList->HeadNode; x != 0; x = x->NodeNext)
	{
		cPlayer *p = (cPlayer *)x->NodeData;
		if(p && p->IsActive && ID == p->PlayerId)
		{
			return p;
                }
        }
	return 0;
}




nice and thanks again! Very Happy
Previous Topic: Big Gun Destruction Animation
Next Topic: ServerSide Temps
Goto Forum:
  


Current Time: Thu Dec 19 10:54:08 MST 2024

Total time taken to generate the page: 0.01157 seconds