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.

 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'


// 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;
  WriteLn('StrangeString: '+StrangeString);
  WriteLn('ItchyInt: '+IntToStr(ItchyInt));
  WriteLn('YourSingle: '+FloatToStr(YourSingle));
  result := 'FunkyDuck has a return string!';

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

  MyStr: String;
  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

External Links