English Solved How to Add Interactive Objects to the Company System

  • Auteur de la discussion Auteur de la discussion Bundestag
  • Date de début Date de début

Bundestag

User
3/4/21
25
1
1
300
Hello dear The-Programmer Forum,
i want do make an Object that is placed with the Company System and i wanted to know what do I have to pay attention to when implementing the objects?
I also want it to be fully implementetd in the Company-System like the other objects.

I allready Saw the Object Part in the Config and i also saw these tow things:
Code:
actionOnPlace = "max_entreprise_fnc_onPlaceInfoStandV1";
actionOnJoin = "max_entreprise_fnc_onJoinInfoStandV1";

So, for starters, do also create files like fnOnPlaceInfoStandV1 like the other objects have or can i add an addAction right into it.
And if i can add it right away, will it also be only acessebel for the Company employes?
 
Solution
Hey ! Since the 3.2 update, you're able to add new placeables items in the config_master.cpp of the script.

So in the config file, below :
Code:
class company_placeable_objects {
you can add :
[CODE highlight="1"]
class OBJECT_CLASSNAME {
displayName = "Process items";
type = "object";
can_be_placed = 1;
actionOnPlace = "life_fnc_companyProcessObject";
actionOnJoin = "life_fnc_companyProcessObject";
condition = "";
};
[/CODE]
Replace OBJECT_CLASSNAME by the object classname, it must be of a different classname from other placeable objects in the "company_placeable_objects"

Then, in your mission folder, create (in the folder you want, for example core/actions) a fn_companyProcessObject.sqf with the...
Hey ! Since the 3.2 update, you're able to add new placeables items in the config_master.cpp of the script.

So in the config file, below :
Code:
class company_placeable_objects {
you can add :
[CODE highlight="1"]
class OBJECT_CLASSNAME {
displayName = "Process items";
type = "object";
can_be_placed = 1;
actionOnPlace = "life_fnc_companyProcessObject";
actionOnJoin = "life_fnc_companyProcessObject";
condition = "";
};
[/CODE]
Replace OBJECT_CLASSNAME by the object classname, it must be of a different classname from other placeable objects in the "company_placeable_objects"

Then, in your mission folder, create (in the folder you want, for example core/actions) a fn_companyProcessObject.sqf with the following code :
[CODE highlight="21,26"]
/*
Maxence
*/
params [
["_entreprise",objNull,[objNull]],
["_currentObject",objNull,[objNull]]
];

_isOnPlaceEvent = false;
if (isNull _currentObject) then {_currentObject = maxence_placing_object; _isOnPlaceEvent = true;};
if ((isNull _entreprise) || (isNull _currentObject)) exitWith {};

if (_isOnPlaceEvent) then {
_members = _entreprise getVariable ["entreprise_members",[]];

{
_curCheck = _x;

{
if ((getPlayerUID _curCheck) isEqualTo (_x select 0)) then {
[_currentObject,2] remoteExecCall ["max_entreprise_fnc_entrepriseAddAction",_curCheck];
};
} forEach _members;
} forEach playableUnits;
} else {
[_currentObject,2] call max_entreprise_fnc_entrepriseAddAction;
};
[/CODE]
I won't go into the details of this code, but if you want to make yet another panel afterwards, you'll have to modify lines 21 and 26 whose "2" corresponds to the case in the file I'm going to tell you about next.

Don't forget that if you create a new mission file, you'll have to define the function in your Functions.hpp, like that :
Code:
class companyProcessObject {};

Last thing, to choose which action to add, in your @The_Programmer/addons/company_system/client/tp_entrepriseAddAction.sqf, below :
Code:
switch (_type) do {
add :
[CODE highlight="2"]
case 2 : {
_object addAction [localize "STR_Process_Iron",life_fnc_processAction,"iron",0,false,false,"",' life_inv_ironUnrefined > 0 && !life_is_processing && !life_action_inUse',5];
};
[/CODE]
You will also be able to change the process action, here I put the iron process. If you copy and paste the init of an object you already have on your map, don't forget to replace this with _object

I hope everything will work like that 😁
 
Solution