[Code] Getting a player's cPlayer Object? [message #368266] |
Wed, 21 January 2009 11:29 |
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 #368268 is a reply to message #368267] |
Wed, 21 January 2009 11:40 |
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!
|
|
|