Author Topic: Please help me!  (Read 1098 times)

0 Members and 1 Guest are viewing this topic.

Offline Dual-Core-Power

  • Major(1)
  • Posts: 3
Please help me!
« on: October 27, 2007, 07:33:05 pm »
Hey guys!

I have some problems with my own made script. Each time when I try to start my soldat server, the little start window opens and after one second it shuts down. Afterwards I checked the ConsoleLog and it told me that a Syntax error exist in line 56 and it complains about a comma which is expected in this line. I use the soldat server version 263 with windows vista 32-bit. I hope you can help me.

Here is my script:

Code: [Select]
procedure OnPlayerSpeak(ID: Byte; Text: string);

var
 var1,var2,var3:single;
 switch:string;

begin

case switch of

'!help':
begin
SayToPlayer (ID, 'Available commands:');
        SayToPlayer (ID, '!time');
        SayToPlayer (ID, '!stats');
end
'!time':
WriteConsole (0, 'Current Server time is '+FormatDate('hh:nn:ss am/pm'), $0000FF);
'!stats':
begin
if (GetPlayerStat(ID,'Deaths') > 0) then
begin
        SayToPlayer (ID, 'Score  : '+inttostr(GetPlayerStat(ID,'Kills')));
        SayToPlayer (ID, 'Deaths : '+inttostr(GetPlayerStat(ID,'Deaths')));
        var1 := GetPlayerStat (ID,'Kills');
        var2 := GetPlayerStat (ID,'Deaths');
        var3 := var1/var2;
        SayToPlayer (ID, 'Skill  : '+floattostr(var3));
end

else
begin
        SayToPlayer (ID, 'Score  : '+inttostr(GetPlayerStat(ID,'Kills')));
        SayToPlayer (ID, 'Deaths : '+inttostr(GetPlayerStat(ID,'Deaths')));
     SayToPlayer (ID, 'Skill  : '+inttostr(GetPlayerStat(ID,'Kills')));
end

end

else
begin
end

end;

end;
Thank you for suggestion!
« Last Edit: October 28, 2007, 02:43:33 am by chrisgbk »

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Please help me!
« Reply #1 on: October 28, 2007, 02:48:41 am »
Code: [Select]
SayToPlayer (ID, 'Skill  : '+inttostr(GetPlayerStat(ID,'Kills')));

Notice that square box? that isn't supposed to be there. Remove that and it will start fine.

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Please help me!
« Reply #2 on: October 28, 2007, 04:11:40 am »
Also, your doing "Case switch of".... Your Switch variable is nothing.....

Offline Dual-Core-Power

  • Major(1)
  • Posts: 3
Re: Please help me!
« Reply #3 on: October 28, 2007, 06:10:47 am »
Code: [Select]
SayToPlayer (ID, 'Skill  : '+inttostr(GetPlayerStat(ID,'Kills')));

Notice that square box? that isn't supposed to be there. Remove that and it will start fine.

Hey chrisbk thank you for suggestion. When I remove this line my script works, but not correct.
It does nothing when you type !help or !stats. I think this is what EnEsCe mean with:

Also, your doing "Case switch of".... Your Switch variable is nothing.....

Hey EnEsCe! First of all, thank you for your suggestion. I thought I can do it the same way how I do it in C++, but I think you're right.
I improved my code and I think this is what you mean:

var
var1,var2,var3:single;
switch:integer;

procedure OnPlayerSpeak(ID: Byte; Text: string);

begin

if (Text = '!help') then
begin
switch:= 1;
end

else if (Text = '!time') then
begin
switch:= 2;
end

else if (text = '!stats') then
begin
switch:= 3;
end

else
begin
end


case switch of

1:
   begin
   SayToPlayer (ID, 'Available commands:');
        SayToPlayer (ID, '!time');
        SayToPlayer (ID, '!stats');
   end
2:
   WriteConsole (0, 'Current Server time is '+FormatDate('hh:nn:ss am/pm'), $00CCFF);
3:
   begin
   if (GetPlayerStat(ID,'Deaths') > 0) then
   begin
        SayToPlayer (ID, 'Score  : '+inttostr(GetPlayerStat(ID,'Kills')));
        SayToPlayer (ID, 'Deaths : '+inttostr(GetPlayerStat(ID,'Deaths')));
        var1 := GetPlayerStat (ID,'Kills');
        var2 := GetPlayerStat (ID,'Deaths');
        var3 := var1/var2;
        SayToPlayer (ID, 'Skill  : '+floattostr(var3));
   end

   else
   begin
        SayToPlayer (ID, 'Score  : '+inttostr(GetPlayerStat(ID,'Kills')));
        SayToPlayer (ID, 'Deaths : '+inttostr(GetPlayerStat(ID,'Deaths')));
   end
   
   end

   else
   begin
   end

   end;

end;

If there is any mistake, please explain me.
« Last Edit: October 28, 2007, 08:14:55 am by Dual-Core-Power »

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1904
Re: Please help me!
« Reply #4 on: October 28, 2007, 06:14:34 am »
No, a bit like this.

Code: [Select]
procedure OnPlayerSpeak(ID: Byte; Text: string);
var
var1,var2,var3: single;
begin
case LowerCase(GetPiece(Text,' ',0)) of // The first word, in lower case.
'!help': begin
SayToPlayer(ID, 'Available commands:');
SayToPlayer(ID, '!time');
SayToPlayer(ID, '!stats');
end;
'!time':
WriteConsole(0,'Current Server time is '+FormatDate('hh:nn:ss am/pm'),$0000FF);
'!stats': begin
if GetPlayerStat(ID,'Deaths')>0 then begin
SayToPlayer(ID, 'Score  : '+inttostr(GetPlayerStat(ID,'Kills')));
SayToPlayer(ID, 'Deaths : '+inttostr(GetPlayerStat(ID,'Deaths')));
var1:=GetPlayerStat (ID,'Kills');
var2:=GetPlayerStat (ID,'Deaths');
var3:=var1/var2;
SayToPlayer(ID, 'Skill  : '+floattostr(var3));
end else begin
SayToPlayer(ID, 'Score  : '+inttostr(GetPlayerStat(ID,'Kills')));
SayToPlayer(ID, 'Deaths : '+inttostr(GetPlayerStat(ID,'Deaths')));
SayToPlayer(ID, 'Skill  : '+inttostr(GetPlayerStat(ID,'Kills')));
end;
end;

else begin
// Whatever purpose this serves.
end;
end;
end;
« Last Edit: October 28, 2007, 07:38:28 am by Toumaz »

Offline Dual-Core-Power

  • Major(1)
  • Posts: 3
Re: Please help me!
« Reply #5 on: October 28, 2007, 07:13:20 am »
Toumaz, your code works pretty awesome :D
Thank You!