Author Topic: {Solved} Invalid number of parameters?  (Read 1582 times)

0 Members and 1 Guest are viewing this topic.

Offline Norbo

  • Camper
  • ***
  • Posts: 338
{Solved} Invalid number of parameters?
« on: November 13, 2008, 02:48:55 pm »
Come again?

Code: [Select]
Const
SPACES = '      '; //spaces before and after the value
COMMAND = '/showinfo'; //the command for showing the server info
SPAMTIME = 5; //how many minutes a player has to wait to show server info
COLOR = $FFFFFFFF; //the color of the messages

Var
SpamTimer: array[1..32] of integer;
CanShowInfo : array[1..32] of boolean;

procedure ShowInfo(ID: byte);
begin
WriteConsole(ID,'Server Name:'+SPACES+ReadINI('soldat.ini','NETWORK','Server_Name','*ERROR*')+SPACES,COLOR);
Case ReadINI('soldat.ini','GAME','Gamestyle','*ERROR*') of
'0': begin
WriteConsole(ID,'GameMode:'+SPACES+'DeathMatch'+SPACES,COLOR);
WriteConsole(ID,'Score Limit:'+SPACES+ReadINI('soldat.ini','GAME','Deathmatch_Limit','*ERROR*')+SPACES,COLOR);
end
'1': begin
WriteConsole(ID,'GameMode:'+SPACES+'PointMatch'+SPACES,COLOR);
WriteConsole(ID,'Score Limit:'+SPACES+ReadINI('soldat.ini','GAME','Pointmatch_Limit','*ERROR*')+SPACES,COLOR);
end
'2': begin
WriteConsole(ID,'GameMode:'+SPACES+'TeamMatch'+SPACES,COLOR);
WriteConsole(ID,'Score Limit:'+SPACES+ReadINI('soldat.ini','GAME','Teammatch_Limit','*ERROR*')+SPACES,COLOR);
end
'3': begin
WriteConsole(ID,'GameMode:'+SPACES+'Capture The Flag'+SPACES,COLOR);
WriteConsole(ID,'Score Limit:'+SPACES+ReadINI('soldat.ini','GAME','Capture_Limit','*ERROR*')+SPACES,COLOR);
end
'4': begin
WriteConsole(ID,'GameMode:'+SPACES+'RamboMatch'+SPACES,COLOR);
WriteConsole(ID,'Score Limit:'+SPACES+ReadINI('soldat.ini','GAME','Rambomatch_Limit','*ERROR*')+SPACES,COLOR);
end
'5': begin
WriteConsole(ID,'GameMode:'+SPACES+'Infiltration'+SPACES,COLOR);
WriteConsole(ID,'Score Limit:'+SPACES+ReadINI('soldat.ini','GAME','Infiltration_Limit','*ERROR*')+SPACES,COLOR);
end
'6': begin
WriteConsole(ID,'GameMode:'+SPACES+'Hold The Flag'+SPACES,COLOR);
WriteConsole(ID,'Score Limit:'+SPACES+ReadINI('soldat.ini','GAME','Hold_Limit','*ERROR*')+SPACES,COLOR);
end
end
WriteConsole(ID,'Time Limit:'+SPACES+ReadINI('soldat.ini','GAME','Time_Limit','*ERROR*')+SPACES,COLOR);
WriteConsole(ID,'Max Players:'+SPACES+ReadINI('soldat.ini','GAME','Max_Players','*ERROR*')+SPACES,COLOR);
WriteConsole(ID,'Max Spectators:'+SPACES+ReadINI('soldat.ini','NETWORK','Max_Spectators','*ERROR*')+SPACES,COLOR);
WriteConsole(ID,'Respawn Time:'+SPACES+ReadINI('soldat.ini','GAME','Respawn_Time','*ERROR*')+SPACES,COLOR);
WriteConsole(ID,'Wave Respawn Time:'+SPACES+ReadINI('soldat.ini','GAME','WaveRespawn_Time','*ERROR*')+SPACES,COLOR);
Case ReadINI('soldat.ini','GAME','Realistic_Mode','*ERROR*') of
'0': WriteConsole(ID,'Realistic: No'+SPACES,COLOR);
'1': WriteConsole(ID,'Realistic: Yes'+SPACES,COLOR);
end
Case ReadINI('soldat.ini','GAME','Survival_Mode','*ERROR*') of
'0': WriteConsole(ID,'Survival: No'+SPACES,COLOR);
'1': WriteConsole(ID,'Survival: Yes'+SPACES,COLOR);
end
Case ReadINI('soldat.ini','GAME','Weapons_Mode','*ERROR*') of
'0': WriteConsole(ID,'Advanced: No'+SPACES,COLOR);
'1': WriteConsole(ID,'Advanced: Yes'+SPACES,COLOR);
end
WriteConsole(ID,'Bonus Frequency:'+SPACES+ReadINI('soldat.ini','GAME','Bonus_Frequency','*ERROR*')+SPACES,COLOR);
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
i: integer;
begin
if (Text = COMMAND) then begin
if (SpamTimer[ID] > 0) and (CanShowInfo[ID] = true) then begin
ShowInfo(ID);
i := SPAMTIME*60;
SpamTimer[ID] := i;
end
else WriteConsole(ID,'Please wait '+SPAMTIME+' minutes between showing the server info',COLOR);
end
end;

procedure AppOnIdle(Ticks: integer);
var
i: integer;
begin
for i := 1 to 32 do begin
if (SpamTimer[i] > 0) and (CanShowInfo[i] = false) then SpamTimer[i] := SpamTimer[i]-1;
if SpamTimer[i] = 0 then CanShowInfo[i] := true;
end
end;

procedure ActivateServer();
var
i: integer;
begin
for i := 1 to 32 do begin
SpamTimer[i] := 0;
CanShowInfo[i] := true;
end
end;

the error is someware in the on player command part, i just dont know what the hell is wrong with it

anyone? it would be greatly appriciated, and when i will realese the script i will credit the person who helps me

kthx :D
« Last Edit: November 13, 2008, 03:19:10 pm by Norbo »

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: Invalid number of parameters?
« Reply #1 on: November 13, 2008, 03:18:44 pm »
meh i fixed it now... thanks to TK`... well, please remove this topic

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
Re: Invalid number of parameters?
« Reply #2 on: November 13, 2008, 03:26:48 pm »
const
  CMD = '/showinfo';

WriteConsole(ID, 'Please wait '+ IntToStr(SPAMTIME) +' minutes between showing the server info', COLOR);

Result:

Code: [Select]
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
  i: integer;
begin
   if (Text = CMD) then
   begin
      if ((SpamTimer[ID] > 0) and (CanShowInfo[ID] = true)) then
      begin
        ShowInfo(ID);
        i:= SPAMTIME * 60;
        SpamTimer[ID]:=  i;
      end else
      begin
        WriteConsole(ID, 'Please wait '+ IntToStr(SPAMTIME) +' minutes between showing the server info', COLOR);
      end;
   end;
end;

The bug occurs due to your const named COMMAND.
In addition I fixed a conversion error -> IntToStr(SPAMTIME)

Code should work  ;)
Soldat Global Account System: #soldat.sgas @ quakenet