Author Topic: Type mismatch..  (Read 781 times)

0 Members and 1 Guest are viewing this topic.

Offline toRch

  • Major
  • *
  • Posts: 55
  • <3
Type mismatch..
« on: January 10, 2008, 06:57:31 am »
I just tried to do a gather-ish script.
I get a type mismatch when i starting the server(in some earlier versions that happened when i typed !add ingame).
I guess it has something to do with byte and integer cooperation.
So could you guys help me out please? :)
Also please tell me what lines i could delete to make this shorter, cause im nubtard at scripting(this is my first serious script).
thanks

Code: [Select]
var
adders: array [1..32] of integer;
people: integer;

function isIn(put: array [1..32] of integer; get: integer): boolean;
 var i: integer;
 begin
  for i:=1 to 32 do
  begin
  if put[i]=get then
   begin
     result:=true;
     exit;
   end;
  end;
  result:=false;
  end;

procedure activateserver();
var i: integer;
begin
for i:=1 to 32 do
 begin
   adders[i] := 0
 end;
  people:=0;
 end;


procedure OnPlayerSpeak(ID: Byte; Text: string);
begin
 if lowercase(Text) = '!add' then
  begin
   if isIn(adders,id)=true then
    begin
     SayToPlayer(ID,'already added!') end
     else begin
      adders[people+1]:=id;
      people:=people+1;
      SayToPlayer(ID,'added');
     end;
    end;
end;

« Last Edit: January 10, 2008, 06:07:34 pm by toRch »

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Type mismatch..
« Reply #1 on: January 10, 2008, 02:51:40 pm »
      adders[people+1]:=idtoname(id);

adders is an array of integers and idtoname() returns a string ;) There's your error. Maybe you wanted to use ID right away? =P

Offline toRch

  • Major
  • *
  • Posts: 55
  • <3
Re: Type mismatch..
« Reply #2 on: January 11, 2008, 12:40:32 pm »
Thanks! This problem seems to be solved. But I am still getting an error:

Code: [Select]
08-01-11 00:05:05  [*] myscripts -> [Error] (41:22): Invalid number of parameters
I edited in the new version.

Date Posted: January 11, 2008, 12:05:46 am
*bump* anyone?

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Type mismatch..
« Reply #3 on: January 11, 2008, 04:27:31 pm »
Thanks! This problem seems to be solved. But I am still getting an error:

Code: [Select]
08-01-11 00:05:05  [*] myscripts -> [Error] (41:22): Invalid number of parameters
I edited in the new version.

Date Posted: January 11, 2008, 12:05:46 am
*bump* anyone?
no idea, that thing in the first post compiles fine for me