Author Topic: Syntax Error  (Read 891 times)

0 Members and 1 Guest are viewing this topic.

Offline Bellamy

  • Major(1)
  • Posts: 42
Syntax Error
« on: March 29, 2009, 07:23:22 pm »
I'm currently creating a script that includes a loop and some other stuff. When I ran the server, it said there was a syntax error: 'then' expected. The line it referred to was the 28th line. In this case it is the middle line that starts with 'if'.

Here's the part of my script it's talking about:

Code: [Select]
for i := 1 to 14 do begin
if i != OneWep then SetWeaponActive(0,i,false) else
SetWeaponActive(0,i,true);

Could anyone explain to me why it expected 'then' if there is already 'then' on that line?

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Syntax Error
« Reply #1 on: March 29, 2009, 07:47:11 pm »
It is probably the !=. Try <> instead.


Offline Bellamy

  • Major(1)
  • Posts: 42
Re: Syntax Error
« Reply #2 on: March 29, 2009, 08:11:46 pm »
It worked! Thanks.

Now it says there's a type mismatch on the second line.

Code: [Select]
begin
inc(OneWep,1);
if OneWep = 15 then OnWep := 1;
SetWeaponActive(OldWep,false);

Could you explain what that means?

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Syntax Error
« Reply #3 on: March 29, 2009, 10:38:42 pm »
Are oldwep and onewep a integers? Also u have
Code: [Select]
if OneWep = 15 then OnWep := 1should it be
Code: [Select]
if OneWep = 15 then OneWep := 1   //with the e in Onewep := 1


Offline Bellamy

  • Major(1)
  • Posts: 42
Re: Syntax Error
« Reply #4 on: March 29, 2009, 10:55:38 pm »
Good call. And yes, I made them variables (bytes/integers) earlier in the script.

I also need to know why it says 'type mismatch' for the 'inc' line.
« Last Edit: March 29, 2009, 11:31:04 pm by Bellamy »

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Syntax Error
« Reply #5 on: March 30, 2009, 08:28:45 pm »
Inc does not work with the type byte, afaik know integers but i havn't tested all n' all it works with and doesn't.

Offline Bellamy

  • Major(1)
  • Posts: 42
Re: Syntax Error
« Reply #6 on: March 30, 2009, 09:17:12 pm »
So you're saying I should use the integer type for the variable instead of byte, right?

Edit: I just tried using both integer and byte as the type and neither worked.
Edit2: Btw, I realized it might help a little if I gave you what the exact error was.
"[Error] (33:16): Type mismatch"
« Last Edit: March 30, 2009, 09:28:16 pm by Bellamy »

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Syntax Error
« Reply #7 on: March 31, 2009, 11:28:11 am »
So you're saying I should use the integer type for the variable instead of byte, right?
actually I'm saying you should do myVar := myVar + 1; but it really doesn't matter that much

Just by looking at what you got there, I'm not sure whats wrong. Make sure your showing us the correct code (if multiple files, make sure you take that into account)

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Syntax Error
« Reply #8 on: March 31, 2009, 11:32:58 am »
http://enesce.com/help/html/Functions/SetWeaponActive.html

apart from feeding it an invalid number of arguments, your second argument is of invalid type :G

should be SetWeaponActive(0,OldWep,false); i guess


Edit: you might also have a typo: if OneWep = 15 then OneWep := 1; ?..
« Last Edit: March 31, 2009, 11:35:06 am by danmer »

Offline Bellamy

  • Major(1)
  • Posts: 42
Re: Syntax Error
« Reply #9 on: March 31, 2009, 04:08:09 pm »
I fixed the typo. And the SetWeaponActive thing, that's a good call, I don't know why I didn't put in the ID parameter, but I'll fix it and see if it works.

EDIT: Wow, that little 0 that I was too lazy to insert in earlier made it work! (that line at least)
There are more errors I might need help with.
« Last Edit: March 31, 2009, 05:57:54 pm by Bellamy »