Jump to content
  • 0
Brynner

what's wrong with this script?

Question

anthell01,35,267,0	script	ant001	45,1,1, {	if(anthell==1) goto moc15;	moc04:	warp "moc_fild04",213,327; break;	moc15:	warp "moc_fild15",251,248; break;}anthell02,171,169,0	script	ant001	45,1,2, {	if(anthell==0) goto moc15;	moc04:	warp "moc_fild04",213,327; break;	moc15:	warp "moc_fild15",251,248; break;}

thank you in advance.

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

[Error]: npc_parse_script: Missing left curly ',{' in file '(DIRECT INPUT)', line '1'. Skipping the rest of the file.* w1=anthell01,35,267,0* w2=script* w3=ant001* w4=45,1,1, { 


You shouldn't put a space between the last comma and the opening curly, should leave it just as specified in the error message: ",{"

 

Edit:

 

PS: And break is illegally used within these scripts: you can only "break" from loops (for, while, do ... while) or switch statements.

 

PPS: You should always avoid the usage of goto commands (you should remember that goto is evil). It'd be better to use an if... else... structure in that case.

 

PPPS: in case the condition wasn't met, wou'd be warped twice (to the first place, then to the second place) because there wasn't an end to signal end of label execution. I suppose this is what you wanted with the break statement.

 

PPPPS: your NPC names are both the same. While they both will be loading, one of them will get renamed to a weird name you'll have a difficult time knowing in most cases.

 

Attaching fixed scripts:

 anthell01,35,267,0    script    ant001#01    45,1,1,{    if (anthell==1) {        warp "moc_fild15",251,248;    }    else {        warp "moc_fild04",213,327;    }    end;}anthell02,171,169,0    script    ant001#02    45,1,2,{    if (anthell==0) {        warp "moc_fild15",251,248;    }    else {        warp "moc_fild04",213,327;    }    end;}

 

PS after fixed scripts: spacing after the ifs and before the curlies isn't needed but I usually do it for clarity's sake

PPS after fixed scripts: You can omit the curlies after the if in case you're using onle one sentence like in this case, but I've been strict this time since you're learning.

Share this post


Link to post
Share on other sites
  • 0

I've just edited my last post to add some insights that made your NPCs not function properly. Please recheck.
 
I've deleted my last answer and replied again because I forgot to make the names of the NPCs to be different. If you check yet once again, this issue will be solved. Sorry for the inconvenience, just ensuring you will have your NPCs will act nice on your server :swt3:

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.