Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-30-2003, 11:31 PM
Mal1core Mal1core is offline
Registered User
Join Date: Jul 2003
Location: Rochester, New York
Posts: 41
Mal1core is on a distinguished road
Send a message via AIM to Mal1core Send a message via Yahoo to Mal1core
Plz explain index

im wondering if someone can explain how to use index to identify 1 player from anotehr in a level. thanks.
__________________
Im still searching...
Reply With Quote
  #2  
Old 08-31-2003, 12:04 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
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.
__________________


Help me keep scripting
Reply With Quote
  #3  
Old 08-31-2003, 12:38 AM
Mal1core Mal1core is offline
Registered User
Join Date: Jul 2003
Location: Rochester, New York
Posts: 41
Mal1core is on a distinguished road
Send a message via AIM to Mal1core Send a message via Yahoo to 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
__________________
Im still searching...
Reply With Quote
  #4  
Old 08-31-2003, 01:40 AM
protagonist protagonist is offline
Banned
protagonist's Avatar
Join Date: May 2003
Location: CAW
Posts: 5,586
protagonist is on a distinguished road
Send a message via AIM to protagonist Send a message via MSN to protagonist
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;
}
Reply With Quote
  #5  
Old 08-31-2003, 01:41 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
NPC Code:

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

__________________


Help me keep scripting
Reply With Quote
  #6  
Old 08-31-2003, 01:57 AM
protagonist protagonist is offline
Banned
protagonist's Avatar
Join Date: May 2003
Location: CAW
Posts: 5,586
protagonist is on a distinguished road
Send a message via AIM to protagonist Send a message via MSN to protagonist
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.
Reply With Quote
  #7  
Old 08-31-2003, 02:13 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Quote:
Originally posted by protagonist



ID and Index are two very different things.
ditto
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #8  
Old 08-31-2003, 02:21 AM
Mal1core Mal1core is offline
Registered User
Join Date: Jul 2003
Location: Rochester, New York
Posts: 41
Mal1core is on a distinguished road
Send a message via AIM to Mal1core Send a message via Yahoo to Mal1core
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.
__________________
Im still searching...
Reply With Quote
  #9  
Old 08-31-2003, 02:40 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to 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.
__________________


Help me keep scripting
Reply With Quote
  #10  
Old 08-31-2003, 03:24 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
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
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #11  
Old 08-31-2003, 03:25 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
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.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #12  
Old 08-31-2003, 03:37 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Hence my confusion. Same purpose, different lifespans.
__________________


Help me keep scripting
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:00 AM.


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