Script not working

Started by mport2004, Mon 10/10/2005 23:43:17

Previous topic - Next topic

mport2004

In my game i have a gard tower that shoots your guys when they get near it.
I have this script for when you attack it.


if (GetGlobalInt(14) == 1) {
character[BB].Animate(4, 1, 0, eBlock, eForwards);
int ran=Random(3);
if (ran==0) character[GT].Animate(1, 1, 0, eBlock, eForwards);SetGlobalInt(2,1);
if (ran==1) character[GT].Say("1");
if (ran==2) character[GT].Say("2");
if (ran==3) character[GT].Say("3");
}

when my guys attack it even if it dosent get a 0 for the random # it still uses SetGlobalInt(2,1);Ã,  ???

strazer

Quote from: mport2004 on Mon 10/10/2005 23:43:17
if (ran==0) character[GT].Animate(1, 1, 0, eBlock, eForwards);SetGlobalInt(2,1);

You have to enclose multiple commands within brackets, otherwise the conditional only works on the first command. Your code is the same as
Code: ags

if (ran==0) character[GT].Animate(1, 1, 0, eBlock, eForwards);
SetGlobalInt(2,1);


Try this instead:

Code: ags

if (ran==0) {
  character[GT].Animate(1, 1, 0, eBlock, eForwards);
  SetGlobalInt(2,1);
}


monkey0506

And just to clarify, you can use cGt in place of character[GT], in case you didn't know. ;)

SMF spam blocked by CleanTalk