CrossFunc

From Soldat Community Wiki
Jump to: navigation, search

From the Scripting Manual

function CrossFunc(const Params: array of variant; ProcName: string): variant;

Parameter Info:
 Params (Array of Variant): Parameters to be passed to the function, must be in [ square brackets ]
 ProcName (String): Script name + function name to be called. See below for example.

Description:
 This function will call a procedure/function found within another script in your server /scripts/   folder. 
 The ProcName parameter must contain the script name + function name formatted like this: (Note the dot between script name and the function) 'MyScriptName.OnCommand'

Examples

// This function will be to test CrossFunc
// For example: Make a copy of the 'default' folder, name it 'default2'
// And place this function somewhere in the 'default2' Core.pas file

function FunkyDuck(StrangeString: String;ItchyInt: Integer;YourSingle: Single): string;
begin
  WriteLn('StrangeString: '+StrangeString);
  WriteLn('ItchyInt: '+IntToStr(ItchyInt));
  WriteLn('YourSingle: '+FloatToStr(YourSingle));
  result := 'FunkyDuck has a return string!';
end;

// Now for this code, place it in any other script folder.
// Such as: 'default', in any of the .pas files

var
  MyStr: String;
begin
  MyStr := CrossFunc(['my string',696969,1.234567],'default2.FunkyDuck'); // (Does not have to be assigned to a variable)
  WriteLn(MyStr); // This will print "FunkyDuck has a return string!" in the console
end;


External Links