Author Topic: Identifier expected. - :S - Help [Solved]  (Read 709 times)

0 Members and 3 Guests are viewing this topic.

Offline utkesmer

  • Major(1)
  • Posts: 44
Identifier expected. - :S - Help [Solved]
« on: July 01, 2009, 05:05:18 am »
-----

Here is my script.

--- SCRIPT.pas ---

Code: [Select]
var
AS: boolean;

function OnRequestGame(IP: string; State: integer): integer;
begin
  Result := State;
  {
  IMPORTANT NOTE:
    If you modify Result, please take into consideration that the user
    may also be using another script which also modified the result...
    To avoid conflictions, PLEASE perform logical checks...
  }

 if State = 3 then WriteConsole(0, 'BLABLABLABLABLABLABLABLA', RGB(255,130,0) );
 if State = 4 then WriteConsole(0, 'BLABLABLABLABLABLABLABLA', RGB(255,10,10) );
 if State = 5 then WriteConsole(0, 'BLABLABLABLABLABLABLABLA', RGB(0,130,255) );

end;

procedure OnJoinGame(ID, Team: byte);
begin

 if AS = true then begin
   Command('/setteam5 ' +INTTOSTR(ID) );
   WriteConsole(ID, 'Auto Spectator is on.', RGB(255,0,0) );
 end;

end;

procedure OnPlayerSpeak(ID: byte; Text: string);
begin

 if MaskCheck(Text, '!komut*') then begin
   WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
 end;

 if MaskCheck(Text, '!command*') then begin
   WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
 end;

 if MaskCheck(Text, '!kural*') then begin
   WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
 end;

 if MaskCheck(Text, '!rule*') then begin
   WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
 end;

 if MaskCheck(Text, '!alpha*') or MaskCheck(Text, '!red*') or MaskCheck(Text, '!1*') then Command('/setteam1 '+INTTOSTR(ID) );

 if MaskCheck(Text, '!bravo*') or MaskCheck(Text, '!blue*') or MaskCheck(Text, '!2*') then Command('/setteam2 '+INTTOSTR(ID) );

 if MaskCheck(Text, '!spec*') or MaskCheck(Text, '!5') then Command('/setteam5 '+INTTOSTR(ID) );

 if MaskCheck(Text, '!r*') then Command('/restart');

 if MaskCheck(Text, '!p*') then Command('/pause');

 if MaskCheck(Text, '!up*') or  if MaskCheck(Text, '!unpause*') then Command('/unpause');

 if MaskCheck(Text, '!ub*') or MaskCheck(Text, '!unb*') then Command('/unbanlast');

 if MaskCheck(Text, '!autos1*') then begin
   AS := true;
   WriteConsole(0, 'Auto Spectator Script is on!', RGB(0,255,0) );
 end;

 if MaskCheck(Text, '!autos0*') then begin
   AS := false;
   WriteConsole(0, 'Auto Spectator Script is off!', RGB(255,0,0) );
 end;

end;

I can't see any problem but it doesn't work. Server shutting down.

--- Log ---

Code: [Select]
09-07-01 12:39:19    Console Log Started
09-07-01 12:39:19 Welcome to Soldat 1.5.0
09-07-01 12:39:19  [*] ScriptCore v2.6 loaded! Found 2 scripts...
09-07-01 12:39:19  [*] Compiling default -> Core.pas...
09-07-01 12:39:19  [*] Compiling default -> NetworkCore.pas...
09-07-01 12:39:19  [*] Compiling default -> AdminCore.pas...
09-07-01 12:39:19  [*] Compiling Script -> SCRIPT.pas...
09-07-01 12:39:19  [*] Script -> [Error] (3:1): Identifier expected
09-07-01 12:39:19  [*] Compilation Failed.
09-07-01 12:39:19 Shutting down server...
09-07-01 12:39:19 Shutting down admin server...
09-07-01 12:39:19 Shutting down ScriptCore...

Help me please.

-----
« Last Edit: July 01, 2009, 08:04:32 am by utkesmer »

Offline JFK

  • Camper
  • ***
  • Posts: 255
    • My TraxInSpace Account
Re: Identifier expected. - :S - Help
« Reply #1 on: July 01, 2009, 05:36:34 am »
Not sure, but 'as' seems to be a delphi command. Try a different variable name.

http://www.delphibasics.co.uk/RTL.asp?Name=As
Come join: EliteCTF
Listen to: My Music

Offline utkesmer

  • Major(1)
  • Posts: 44
Re: Identifier expected. - :S - Help
« Reply #2 on: July 01, 2009, 08:00:06 am »
Not sure, but 'as' seems to be a delphi command. Try a different variable name.

http://www.delphibasics.co.uk/RTL.asp?Name=As

Thank you very much, I changed the variable name to "autospec".

--- Log ---

Code: [Select]
09-07-01 15:44:51    Console Log Started
09-07-01 15:44:52 Welcome to Soldat 1.5.0
09-07-01 15:44:52  [*] ScriptCore v2.6 loaded! Found 2 scripts...
09-07-01 15:44:52  [*] Compiling default -> Core.pas...
09-07-01 15:44:52  [*] Compiling default -> NetworkCore.pas...
09-07-01 15:44:52  [*] Compiling default -> AdminCore.pas...
09-07-01 15:44:52  [*] Compiling Script -> SCRIPT.pas...
09-07-01 15:44:52  [*] Script -> [Error] (87:33): Syntax error
09-07-01 15:44:52  [*] Compilation Failed.
09-07-01 15:44:52 Shutting down server...
09-07-01 15:44:52 Shutting down admin server...
09-07-01 15:44:52 Shutting down ScriptCore...

I found this syntax error too.

Now, there is no problem. =)

Here is the correct script.

Code: [Select]
var
autospec: boolean;

function OnRequestGame(IP: string; State: integer): integer;
begin
  Result := State;
  {
  IMPORTANT NOTE:
    If you modify Result, please take into consideration that the user
    may also be using another script which also modified the result...
    To avoid conflictions, PLEASE perform logical checks...
  }

 if State = 3 then WriteConsole(0, 'BLABLABLABLABLABLABLABLA', RGB(255,130,0) );
 if State = 4 then WriteConsole(0, 'BLABLABLABLABLABLABLABLA', RGB(255,10,10) );
 if State = 5 then WriteConsole(0, 'BLABLABLABLABLABLABLABLA', RGB(0,130,255) );

end;

procedure OnJoinGame(ID, Team: byte);
begin

 if autospec = true then begin
   Command('/setteam5 ' +INTTOSTR(ID) );
   WriteConsole(ID, 'Auto Spectator is on.', RGB(255,0,0) );
 end;

end;

procedure OnPlayerSpeak(ID: byte; Text: string);
begin

 if MaskCheck(Text, '!komut*') then begin
   WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
 end;

 if MaskCheck(Text, '!command*') then begin
   WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
 end;

 if MaskCheck(Text, '!kural*') then begin
   WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
 end;

 if MaskCheck(Text, '!rule*') then begin
   WriteConsole(ID, 'BLABLABLABLABLABLABLABLA', RGB(56,176,222) );
 end;

 if MaskCheck(Text, '!alpha*') or MaskCheck(Text, '!red*') or MaskCheck(Text, '!1*') then Command('/setteam1 '+INTTOSTR(ID) );

 if MaskCheck(Text, '!bravo*') or MaskCheck(Text, '!blue*') or MaskCheck(Text, '!2*') then Command('/setteam2 '+INTTOSTR(ID) );

 if MaskCheck(Text, '!spec*') or MaskCheck(Text, '!5') then Command('/setteam5 '+INTTOSTR(ID) );

 if MaskCheck(Text, '!r*') then Command('/restart');

 if MaskCheck(Text, '!p*') then Command('/pause');

 if MaskCheck(Text, '!up*') or MaskCheck(Text, '!unpause*') then Command('/unpause');

 if MaskCheck(Text, '!ub*') or MaskCheck(Text, '!unb*') then Command('/unbanlast');

 if MaskCheck(Text, '!autos1*') then begin
   autospec := true;
   WriteConsole(0, 'Auto Spectator Script is on!', RGB(0,255,0) );
 end;

 if MaskCheck(Text, '!autos0*') then begin
   autospec := false;
   WriteConsole(0, 'Auto Spectator Script is off!', RGB(255,0,0) );
 end;

end;

Thank you again, JFK.