04-24-2013, 04:56 PM
(04-23-2013, 06:48 PM)BeeKayK Wrote: [ -> ]This is my script.Spoiler below!
if(asTimer == "PlayerAh")
{
int AhVariable = RandInt(1, 2)
switch(AhVariable)
{
case 1:
PlaySoundAtEntity("Aaaah1", "player_react_guardian1.snt", "Player", 0, false);
AddTimer("PlayerAh", RandInt(10, 20), "Ambience");
break;
case 2:
PlaySoundAtEntity("Aaaah2", "player_react_guardian2.snt", "Player", 0, false);
AddTimer("PlayerAh", RandInt(10, 20), "Ambience");
break;
}
}
Why am i getting an error, that it expected a ; at the highlighted text?
Don't worry, this is not my whole script file. I know this single passage wouldn't work in any way. It's a part of a timer, as you see in the top of the script
JAP already solved the issue, but to explain the error a little....
It was saying there was an issue at the line directly below where the actual problem was.
Code:
int AhVariable = RandInt(1, 2)
The compiler reads this line, but because there is no ; at the end, it does not know where the line ends. As far as the compiler knows, the next line down is part of the same statement.
To the compiler it looks like this
Code:
int AhVariable = RandInt(1, 2) switch(AhVariable) {
The error is generated because it was expecting to the have the statement terminated by the ;
switch(int) { is not a valid part of a statement, so it throws the error on this line.
tl;dr - the line number given in the error message is approximate, with this particular error, it tends to be the line above
(04-24-2013, 04:50 PM)BeeKayK Wrote: [ -> ]I tried. Now just nothing happens
Can you post the whole function?