CBA Eventhandlers not triggered

  1. 6 years ago

    Hi there, about 7 months ago I created a topic related to event handlers and I recently just got back to the alivemod again. I've got some event handlers going and when I'm testing it on my local machine it works just fine but not when I move it over to my dedicated server on a different machine. I've tried different ways and as far as I got it to work and find what the problem is, and it something with alive that I've missed or are not understanding, because any AI's spawned from the alive modules aren't triggering the event handler, however, if I spawn an AI from Zeus it works just fine without a problem. Anyone got any ideas on how to resolve this?

    description.ext (I've tried switching CAManBase to Man and All and still no change, I mean it works just fine on my local machine)

    class Extended_Hit_EventHandlers {
    	class CAManBase {
    		hit = "_this call custom_fnc_handleHit;";
    	};
    };

    fn_handleHit.sqf (Just as a test to see if it's being triggered or not)

    params ["_unit","_causedBy","_damage","_instigator"];
    hint format ["Triggered\nUnit: %1\nCausedBy: %2\nInstigator: %3", name _unit, name _causedBy, name _instigator];
  2. I doubt it's causing your problem here, but its convention to use a class to separate your eventhandlers by mod

    class Extended_Hit_EventHandlers {
    	class CAManBase {
                class your_mod_name {
    		    hit = "_this call custom_fnc_handleHit;";
                };
    	};
    };
  3. @SpyderBlack723 I doubt it's causing your problem here, but its convention to use a class to separate your eventhandlers by mod

    class Extended_Hit_EventHandlers { class CAManBase { class your_mod_name { hit = "_this call custom_fnc_handleHit;"; }; }; };

    Oh I never knew about that, cheers man I'll give it a test and come back with the result shortly!

  4. @SpyderBlack723 I doubt it's causing your problem here, but its convention to use a class to separate your eventhandlers by mod

    class Extended_Hit_EventHandlers { class CAManBase { class your_mod_name { hit = "_this call custom_fnc_handleHit;"; }; }; };

    Sorry for the late response kinda took a break from scripting, anyhow I tried the way you recommended, for several mods. I've tried changing CAManBase as well (Man, All, etc), the only way I got it to work so far is by spawning the AI from Zeus.

    This issue kinda is the same as when I used the headless client, bots controlled by system or addons such as ALiVE and headless client doesn't seem to want to work. I have been looking into a different way by making a script that loops through all bots lets say every 10-15 seconds and then attaches the event handler at that point to the AI itself this would technically work at all time no matter if u use headless client or not.

    The problem is I do not really know how I would loop through the bots at all time, the best way would be if you could call when a unit is created in which it wouldn't be such a heavy performance hitter with massive loops all the time.

    If anyone wants to help me out, feel free giving me suggestions or what to do, otherwise, I'll have the end result with the source code here if anyone wants it.

  5. Edited 6 years ago by SpyderBlack723

    Just to confirm information:

    Have you tried with CBA / ALiVE only?
    Have you tried replacing your script/function with a super simple hint just to see if it gets called at all?

    Otherwise I think I pass the baton to @marceldev89 because he isn't busy enough.

  6. @SpyderBlack723 Just to confirm information:

    Have you tried with CBA / ALiVE only?
    Have you tried replacing your script/function with a super simple hint just to see if it gets called at all?

    Otherwise I think I pass the baton to @marceldev89 because he isn't busy enough.

    1: No, will do that in a bit working on another way to kinda inject it into each unit that is being spawned.
    2: Yes, just to be on the sure side I run a simple script with just a hint stating what event fired, I got both hit and kill events that aren't working any of them.

    Executes correctly when any unit is being spawned attaching the event handlers to it.

    ["CAManBase", "initPost", {_this call alive_fnc_setupEVH},true,[],true] call CBA_fnc_addClassEventHandler;

    This is the problem right now (currently tested this only with headless client, going to do a separate test in a bit to see if it does any different which I doubt it would as it only outputs the player as the unit assigned to call the function from above.

    diag_log format["Assigning Events to data: %1", name _this]; // Giving this error, Error in expression < format["Assigning Events to data: %1", name _this];
    diag_log format["Assigning Events to data: %1", name player]; // Works but only outputs the HC and not the rest of the players/units spawned on the map
  7. I might be reading this wrong but the event does actually fire but the code it executes gives an error, correct?

  8. Edited 6 years ago by 123B3n

    @marceldev89 I might be reading this wrong but the event does actually fire but the code it executes gives an error, correct?

    If you talking about the last post I did yes, but I figured out the issue. Somehow when it fired the event the data transferred from the code was an array, easy fix. I'm attempting right now to get the event handlers to work based on the initPost function.

    I simply just did a diag_log to see if the initPost is being executed on each unit that is spawned on the server and it seems to work so far.

  9. Honestly, I have no clue why this issue even happened but somehow I got it to work, in case anyone else has the same issue use this code below and it should work perfectly after just change the function to your script or function depending on how you build your mission.

    P.S I currently use headless client and that is what it is working for, can't confirm that it is working without it right now.

    if !(hasInterface or isServer) then {
    	["All", "Hit", {_this call alive_fnc_handleHit;}] call CBA_fnc_addClassEventHandler;
    	["All", "Killed", {_this call alive_fnc_handleKill;}] call CBA_fnc_addClassEventHandler;
    } else {
    	["CAManBase", "Fired", {_this call alive_fnc_handleFired;}] call CBA_fnc_addClassEventHandler;
    	["CAManBase", "Respawn", {_this call alive_fnc_handleRespawn;}] call CBA_fnc_addClassEventHandler;
    };
  10. Thanks added to wiki

    http://alivemod.com/wiki/index.php/Script_Snippets#CBA_Eventhandlers

  11. highhead

    6 Apr 2018 Administrator
    Edited 6 years ago by highhead

    @123B3n Great work! Thanks for keeping us posted!

  12. @highhead @123B3n Great work! Thanks for keeping us posted!

    @SavageCDN Thanks added to wiki

    http://alivemod.com/wiki/index.php/Script_Snippets#CBA_Eventhandlers

    Thank you all, wish I had a better solution to the problem but I'll investigate it deep in hope of finding another solution without the use of the headless client.

    I'll stay in touch once I know more.

  13. 4 years ago
    Edited 4 years ago by Beyaco

    Does anybody have an example or some sort of guide with CBA even triggers and ALiVE? I am in a bit over my head with all of this, but a small step by step would be much appreciated.

 

or Sign Up to reply!