Difference between revisions of "CfgFunctions"

From Desolation REDUX Wiki
Jump to navigation Jump to search
(Created page with "To define functions you need to define CfgFunctions. The class follows a hierarchy. The top level is formed by the class definition of CfgFunctions followed by the definition...")
 
 
Line 1: Line 1:
To define functions you need to define CfgFunctions. The class follows a hierarchy. The top level is formed by the class definition of CfgFunctions followed by the definition of a class with the name of the Plugin, in this example called ExamplePluginName in the second level. The third level contains groups of functions, there has to be at least one group per new sub folder.Each group consists of a file parameter which, other then the name implies, does not define the filename, it defines the path to the ArmA Script File (SQF) files, including the base folder of the Plugin, in this example ExamplePluginPath. You can define where the group of functions shall be populated, with isServer = 1;you define that the function group shall be accessible on the server, while with isClient= 1;you define that the functions shall be transferred to the clients.To actually define the functions you add multiple classes to each group, whose name matches the function name. The example at the end of this section will 5PLUGINDEVELOPMENT
+
To define functions you need to define CfgFunctions. The class follows a hierarchy. The top level is formed by the class definition of CfgFunctions followed by the definition of a class with the name of the Plugin, in this example called ExamplePluginName in the second level. The third level contains groups of functions, there has to be at least one group per new sub folder.  
define the functions doStuffOnServerOne and doStuffOnServerTwo in the subfolder Server as well as doStuffOnClientOne, doStuffOnClientTwo and doStuffOnClientThree in the subfolder Client. The subfolder name does not influence where the function will get populated, this is only defined by isserver = 1; and isclient= 1;, the subfolder name is just an name.The files need to follow the naming fn_FunctionName.sqf and need to be located in the as file defined folder. So for doStuffOnServerOne the correct file name would be fn_doStuffOnServerOne.sqf in the folder ExamplePluginPathServerFunctions.There are reserved function names like initClient and initServer, these functions are automatically executed once on the corresponding instance as initialization.
+
 
 +
Each group consists of a file parameter which, other then the name implies, does not define the filename, it defines the path to the ArmA Script File (SQF) files, including the base folder of the Plugin, in this example ExamplePluginPath.  
 +
 
 +
You can define where the group of functions shall be populated, with isServer = 1;you define that the function group shall be accessible on the server, while with isClient= 1;you define that the functions shall be transferred to the clients.
 +
 
 +
To actually define the functions you add multiple classes to each group, whose name matches the function name. The example at the end of this section will 5PLUGINDEVELOPMENT
 +
define the functions doStuffOnServerOne and doStuffOnServerTwo in the subfolder Server as well as doStuffOnClientOne, doStuffOnClientTwo and doStuffOnClientThree in the sub folder Client. The sub folder name does not influence where the function will get populated, this is only defined by isserver = 1; and isclient= 1;, the subfolder name is just an name.
 +
 
 +
The files need to follow the naming fn_FunctionName.sqf and need to be located in the as file defined folder. So for doStuffOnServerOne the correct file name would be fn_doStuffOnServerOne.sqf in the folder ExamplePluginPathServerFunctions.
 +
 
 +
There are reserved function names like initClient and initServer, these functions are automatically executed once on the corresponding instance as initialization.
  
 
   class CfgFunctions
 
   class CfgFunctions

Latest revision as of 04:12, 21 March 2020

To define functions you need to define CfgFunctions. The class follows a hierarchy. The top level is formed by the class definition of CfgFunctions followed by the definition of a class with the name of the Plugin, in this example called ExamplePluginName in the second level. The third level contains groups of functions, there has to be at least one group per new sub folder.

Each group consists of a file parameter which, other then the name implies, does not define the filename, it defines the path to the ArmA Script File (SQF) files, including the base folder of the Plugin, in this example ExamplePluginPath.

You can define where the group of functions shall be populated, with isServer = 1;you define that the function group shall be accessible on the server, while with isClient= 1;you define that the functions shall be transferred to the clients.

To actually define the functions you add multiple classes to each group, whose name matches the function name. The example at the end of this section will 5PLUGINDEVELOPMENT define the functions doStuffOnServerOne and doStuffOnServerTwo in the subfolder Server as well as doStuffOnClientOne, doStuffOnClientTwo and doStuffOnClientThree in the sub folder Client. The sub folder name does not influence where the function will get populated, this is only defined by isserver = 1; and isclient= 1;, the subfolder name is just an name.

The files need to follow the naming fn_FunctionName.sqf and need to be located in the as file defined folder. So for doStuffOnServerOne the correct file name would be fn_doStuffOnServerOne.sqf in the folder ExamplePluginPathServerFunctions.

There are reserved function names like initClient and initServer, these functions are automatically executed once on the corresponding instance as initialization.

 class CfgFunctions
 {
   class EXP
   {
     class Server
     {
       file = "Server";
       isserver = 1;
       class initServer {};
     };
     class Client
     {
       file = "Client";
       isclient = 1;
       class initClient {};
     };
     class ServerFunctions 
     {
       file = "Server\Functions";
       isserver = 1;
       class doStuffOnServerOne {};
       class doStuffOnServerTwo {};
     };
     class ClientFunctions 
     {
       file = "Client\Functions";
       isclient = 1;
       class doStuffOnClientOne {};
       class doStuffOnClientTwo {};
       class doStuffOnClientThree {};
     };
    };
   };

For more examples about the definition of functions take an Plugin like the database Plugin of APMS: DesoDB Plugin