Author Topic: Problem with putting table into procedure  (Read 1014 times)

0 Members and 1 Guest are viewing this topic.

Offline Mighty

  • Camper
  • ***
  • Posts: 276
Problem with putting table into procedure
« on: June 20, 2010, 05:42:56 pm »
I have smth like that:

Code: [Select]
var
   ArrayInt: array[0..50] of integer;

Procedure HelpMe(Source: array[0..50] of integer);
begin
   WriteLn('This line doesnt work');
(...)
end;

function OnPlayerCommand(ID: Byte; Text: string): boolean;
begin
(...)
   WriteLn('This line works');
   HelpMe(ArrayInt);
   WriteLn('This line doesnt work');
(...)
end;


No compilation mistakes, but when i use the command:
  • [Error] ScriptName -> (OnPlayerCommand): Type Mismatch


My question is: how can i use table in procedure?
I tried with Source: TStringArray & ArrayStr: TStringArray and then converting ArrayStr to ArrayInt, but then i was getting Out Of Range error
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID

Offline mich1103

  • Flagrunner
  • ****
  • Posts: 558
  • Did you say chocolate ? O.o
    • ZoMbIe-DeStRoYeR pk server
Re: Problem with putting table into procedure
« Reply #1 on: June 20, 2010, 05:53:53 pm »
First wath you want to do ?

Offline Mighty

  • Camper
  • ***
  • Posts: 276
Re: Problem with putting table into procedure
« Reply #2 on: June 20, 2010, 06:06:50 pm »
My question is: how can i use table in procedure?

Anyways it doesn't really matter what i want to do specificly, i just want to use procedure using table. and i have no idea how. tried all ideas.

I've written in code which line works and which doesnt.
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Problem with putting table into procedure
« Reply #3 on: June 20, 2010, 06:10:07 pm »
Code: (pascal) [Select]
Var
 MyArray: Array[0..50] of Integer;

Procedure HelpMe(Source: Array of Integer); //You cant determine the length of the array inside the parameters. :)
 Begin
  WriteLn('Yo dawg, this s.. is working!');
 WriteLn('Length of your array: '+IntToStr(GetArrayLength(Source)));
end;

Function OnPlayerCommand(ID: Byte; Text: String): Boolean;
 Begin
 if LowerCase(Text) = '/hey' Then HelpMe(MyArray);
end;

//Doing /hey would output this:

//"Yo dawg, this s.. is working!
//Length of your array: 51"

//~~~~~~~~

//I don't know if that is what you seek, I just fixed the problems with it. :)
www.soldatx.com.br - The brazilian Soldat community.

Offline Mighty

  • Camper
  • ***
  • Posts: 276
Re: Problem with putting table into procedure
« Reply #4 on: June 20, 2010, 09:13:04 pm »
Very big -THANKS-, that's exactly what i needed :)
xFire: macmil        e-mail: macekmil@gmail.com
My scripts: Accuracy Script       Flashbang       Punishments GUID
            CatchMe Gamemod       AntiFake
            CW System             AntiFakeGUID

Offline squiddy

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 333
  • Flagger assassin
    • SoldatX
Re: Problem with putting table into procedure
« Reply #5 on: June 20, 2010, 09:38:42 pm »
You are welcome. :)
www.soldatx.com.br - The brazilian Soldat community.