Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   playerindex (https://forums.graalonline.com/forums/showthread.php?t=30105)

BBflat 05-26-2002 04:46 PM

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

Saga2001 05-27-2002 04:04 AM

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


All times are GMT +2. The time now is 09:51 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.