Graal Forums

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

tlf288 07-14-2003 07:58 PM

showimg error?
 
NPC Code:

function InitializeImageArrays()
{
this.imageCount = 3; // Change this accordingly
setarray this.imageShow, this.imageCount; // 1 = auto show, 0 = no auto show
setarray this.imageIndex, this.imageCount;
setarray this.imagePosX, this.imageCount;
setarray this.imagePosY, this.imageCount;
setarray this.imageStartX, this.imageCount;
setarray this.imageStaryY, this.imageCount;
setarray this.imageWidth, this.imageCount;
setarray this.imageHeight, this.imageCount;
setarray this.imageLayer, this.imageCount;

// The main image
this.imageShow[0] = 1;
this.imageIndex[0] = 1;
this.imagePosX[0] = 0;
this.imagePosY[0] = screenheight - 118;
this.imageStartX[0] = 0;
this.imageStartY[0] = 71;
this.imageWidth[0] = 487;
this.imageHeight[0] = 118;
this.imageLayer[0] = 5;

// The HP bar
this.imageShow[1] = 1;
this.imageIndex[1] = 2;
this.imagePosX[1] = 15;
this.imagePosY[1] = screenheight - 72;
this.imageStartX[1] = 10;
this.imageStartY[1] = 29;
this.imageWidth[1] = 5;
this.imageHeight[1] = 27;
this.imageLayer[1] = 4;
}

function ShowImages()
{
for ( i = 0; i != this.imageCount; i++ )
{
if (this.imageShow[i] == 1)
{
showimg this.imageIndex[i], gui1.gif, this.imagePosX[i], this.imagePosY[i];
changeimgpart this.imageIndex[i], this.imageStartX[i], this.imageStartY[i], this.imageWidth[i], this.imageHeight[i];
changeimgvis this.imageIndex[i], this.imageLayer[i];
}
}
}



Does anyone know why this wont work? Both of there function are called when the npc gets created. The InitializeImageArrays function is called first. Then the ShowImages function.

I I set the imageCount to 1 then it doesnt cause an error, but then that defeats the whole purpose of what I am trying to do.

If it is an error in my script I just can't see what it is. What I believe is it is an error with the showimg command placed in a 'for loop'. I am just not sure so if anyone who knows what the problem is would post an answer I would greatly appreciate it.

Tseng 07-14-2003 08:16 PM

array elements aren't called using arrayname[elementnumber]

#I(arrayname,elementnumber)

(wrong language :D)

Falados 07-14-2003 08:52 PM

Quote:

Originally posted by Tseng
array elements aren't called using arrayname[elementnumber]

#I(arrayname,elementnumber)

(wrong language :D)

But these are REAL arrays, not string arrays.


Try a timeout loop.

and intalize the arrays when created & playerenters

thats all I can come up with at a glance. (you could also try using indicies of 200 or greater instead of 1 and 2, I duno if that would help, but it makes it clientside instead of showing it for all players)

tlf288 07-14-2003 11:22 PM

Quote:

Originally posted by Tseng

array elements aren't called using arrayname[elementnumber]

#I(arrayname,elementnumber)

(wrong language )

Silly Tseng, I am using "setarray" not string arrays :D .

Quote:

Originally posted by Falados

But these are REAL arrays, not string arrays.


Try a timeout loop.

and intalize the arrays when created & playerenters

thats all I can come up with at a glance. (you could also try using indicies of 200 or greater instead of 1 and 2, I duno if that would help, but it makes it clientside instead of showing it for all players)

I'll try that out and report back.

I didn't know indicies of 1 and 2 were clientside >.< .

Tseng 07-14-2003 11:52 PM

Note to self: Don't post in the NPC Scripting forum 10 minutes after I wake up, my brain isn't awake yet. :D

(Wow, do I feel stupid.)

tlf288 07-15-2003 12:15 AM

Quote:

Originally posted by Tseng
Note to self: Don't post in the NPC Scripting forum 10 minutes after I wake up, my brain isn't awake yet. :D
You sure sleep late :eek: .


Quote:


(Wow, do I feel stupid.)

You should :grin: .

Tseng 07-15-2003 02:47 AM

Quote:

Originally posted by tlf288


You sure sleep late :eek: .


10 AM, pacific standard time, is late?

tlf288 07-15-2003 03:08 AM

No.... I sometimes don't take account for timezones.

Kaimetsu 07-15-2003 06:16 AM

Boil the problem down to the necessities if you want somebody to look at it.

tlf288 07-15-2003 07:00 AM

I did. Those are the two functions I came down to. Then I removed all other set of arrays in the InitializeImageArrays besides two because it will work with one set, but starts to have problems with more than one.

Kaimetsu 07-15-2003 07:13 AM

Quote:

Originally posted by tlf288
I did. Those are the two functions I came down to. Then I removed all other set of arrays in the InitializeImageArrays besides two because it will work with one set, but starts to have problems with more than one.
And you really think all those fields are necessary? ImageLayer? ImageStartX? You should delete everything you can remove without stopping the error from occuring and, when the removal of an element does negate the error, it's a big clue as to what is wrong.

Also: 'It doesn't work' is not an error. Tell us what it does, what it doesn't do, what it's supposed to do.


All times are GMT +2. The time now is 04:31 PM.

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