Thread: playerindex
View Single Post
  #2  
Old 05-27-2002, 04:04 AM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
Re: playerindex

Quote:
Originally posted by BBflat
Gah, help, I can't get the index of other players! testplayer(x,y) works great to get MY index which will always be 0, but it doesn't get anybody else's index. What do I need to do to get somebody else's index?? Sorry about all these questions lately.
The way I like to do it is like this:
NPC Code:

if (playerchats && startswith(/get , #c)) {
this.player = -1;
for ( i=0; i<playerscount; i++ ) {
if (strequals(#a(i), #e(5,-1,#c))) {this.player = i; i=playerscount;}
}
if (this.player == -1)
setplayerprop #c, the player is not on the level;
else
setplayerprop #c, the player's index if #v(this.player);
}



The way this works is the player says: "/get <account>" and if the player is on the level it returns their index. There are many ways to get indexes though, like useing mouse vars you can use an in with a for loop...
__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it
Reply With Quote