![]() |
Plz explain index
im wondering if someone can explain how to use index to identify 1 player from anotehr in a level. thanks.
|
Every player gets a unique index upon entering a level. Graal is smart enough to be able to keep it ordered somehow (chronologically perhaps?). Clientside, 0 refers to whoever is currently using it. Serverside, I believe 0 refers to the last person to affect it, don't quote me on that. Other than that, everyone has a natural number index
Say you and I are in the same room. One of us would have index 1, the other would have index 2. |
hmmm.... i kinda get it but like a script example would be nice.. like if(player(1)){
//blah blah } cause im trying to let one person get another persons x,y coordinates... and i heard i had to use player[index]...thanks |
Index is a reference number given by Graal to help define different NPCs and characters. An example of getting the x coordinates of the players in a level is this:
for(i=0;i<playerscount;i++) { setarray thing,i; thing[i]=players[i].x; } |
NPC Code: |
Quote:
ID and Index are two very different things. |
Quote:
|
Quote:
|
Is it? I wonder what id is used for then. I've never used it, so I just assumed id was an unusual way to abbreviate, as graal is full of those. Interesting, I guess that means there is no way to figure out a player's index without a for loop then.
|
id is used to tell showcharacter npcs from players
the index is created and used by your client, so each player has their own set of indecies assigned to the other players in the level (allplayers indecies set apart from this, or do those even have indecies? I don't know much about server-side still) so your index is always one all you need to do is find the player you want with a for loop i.e. for (i=0;i<playerscount;i++) { if (flags_to_tell_if_this_is_the_right_player) { var = i; then use that index to get the others' coordinates with players[index].x players[index].y if you read this and still don't get it, my head will explode, cause anything more will be basically handing you a code |
Quote:
Index of the players in the level does change as players enter and exit I believe, it's basically the order they entered. |
Hence my confusion. Same purpose, different lifespans.
|
| All times are GMT +2. The time now is 12:45 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.