Jump to content
Sign in to follow this  
sickboy

CBA: Community Base Addons public release!

Recommended Posts

Is CBA that is being distributed thru sixupdater the latest one and should be used by mods? Asking because latest version of CBA is not listed in the files section of CBA project space @ dev-heaven.

Yes, Six Updater version is the latest.

We are doing final testing with the current version and if all lights remain green, we hope to release a new version officially, hopefully by the end of this week.

Share this post


Link to post
Share on other sites

Sorry for the noob question, but are init event handlers supposed to be used differently for multiplayer initialization.

This is what I have in my config.cpp

class Extended_Init_Eventhandlers
{
   class Man
   {
       xeh_init = "[] execVM '\MapTools\script\add_ruler.sqf'";
   };
};

This runs fine in single player but as soon as I try and run it on a server (running locally) it fails to initialize.

Using the latest CBA build as of today from SIX.

Share this post


Link to post
Share on other sites

There's many things that need to be handled differently in Multiplayer, which is nothing specific to using XEH/CBA eh's.

I suggest to add some logging to add_ruler.sqf, with e.g diag_log text "my message";

which ends up in your arma.rpt.

Please also don't use xeh_init as your init name. It is supposed to be your tag + addonname :)

Share this post


Link to post
Share on other sites

Thanks Sickboy,

It shouldn't be an issue with my script, that is to say as well its probably not an issue in CBA either. I have had previous iterations before trying to tie it into CBA working in multiplayer, both being loaded from the units initialization field from the editor and later through dialog (the map screen) initializing when first opened.

As for diagnostic messages I had it sleep for a few second and then try and put some output to sideChat and I wasn't getting anything. I even added a waitUntil {player == player}; to see if that would help. No dice. :(

Didn't know about the xeh_init stuff. Is there any documentation beyond what is on DH? I am somewhat confused by a number of the naming conventions that XEH uses. :(

Sorry for the trouble. I will try changing the xeh_init line tomorrow and see if that helps.

*edit*

Sort of related (at least as an oddity). I am using CBA for something else, and I noticed that when I am in the editor testing if I go to the escape menu and restart I still have the keyboard event handlers that were added the first time around using the CBA keyboard handler functionality. Only if I go back into the editor and preview again do they clear out. :confused:

Edited by NouberNou

Share this post


Link to post
Share on other sites

Hard to say what is the problem. I know for certain that pre and post inits work 100%.

If I find a minute i'll have a quick look on Manbased init handlers.

We always attach them to CAManBase instead of Man though.

If you would like some examples I could recommend having a look at ACE Mod; ace_sys_*** addon configs, almost all implement XEH handlers :)

Please report bugs on the issue tracker with the required details instead :)

Share this post


Link to post
Share on other sites
Thanks Sickboy,

It shouldn't be an issue with my script, that is to say as well its probably not an issue in CBA either. I have had previous iterations before trying to tie it into CBA working in multiplayer, both being loaded from the units initialization field from the editor and later through dialog (the map screen) initializing when first opened.

As for diagnostic messages I had it sleep for a few second and then try and put some output to sideChat and I wasn't getting anything. I even added a waitUntil {player == player}; to see if that would help. No dice. :(

Hmm... try having this:

class Extended_Init_Eventhandlers
{
   class Man
   {
       NOU_MapInit="diag_log text 'Maptools init';[] execVM '\MapTools\script\add_ruler.sqf'";
   };
};

Here, I've used a made-up OFPEC tag in order to make your XEH init entry (hopefully) unique. This should log something to your ArmA2.RPT file when a mission is started. (Please head to the OFPEC tag registry and register a tag for yourself, then use that)

Didn't know about the xeh_init stuff. Is there any documentation beyond what is on DH? I am somewhat confused by a number of the naming conventions that XEH uses. :(
Yes, the XEH documentation isn't very clear on this. The general rule/convention is: make up a name for your extended event handler entry that's unique. One way to do that is to to name it eg <TAG>_<somethingunique>. There isn't any other documentation than that which is in the CBA wiki, but have a look at other addons out there that make use of the extended event handlers system, such as the ACE addons (like Sickboy mentions). That's a good way of learning a few tricks. :)
*edit*

Sort of related (at least as an oddity). I am using CBA for something else, and I noticed that when I am in the editor testing if I go to the escape menu and restart I still have the keyboard event handlers that were added the first time around using the CBA keyboard handler functionality. Only if I go back into the editor and preview again do they clear out. :confused:

Hmm...interesting... that may need some poking at to see if we can solve it. :) Edited by Killswitch

Share this post


Link to post
Share on other sites

Awesome, thanks Sick and Kill! :D I'll be sure to try that as soon as I get up tomorrow.

Also I will try and use the bug tracker... It just reminds me of my previous employment too much (any bug tracker). :p They are a good asset though!

Share this post


Link to post
Share on other sites

Dont forget to first go to ofpec and register your TAG ;)

Share this post


Link to post
Share on other sites
Dont forget to first go to ofpec and register your TAG ;)

Yea, def will. I been tagging most of my stuff (public vars, setVariables, etc) already to avoid namespace conflicts. Thats a habit learned from years of PHP class writing... :P I find myself doing it even in languages that have nice namespace support... :rolleyes:

Share this post


Link to post
Share on other sites

Changed the name of the property to one with my tag and changed the class to CAManBase and it works now. Thanks! :)

Share this post


Link to post
Share on other sites

Can the up-to-the-minute version be had through YOMA? If so, can someone provide the URL?

Share this post


Link to post
Share on other sites

I was wondering which event would be the best to add an action to every unit?

I have tried init and initpost but I can't seem to get any sort of variable to refer to the object that its being called on. Neither _this or this work. Wondering if there is something else that works there or if I am doing it wrong, or if there is a bug (which I will file a report for if its the case).

NOU_MapPlus_CopyMapPosInit = "diag_log text ""copy post init""; this addAction [""Copy Map"", ""script\NOU_MapPlus_fnc_CopyMap.sqf"", this, 0, true, true, ""Action"", ""true""];";

I was getting some "generic error in expressions" when using _this and with "this" I get an undefined variable.

The above example is just the current iteration (used single quotes in double quotes, vica versa, and now the double double quotes), and the script location for addaction is in a mission for testing.

---------- Post added at 11:19 PM ---------- Previous post was at 11:08 PM ----------

Nevermind, found it. The variable is "_unit".

:)

---------- Post added at 12:50 AM ---------- Previous post was Yesterday at 11:19 PM ----------

OK, legit question this time. Is the respawn init handlers meant to handle when a player is killed and respawns in the game or just when a player spawns into a unit, or multiple times...

Now that I type that out it sort of sounds like this is broken. Just wanting to clarify before I right up a bug report. I'll test out some other things too, like writing to the rpt.

Share this post


Link to post
Share on other sites
Please take a look at how ArmA 2 Eventhandlers work: http://community.bistudio.com/wiki/ArmA_2:_Event_Handlers

_this select 0, contains the unit.

Sorry Sickboy, I was going off the example on the DH page that included using "_this" in the actual event handler decleration.

From DH:

class Extended_Init_Eventhandlers
{
   class Man
   {
       class SLX_XEH_RespawnInitMan
       {
           onRespawn = true;                    // Run this even after respawn
           init      = "_this call My_Respawn_InitEH";
       };
   };
};

Mine:

class Extended_Init_Eventhandlers
{
   class CAManBase
   {
       class NOU_MapPlus_CopyPostInit {
           onRespawn = 1;
           init = "_unit addAction [""Copy Map"", ""script\NOU_MapPlus_fnc_CopyMap.sqf"", _unit, 0, true, true, ""Action"", ""(_target != player && ('MapTools' in weapons _target))""]";
       };
   };
};

I do not know if that is an error or intended that _this doesn't work and _unit does.

Share this post


Link to post
Share on other sites

_unit = _this select 0;

Both work. _this is an array, not an object.

Share this post


Link to post
Share on other sites
_unit = _this select 0;

Both work. _this is an array, not an object.

Ahhh, gotcha! That was the generic error... :p Dang eval'd code not being helpful! :(

Now I will hopefully find something equally dumb on my part with the code not running again when I get killed or kill another player.

Edited by NouberNou

Share this post


Link to post
Share on other sites

I'm getting an error whenever I try and start up ArmA2 with CBA, ACE and HiFi.

Include file x\cba\addons\main\script_macros_common.hpp not found.

Can anybody help?

Share this post


Link to post
Share on other sites

I need some help here with a script

[-2, {rrlane1 globalChat format["Rifle Lane 1 Targets :%1 Hit :%2", _inc, _score]}, ""] call CBA_fnc_globalExecute;

Instead of getting any values, it says "ANY"

any suggestions?

this is the entire script

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: TODO: Author Name
//////////////////////////////////////////////////////////////////

//                 How to use. 
// 1. Place a popup target and name it to pt1 
// 2. copy it 8 times and it will auto name the targets
// 3. place this line in a trigger or init  nul=[max,set,time] execVM "popup.sqf" 
// max  is the total number of targets that will popup
// set is the max number of targets that can popup per set upto a max of 3
// time is the amount of time to hit the targets before they go down

if (!isServer) exitWith{};

_maxtarg  = _this select 0;
_numtargs = _this select 1;
_skill    = _this select 2;

_targets = [pt1,pt1_1, pt1_2, pt1_3, pt1_4, pt1_5];// target names 
_many    =  count _targets; // count the number of possible targets

_inc     = 0;// keeps track of the number of popup targets triggered 
_score   = 0;// keep count of the targets hit


{_x  animate["terc",1]} forEach _targets;//puts the targets down before the start

_rnumber1=0; 
_rnumber2=0;
_rnumber3=0;

_flag1=0;
_flag2=0;

nopop=true; // sets them to stay down until triggered to popup

hint "Range is Hot";
sleep 2;
hint "Scan your Lane";
sleep 2;


while {_inc<_maxtarg} do 
{
_rnumber1 = random _many;
_int = _rnumber1%1;
_rnumber1 = _rnumber1-_int;


// 1. Check for duplicate targets 
while {(_rnumber1 == _rnumber2) or (_rnumber1 == _rnumber3) or (_rnumber2 == _rnumber3)} do
{  
_rnumber2 = random _many;
_int = _rnumber2%1;
_rnumber2 = _rnumber2-_int;

_rnumber3 = random _many;
_int = _rnumber3%1;
_rnumber3 = _rnumber3-_int;
};
// 1. END

// 2. Set the targets that will popup
_rtarget1 = _targets select _rnumber1;
_rtarget2 = _targets select _rnumber2;
_rtarget3 = _targets select _rnumber3;
// 2. END

// 3. Popup target one always active
_rtarget1 animate["terc", 0];
_inc=_inc+1;
// 3. END

// 3a. Check to see if more than one target is required and opopup at random
// 3b. second target
If (_numtargs > 1 ) then
{
if ((random 2 > 1) and (_inc < _maxtarg)) then
{
_rtarget2 animate["terc", 0];
_inc=_inc+1;
_flag1=1;
};
};
//3b. END

//3c. Third target
If (_numtargs > 2 ) then
{
if ((random 2 < 1) and (_inc < _maxtarg)) then
{
_rtarget3 animate["terc", 0];
_inc=_inc+1;
_flag2=1;
};
};
// 3c. END
// 3a. END

// 4. Time allowed for shooting.
sleep _skill; 
// 4. END 

// 5. Check to see if targets have been hit and count the score
if (_rtarget1 animationPhase "terc" > 0.1) then
{
	_score = _score+1;
	    };
if ((_rtarget2 animationPhase "terc" > 0.1) and (_flag1 == 1)) then

{
	_score = _score+1;
	    };
if ((_rtarget3 animationPhase "terc" > 0.1) and (_flag2 == 1)) then
{
	_score = _score+1;
	    };
// 4. END		    

// 5. Display Score		    
// original rrlane1 globalChat format["Rifle Lane 1 Targets :%1 Hit :%2", _inc, _score]; 
 [-2, {rrlane1 globalChat format["Rifle Lane 1 Targets :%1 Hit :%2", _inc, _score]}, ""] call CBA_fnc_globalExecute;
// 5. END

// 6. Reset targets down and restet flags
_rtarget1 animate["terc", 1];
_rtarget2 animate["terc", 1];
_rtarget3 animate["terc", 1];
_flag1=0;
_flag2=0;
// 6. END

sleep 2;
};
sleep 8;
hint "Session Complete";

Share this post


Link to post
Share on other sites
I need some help here with a script

[-2, {rrlane1 globalChat format["Rifle Lane 1 Targets :%1 Hit :%2", _inc, _score]}, ""] call CBA_fnc_globalExecute;

Instead of getting any values, it says "ANY"

any suggestions?

Hi, this should work:

[-2, {rrlane1 globalChat _this}, format["Rifle Lane 1 Targets :%1 Hit :%2", _inc, _score]] call CBA_fnc_globalExecute;

However, you might want to consider something like:

Add this to init.sqf:

["my_radioMsg", {(_this select 0) globalChat (_this select 1)}] call CBA_fnc_addEventHandler;

And in your script use:

["my_radioMsg", [rrlane1, format["Rifle Lane 1 Targets :%1 Hit :%2", _inc, _score]]] call CBA_fnc_globalEvent;

http://dev-heaven.net/docs/cba/files/events/fnc_addEventHandler-sqf.html

http://dev-heaven.net/docs/cba/files/events/fnc_globalEvent-sqf.html

Or like this, will save on network bandwidth:

Add this to init.sqf:

["my_radioMsg", {(_this select 0) globalChat format["Rifle Lane 1 Targets :%1 Hit :%2",_this select 1, _this select 2]}] call CBA_fnc_addEventHandler;

And in your script use:

["my_radioMsg", [rrlane1, _inc, _score]] call CBA_fnc_globalEvent;

You could also save the strings in a stringtable, and refer the stringtable entries, to make things more dynamic and usable for other messages.

Edited by Sickboy

Share this post


Link to post
Share on other sites

Hey C.B.A. guy's!

Just wanna to say thank you very much for developing and updating C.B.A.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×