Graal Forums

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

Mal1core 08-30-2003 11:31 PM

Plz explain index
 
im wondering if someone can explain how to use index to identify 1 player from anotehr in a level. thanks.

TribulationStaff 08-31-2003 12:04 AM

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.

Mal1core 08-31-2003 12:38 AM

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

protagonist 08-31-2003 01:40 AM

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;
}

TribulationStaff 08-31-2003 01:41 AM

NPC Code:

if (playerenters)
{
setplayerprop #c,My ID is #v(playerid);
players[playerid].bombs=99;
}


protagonist 08-31-2003 01:57 AM

Quote:

Originally posted by TribulationStaff
NPC Code:

if (playerenters)
{
setplayerprop #c,My ID is #v(playerid);
players[playerid].bombs=99;
}



ID and Index are two very different things.

adam 08-31-2003 02:13 AM

Quote:

Originally posted by protagonist



ID and Index are two very different things.

ditto

Mal1core 08-31-2003 02:21 AM

Quote:

Originally posted by Mal1core
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

thank you this helps alot.

TribulationStaff 08-31-2003 02:40 AM

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.

Dach 08-31-2003 03:24 AM

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

adam 08-31-2003 03:25 AM

Quote:

Originally posted by TribulationStaff
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.
playerid is like index except for the entire server. and it never changes while the player is logged on.

Index of the players in the level does change as players enter and exit I believe, it's basically the order they entered.

TribulationStaff 08-31-2003 03:37 AM

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.