Author Topic: simple? script help, fail to compile  (Read 1683 times)

0 Members and 1 Guest are viewing this topic.

Offline a fool

  • Major
  • *
  • Posts: 98
  • Wait, what?
simple? script help, fail to compile
« on: July 02, 2008, 12:11:19 pm »
ok, this is my first script, I have read trough manual and such.
I think the problem is related to some misplacement of ";" or with the ends... I'm used to program in C and C++, this isn't the same xD
Code: [Select]
//SNIPER TRAINER script v1
//Made by [DOT] or on the forums.soldat.pl, a fool
Procedure OnPlayerCommand(ID: Byte; Text: string): boolean;
If RegExpMatch('/level \d+', Text) Then
Begin
lvlID := StrToInt(GetPiece(Text, ' ', 1));
if not lvlID then
WriteConsole(ID, 'You have not entered a valid number, type /help1 and /help2 for help', $FF7F7F7F)
else if lvlID = 1 then
begin
//nothing yet
end
else if lvlID = 2 then
begin
//nothing yet
end
else if lvlID = 3 then
begin
//nothing yet
end
end
else if RegExpMatch('/help1', Text) then
begin
WriteConsole(ID, 'Help----------------------------------------------------------', $FF7F7F7F);
WriteConsole(ID, 'type /level #, # being the number of the level of difficulty', $FF00FFFF);
WriteConsole(ID, 'Level index---------------------------------------------------', $FF7F7F7F);
WriteConsole(ID, 'Level 1: Simple map, non moving targets.', $FF0000FF);
WriteConsole(ID, 'Level 2: Simple map, moving targets.', $FF007FFF);
WriteConsole(ID, 'Level 3: More complex map, non moving targets.', $FF00FFFF);
WriteConsole(ID, 'Level 4: More complex map, moving targets.', $FF00FF7F);
WriteConsole(ID, 'Level 5: Rather complex map, non moving targets.', $FF00FF00);
WriteConsole(ID, 'Level 6: Rather complex map, moving targets.', $FF7FFF00);
WriteConsole(ID, 'Level 7: Special level, you cant move, but the targets either.', $FFFFFF00);
WriteConsole(ID, 'Level 8: Special level, you cant move, but the targets can.' $FFFF7F00);
WriteConsole(ID, 'Level 9: Special level, you just fall and the targets cant move.' $FFFF0000);
WriteConsole(ID, 'About---------------------------------------------------------', $FF7F7F7F);
WriteConsole(ID, 'Script \"SNIPER TRAINER\" created by [DOT], version 1', $FF7F7F7F);
WriteConsole(ID, 'Contact to Game_a_gogo@hotmail.com', $FF7F7F7F)
end;

so I ask you kindly, anyone can help me please? D:
Verily!

Offline rumpel

  • Camper
  • ***
  • Posts: 410
Re: simple? script help, fail to compile
« Reply #1 on: July 02, 2008, 12:15:09 pm »
you forgot many ;
banned.

Offline a fool

  • Major
  • *
  • Posts: 98
  • Wait, what?
Re: simple? script help, fail to compile
« Reply #2 on: July 02, 2008, 01:12:32 pm »
you forgot many ;
I bet... but I played a lot with those... all the process with begin, then end confuse me and I don't know where to place those semi colons

Date Posted: July 02, 2008, 02:43:11 pm
I have an idea, I will remove all those RegExpMatch... and replace them with simple if statements. going to do that soon

Date Posted: July 02, 2008, 02:53:32 pm
ok, so I worked on it a bit. here is what there, can anyone point out everything that I have to do...
Code: [Select]
//SNIPER TRAINER script v1
//Made by [DOT] or on the forums.soldat.pl, a fool
Procedure OnPlayerCommand(ID: Byte; Text: string): boolean;
case Text of
'/level 1': begin
//nothing yet
end;
'/level 2': begin
//nothing yet
end;
'/level 3': begin
//nothing yet
end;
'/level 4': begin
//nothing yet
end;
'/level 5': begin
//nothing yet
end;
'/level 6': begin
//nothing yet
end;
'/level 7': begin
//nothing yet
end;
'/level 8': begin
//nothing yet
end;
'/level 9': begin
//nothing yet
end;
otherwise   begin
//nothing yet
end;
end;
if Text = '/help1' then
begin
WriteConsole(ID, 'Help----------------------------------------------------------', $FF7F7F7F);
WriteConsole(ID, 'type /level #, # being the number of the level of difficulty', $FF00FFFF);
WriteConsole(ID, 'Level index---------------------------------------------------', $FF7F7F7F);
WriteConsole(ID, 'Level 1: Simple map, non moving targets.', $FF0000FF);
WriteConsole(ID, 'Level 2: Simple map, moving targets.', $FF007FFF);
WriteConsole(ID, 'Level 3: More complex map, non moving targets.', $FF00FFFF);
WriteConsole(ID, 'Level 4: More complex map, moving targets.', $FF00FF7F);
WriteConsole(ID, 'Level 5: Rather complex map, non moving targets.', $FF00FF00);
WriteConsole(ID, 'Level 6: Rather complex map, moving targets.', $FF7FFF00);
WriteConsole(ID, 'Level 7: Special level, you cant move, but the targets either.', $FFFFFF00);
WriteConsole(ID, 'Level 8: Special level, you cant move, but the targets can.' $FFFF7F00);
WriteConsole(ID, 'Level 9: Special level, you just fall and the targets cant move.' $FFFF0000);
WriteConsole(ID, 'About---------------------------------------------------------', $FF7F7F7F);
WriteConsole(ID, 'Script "SNIPER TRAINER" created by [DOT], version 1', $FF7F7F7F);
WriteConsole(ID, 'Contact to Game_a_gogo@hotmail.com', $FF7F7F7F);
end;
Verily!

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: simple? script help, fail to compile
« Reply #3 on: July 02, 2008, 02:42:23 pm »
you forgot many ;
Phail, he didn't

a fool, pascal manual is your help ^_^
KAWAAAAAAAIIIIIIIIII

Offline a fool

  • Major
  • *
  • Posts: 98
  • Wait, what?
Re: simple? script help, fail to compile
« Reply #4 on: July 02, 2008, 03:03:02 pm »
you forgot many ;
Phail, he didn't

a fool, pascal manual is your help ^_^
I have read manual as you say... I just don't know what is wrong. I guess I will read it once again.
In both if statements, there are errors, because I can remove one or the other, and it still fail D:
Verily!

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: simple? script help, fail to compile
« Reply #5 on: July 02, 2008, 04:09:15 pm »
and what is "otherwise" ?
KAWAAAAAAAIIIIIIIIII

Offline a fool

  • Major
  • *
  • Posts: 98
  • Wait, what?
Re: simple? script help, fail to compile
« Reply #6 on: July 02, 2008, 04:32:32 pm »
if none of the cases are true, this one will be used instead.

but ok. I fixed the first error, and what confused me the most was the second one...

these two lines:
Code: [Select]
WriteConsole(ID, 'Level 8: Special level, you cant move, but the targets can.' $FFFF7F00);
WriteConsole(ID, 'Level 9: Special level, you just fall and the targets cant move.' $FFFF0000);
was making the thing fail the compile... but what the heck, I rewritten the same thing and it worked O,,o
a mistery... but anyways, it works. here it is:

Code: [Select]
//SNIPER TRAINER script v1
//Made by [DOT] or on the forums.soldat.pl, a fool
function OnPlayerCommand(ID: byte; Text: string): boolean;
begin
begin
if Text = '/level 1' then begin
//nothing yet
end
else if Text = '/level 2' then begin
//nothing yet
end
else if Text = '/level 3' then begin
//nothing yet
end
else if Text = '/level 4' then begin
//nothing yet
end
else if Text = '/level 5' then begin
//nothing yet
end
else if Text = '/level 6' then begin
//nothing yet
end
else if Text = '/level 7' then begin
//nothing yet
end
else if Text = '/level 8' then begin
//nothing yet
end

else if Text = '/level 9' then begin
//nothing yet
end;
end;

if Text = '/help1' then
begin
WriteConsole(ID, 'Help----------------------------------------------------------', $FF7F7F7F);
WriteConsole(ID, 'type /level #, # being the number of the level of difficulty', $FF00FFFF);
WriteConsole(ID, 'Level index---------------------------------------------------', $FF7F7F7F);
WriteConsole(ID, 'Level 1: Simple map, non moving targets.', $FF0000FF);
WriteConsole(ID, 'Level 2: Simple map, moving targets.', $FF007FFF);
WriteConsole(ID, 'Level 3: More complex map, non moving targets.', $FF00FFFF);
WriteConsole(ID, 'Level 4: More complex map, moving targets.', $FF00FF7F);
WriteConsole(ID, 'Level 5: Rather complex map, non moving targets.', $FF00FF00);
WriteConsole(ID, 'Level 6: Rather complex map, moving targets.', $FF7FFF00);
WriteConsole(ID, 'Level 7: Special level, you cant move, but the targets either.', $FFFFFF00);
WriteConsole(ID, 'Level 8: Special level, you cant move, but the targets can.', $FFFF7F00);
WriteConsole(ID, 'Level 9: Special level, you just fall, but the targets cant move.', $FFFF0000);
WriteConsole(ID, 'About---------------------------------------------------------', $FF7F7F7F);
WriteConsole(ID, 'Script SNIPER TRAINER created by [DOT], version 1', $FF7F7F7F);
WriteConsole(ID, 'Contact to Game_a_gogo@hotmail.com', $FF7F7F7F);
end;
Result := false;
end;
« Last Edit: July 02, 2008, 04:37:23 pm by a fool »
Verily!

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: simple? script help, fail to compile
« Reply #7 on: July 02, 2008, 05:09:28 pm »
and what is "otherwise" ?
in pascal programming, its if none of the case statements are true; in soldat pascal, I beluive it is actualyl "else" so...
Code: [Select]
case 'test' of
  'one': WriteLn('1');
  'two': WriteLn('21');
  else begin
    WriteLn('0');
  end;
end;

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: simple? script help, fail to compile
« Reply #8 on: July 02, 2008, 05:47:00 pm »

was making the thing fail the compile... but what the heck, I rewritten the same thing and it worked O,,o
a mistery... but anyways, it works. here it is:



not a mystery, you forgot a ' , '
KAWAAAAAAAIIIIIIIIII

Offline a fool

  • Major
  • *
  • Posts: 98
  • Wait, what?
Re: simple? script help, fail to compile
« Reply #9 on: July 02, 2008, 06:09:56 pm »

was making the thing fail the compile... but what the heck, I rewritten the same thing and it worked O,,o
a mistery... but anyways, it works. here it is:



not a mystery, you forgot a ' , '

ha, wow O,,o
and I was looking if I missed anything of such as well -,,- dumb me lol. thank you anyway
Verily!

Offline shantec

  • Soldier
  • **
  • Posts: 140
  • Get ANGREH!!
Re: simple? script help, fail to compile
« Reply #10 on: July 03, 2008, 04:17:36 am »
a fool, i suggest you to use "case text of" instead of "if text =..."
like in your ... second(?) post :D
Also Known As REIMA


Lol Happles (happy apples)

Offline a fool

  • Major
  • *
  • Posts: 98
  • Wait, what?
Re: simple? script help, fail to compile
« Reply #11 on: July 03, 2008, 05:04:32 am »
I'm wide aware of that. but I though that was what was making it fail. on further scripts, I will use cases when needed.
Verily!