Graal Forums

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

joseyisleet 03-05-2002 06:30 AM

Arrays....
 
-=Josey=-
Ok, I know how to use arrays farely well, but, I've ran into a delima.
NPC Code:

if (playerenters){
this.arrayX={x+1,x+2,x+3,x+4,x+5};
this.arrayY={y+1,y+2,y+3,y+4,y+5};
timeout=.05;
}
if (timeout){
if (playerx in this.arrayX&&playery in this.arrayY){
message Testing...;
}
timeout=.05;
}


This doesn't seem to work right for me. Maybe I'm doing it wrong or maybe I done it right in this thread. I'm at work and yet to test it. Thanks for any help.

Phenom1K 03-05-2002 08:23 AM

Dunno, I've never used arrays, but I've seen a script like this that worked:

[code]
if (playerenters){
this.arrayX={x+1,x+2,x+3,x+4,x+5};
this.arrayY={y+1,y+2,y+3,y+4,y+5};
timeout=.05;
}
if (timeout){
if (playerx in |this.arrayX| && playery in |this.arrayY|){
message Testing...;
}
timeout=.05;
}

screen_name 03-05-2002 08:30 AM

NPC Code:

if ((playerx in this.arrayX) && (playery in this.arrayY)) {
message Testing...;
}



that should work, im new to the in thing to be honest

Saga2001 03-05-2002 09:53 AM

if (playerx in |this.arrayX| && playery in |this.arrayY|) {
message Testing...;
}
Thats right. ;)

Quote:

Originally posted by screen_name
that should work, im new to the in thing to be honest

I remember when i was new to in, I used to write things like this:
NPC Code:

if (playerx<45&&playerx>35&&playery<25&&playery>15) {
message testing;
}



:p

joseyisleet 03-05-2002 07:08 PM

-=Josey=-
Thanks everyone. I was just confused using the "in" command. ;D

Admins 03-05-2002 08:30 PM

I think all here were wrong :)

If you do playerx in this.arrayX then it checks if playerx
is in the array (the exact value of playerx, so its only
true if its equal to one of the 5 entries of the array).
To check for a range do
playerx in |x+1,x+5|

screen_name 03-05-2002 09:13 PM

Quote:

Originally posted by Stefan
I think all here were wrong :)

If you do playerx in this.arrayX then it checks if playerx
is in the array (the exact value of playerx, so its only
true if its equal to one of the 5 entries of the array).
To check for a range do
playerx in |x+1,x+5|

yeah, thats right, becuase most of the time playerx's and playery's have a lot of extra decimal numbers

Saga2001 03-05-2002 11:11 PM

Quote:

Originally posted by Kaimetsu


Not a command!

Yeah, a condition, I think its a common scripter habbit to call everything a command...

Quote:

Originally posted by Stefan
I think all here were wrong :)

If you do playerx in this.arrayX then it checks if playerx
is in the array (the exact value of playerx, so its only
true if its equal to one of the 5 entries of the array).
To check for a range do
playerx in |x+1,x+5|

you could also do:
NPC Code:

int(playerx) in |this.arrayX|


right?


All times are GMT +2. The time now is 01:03 AM.

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