Author Topic: Soldat server "syntax error"  (Read 1677 times)

0 Members and 1 Guest are viewing this topic.

Offline rafineria888

  • Major(1)
  • Posts: 10
Soldat server "syntax error"
« on: February 09, 2016, 09:02:07 am »
Hi.
I've got a problem with soldatserver.exe.
Error:
Quote
Compiling script -> script.pas...
script -> [Error] (1:1): Syntax error
Disabling script
Done

Code:
Quote
program test;
begin
if Text = '/test' then begin
DoDamage(1,4000);
end.
Thanks for help..

Offline Akinaro

  • Flagrunner
  • ****
  • Posts: 749
Re: Soldat server "syntax error"
« Reply #1 on: February 09, 2016, 09:38:54 am »
All functions and procedures you can find at: http://wiki.soldat.pl/index.php/Main_Page

Basic info: http://wiki.soldat.pl/index.php/Scripting_basics

Error show because of few bugs,there is no function/procedure like "program test"
Also add at the end ; not .


It should be something like that(I forgot most of scripts stuff :/ )
Code: [Select]
function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
 if (Text = '/test') then
  begin
   DoDamage(1,4000); //where 1 is player with ID 1
  end;
end;


Offline rafineria888

  • Major(1)
  • Posts: 10
Re: Soldat server "syntax error"
« Reply #2 on: February 09, 2016, 09:55:38 am »
Still the same error.
Simple code like:
Quote
begin

end;
returns the same error. Should be compiled and run as empty script...

Offline Akinaro

  • Flagrunner
  • ****
  • Posts: 749
Re: Soldat server "syntax error"
« Reply #3 on: February 09, 2016, 10:01:41 am »
heh, no it doesnt work like that.

Read all  here:
http://wiki.soldat.pl/index.php/Scripting_basics

Download some scripts to see how they are written.
Then make some basic scripts using functions/procedures from here: http://wiki.soldat.pl/index.php/Server_Scripting

Offline rafineria888

  • Major(1)
  • Posts: 10
Re: Soldat server "syntax error"
« Reply #4 on: February 09, 2016, 10:53:53 am »
I cannot find any script on this forum  :|
Anyway it doesn't work for me:
Quote
const
   somesconst = 1;
var
   somevar: string;
   
function OnPlayerCommand(ID: Byte; text: String): boolean;
begin
   if (text = '/test') then
   begin
      if (ID = 1) then
      begin
         WriteLn('Test successful!');
      end;
   end;
end;
same error

Offline Furai

  • Administrator
  • Veteran
  • *****
  • Posts: 1908
    • TransHuman Design
Re: Soldat server "syntax error"
« Reply #5 on: February 09, 2016, 11:43:39 am »
Can you hop on IRC? (#soldat or #soldat.devs @ QuakeNet) I could try helping you there directly.

Some questions - do you have scripting enabled in soldat.ini (I guess you have because it's trying to compile but you'll never know with soldat for sure)
Do you have any other scripts? Dose the error always indicate the first line?
"My senses are so powerful that I can hear the blood pumping through your veins."

Offline rafineria888

  • Major(1)
  • Posts: 10
Re: Soldat server "syntax error"
« Reply #6 on: February 09, 2016, 12:49:52 pm »
Problem solved.
Encoding... 8)

Offline Furai

  • Administrator
  • Veteran
  • *****
  • Posts: 1908
    • TransHuman Design
Re: Soldat server "syntax error"
« Reply #7 on: February 09, 2016, 01:00:27 pm »
Yeah, after long debugging session on IRC it turned out that it was problem with file encoding. His script.pas was saved as unicode with BOM.

So for future reference - save your files either in ASCII format or in UTF8 without BOM.

Thanks to Falcon and urraka for helping as well.
"My senses are so powerful that I can hear the blood pumping through your veins."