Author Topic: where is bug?  (Read 905 times)

0 Members and 1 Guest are viewing this topic.

Offline sckme

  • Major(1)
  • Posts: 33
where is bug?
« on: October 18, 2008, 12:01:56 pm »
Code: [Select]
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
  i: byte;
  Vips: TStringArray;
  Match: boolean;
begin
  if GetPiece(Text,' ',0) = '/sayv' then begin
    SetArrayLength(Vips, 1);
    Vips:= xsplit(ReadFile('vips.txt'), #10 + #13);
    Match:= false;
    for i:= 0 to ArrayHigh(Vips) do begin
      if IDToIP(ID) = Vips<i> then Match:= true;
    end;
    if Match then WriteConsole(0,'[VIP][' + IDToName(ID) + ']' + Copy(Text,6,Length(Text)), Color);
  end;
end;

When is start my dedicatet server i saw this comunique

Code: [Select]
Invalid number of parameters in if
Where is bug? Can somebody fix it? sry 4my sucks eng

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: where is bug?
« Reply #1 on: October 18, 2008, 12:16:29 pm »
  if IDToIP(ID) = Vips<i> then Match:= true;

You cant use "<i>". its ""

Offline sckme

  • Major(1)
  • Posts: 33
Re: where is bug?
« Reply #2 on: October 18, 2008, 01:27:19 pm »
Code: [Select]
08-10-18 20:21:50  [*] colortextvip -> [Error] (10:12): Unknown identifier 'xsplit'
next error xD

Offline CurryWurst

  • Camper
  • ***
  • Posts: 265
    • Soldat Global Account System
Re: where is bug?
« Reply #3 on: October 18, 2008, 01:40:50 pm »
Don't forget to implement XSplit ;)

Code: [Select]
function xsplit(const source: string; const delimiter: string):TStringArray;
var
i,x,d:integer;
s:string;
begin
d:=length(delimiter);
x:=0;
i:=1;
SetArrayLength(Result,1);
while(i<=length(source)) do begin
s:=Copy(source,i,d);   
    if(s=delimiter) then begin
    inc(i,d);
    inc(x,1);
    SetArrayLength(result,x+1);
    end else begin       
    result[x]:= result[x]+Copy(s,1,1);
    inc(i,1);
  end;
end;
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
  i: byte;
  Vips: TStringArray;
  Match: boolean;
begin
  if GetPiece(Text,' ',0) = '/sayv' then begin
    SetArrayLength(Vips, 1);
    Vips:= xsplit(ReadFile('vips.txt'), #10 + #13);
    Match:= false;
    for i:= 0 to ArrayHigh(Vips) do begin
      if IDToIP(ID) = Vips<i> then Match:= true;
    end;
    if Match then WriteConsole(0,'[VIP][' + IDToName(ID) + ']' + Copy(Text,6,Length(Text)), Color);
  end;
end;
Soldat Global Account System: #soldat.sgas @ quakenet

Offline sckme

  • Major(1)
  • Posts: 33
Re: where is bug?
« Reply #4 on: October 18, 2008, 01:57:00 pm »
Code: [Select]
08-10-18 20:55:17  [*] colortextvip -> [Error] (37:93): Unknown identifier 'Color'

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: where is bug?
« Reply #5 on: October 18, 2008, 02:16:40 pm »
add in this to the top:
Code: [Select]
const
   Color = $FFFFFF //white

Offline sckme

  • Major(1)
  • Posts: 33
Re: where is bug?
« Reply #6 on: October 18, 2008, 03:12:43 pm »
Code: [Select]
08-10-18 22:11:42  [*] colortextvip2 -> [Error] (26:1): Semicolon (';') expected
its script

Code: [Select]
function xsplit(const source: string; const delimiter: string):TStringArray;
var
i,x,d:integer;
s:string;
begin
d:=length(delimiter);
x:=0;
i:=1;
SetArrayLength(Result,1);
while(i<=length(source)) do begin
s:=Copy(source,i,d);   
    if(s=delimiter) then begin
    inc(i,d);
    inc(x,1);
    SetArrayLength(result,x+1);
    end else begin       
    result[x]:= result[x]+Copy(s,1,1);
    inc(i,1);
  end;
end;
end;

const
   Color = $FFFFFF //white
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
  i: byte;
  Vips: TStringArray;
  Match: boolean;
begin
  if GetPiece(Text,' ',0) = '/sayv' then begin
    SetArrayLength(Vips, 1);
    Vips:= xsplit(ReadFile('vips.txt'), #10 + #13);
    Match:= false;
    for i:= 0 to ArrayHigh(Vips) do begin
      if IDToIP(ID) = Vips[i] then Match:= true;
    end;
    if Match then WriteConsole(0,'[VIP][' + IDToName(ID) + ']' + Copy(Text,6,Length(Text)), Color);
  end;

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: where is bug?
« Reply #7 on: October 18, 2008, 04:50:09 pm »
eek my bad.
you need a ';' after Color = $FFFFFF;

I would highly suggest reading up on some programming stuffs before proceeding though, these are pretty simple errors.

Offline sckme

  • Major(1)
  • Posts: 33
Re: where is bug?
« Reply #8 on: October 19, 2008, 03:08:43 am »
Code: [Select]
08-10-19 10:08:25  [*] colortextvip -> [Error] (42:10): Identifier expected
next error...

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: where is bug?
« Reply #9 on: October 19, 2008, 03:26:46 am »
My script xDDD
Script

And yes it's giving error in if.

@sckme
If you wanted to get it quicker you should PM me  ;)