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