Unable to add 'Addaction' to spawning units

  1. 10 years ago

    Hello everyone,

    I really like Alive and I'm playing around with different features. I'm working on a mission, that takes place
    in Takistan, were it is important to establish a good relationship with the local population.
    One way of doing that in this mission is by talking to them via an 'Addaction'. However, I'm not understanding how I can add
    the 'addaction' to civilians that spawned with the civilian module (I have managed to get civies spawning ;P).

    The line below is the line that I use in the editor on editor placed units (which works well, no problem).

    talk= this addAction ["Talk", "talk\talk_init.sqf", [true, false, false, false]];

    I tried to apply this to my needs and came up with this:

    class Extended_Init_EventHandlers { class Man { talk = "_this call (addAction ["Talk", "talk\talk_init.sqf", [true, false, false, false]];)"; }; };

    Looking at that will show you how less of a clue I got :). I usually get stuff working after some reading and trying, but after some game crashes due to messing with the description file I got the feeling that asking on this forum might be a better idea..

    So is there some one able and willing to point this newbie in the right direction?
    Thanks for your time and effort.

    Greets from Tiberius

  2. init = "_this call (compile preprocessFileLineNumbers 'my_script.sqf')";

    ^needs to be in that format

  3. Edited 10 years ago by dixon13

    In your script you could do:

    class Extended_Init_EventHandlers {
        class Man {
            init = "_this call (compile preprocessFileLineNumbers 'script.sqf')";
        };
    };

    In script.sqf:

    [_this,"addActionMP", true] call BIS_fnc_MP;

    When initializing or in the init.sqf state the function:

    addActionMP = { _this addAction ["Talk","talk\talk_init.sqf"];
  4. Hello Dixon13,

    Thanks for your response. Following the steps you gave me in your second post unfortunatly resulted in a error report (every time a unit was trying to spawn) saying:

    "[BIS_fnc_mpexec] function or scripting command 'addactionmp' does not exist".
    That was fixed by changing your line to:
    addActionMP = { _this addAction ["Talk","talk\talk_init.sqf"] };

    however, no civilians had the 'talk' action...

  5. Yeah whoops sorry. Forgot the '}'. I'm glad it worked for ya.

  6. Hello Dixon13,

    I appreciate the help, but the civilians still do not spawn with the 'addaction'.

  7. Oh sorry didn't notice you had said, "however, no civilians had the 'talk' action..."; I will test myself and see if I can get you a solution.

  8. Init.sqf:
    class Extended_Init_EventHandlers {
    class Man {
    init = "_this call (compile preprocessFileLineNumbers 'script.sqf')";
    };
    };

    script.sqf:
    if (side _this == CIV) then {_this addAction ["Talk","talk\talk_init.sqf"] };

    Top scripting tip: Always do it the simplest way first until you know it works, then you can clean it up and optimise it. :)

  9. Edited 10 years ago by Tiberius

    Hello Spencer42, thanks for your input. Following your steps unfortunately does not lead to any other result. No one has the action other than the units I gave it to manually. Not the civilians that spawn through the civilian placement module, and the other civies placed in the editor (as a test). I don't really have a clue whats going on or what I'm doing wrong. I think I messed something up somewhere.

    But I solved the problem by placing units with the addaction in the editor and run them through a cache script . Might not be as nice as using ALiVE, but it is effective ;). I cant spend any more time on this problem... :=(

    Thanks for your help spencer42 and dixon13.

    greets,

    Tiberius

  10. 9 years ago
    Edited 9 years ago by Tiberius

    Hello Everybody,

    Apologies for reopening an old conversation. I'm trying to achieve the same thing as before.
    Spawn Alive civilians with an addaction so I can walk up to them and start a custom conversation.
    I still not managed to achieve this.

    To practice I tried to add custom gear, by following the example as given here :

    However, It didn't work for me... :-(

    This is the code I used:

    description.ext

    class Extended_Init_EventHandlers {
     class Man {
      init = "_this call (compile preprocessFileLineNumbers 'script.sqf')";
     };
    };

    script.sqf

    private "_this";
    _this = _this select 0;
     
    if (side _this == civ) then 
    {
      _this addHeadgear "H_CrewHelmetHeli_B";
    };

    I know this is pretty much the same as Dixon13 and Spencer42 suggested I should do...
    Can any1 give me some advice on how to approach this? I have no time-limit anymore.

    Thanks in advance!

    Cheers
    Tiberius

  11. Edited 9 years ago by dixon13

    script.sqf should look like this... since the first script doesn't place your 'this' variable into an array.

    if (side _this == civ) then {
        _this addHeadgear "H_CrewHelmetHeli_B";
    };

    No need to state _this = _this select 0 since _this is not referring to an array but rather an object.

  12. Deleted 9 years ago by dixon13
  13. Thanks again for your help Dixon13.

    It changed it to what you suggested, but it still doesn't work for me... No units spawn with helmets...
    Is it even possible to spawn units with an addAction?

  14. Does anyone have any input for this. All help will be greatly appreciated :)

  15. Edited 9 years ago by SpyderBlack723

    Is it even possible to spawn units with an addAction?

    Definitely possible, I'll give it a shot and see if I can figure it out. I have done it before though.

    Edit: Alright, this is how I got it to work

    This is the line I used in the description.ext

    class Extended_Init_EventHandlers {
     class Man {
      init = "_this call (compile preprocessFileLineNumbers 'script.sqf')";
     };
    };

    And this is what I used in the script.sqf file

    private "_unit";
    _unit = _this select 0;
    
    if (side _unit == east) then {
    	removeHeadgear _unit;
    	_unit addHeadgear "H_CrewHelmetHeli_B";
    };

    So for you it could be something like

    private "_unit";
    _unit = _this select 0;
    
    if (side _unit == civ) then {
    	talk= _unit addAction ["Talk", "talk\talk_init.sqf", [true, false, false, false];
    };

    You could also use the addActionMP version that Dixon posted. If this doesn't work for you, test using vanilla civilians/units to make sure it is not a mod problem.

  16. Hello Spyder, Thanks for your suggestion. I will give this a try first thing tomorrow!

  17. Edited 9 years ago by dixon13

    I have been testing this lately and you must use _this select 0 so disregard what I said earlier in this thread. Here is what I said earlier.

  18. Also, if you are finding issues with Extended Event Handlers not running on units, then try enabling CBA's XEH Auto PBO, which can be found in their mod under 'optionals'.

  19. highhead

    25 Jun 2015 Administrator

    correct, your should make sure the Addon is CBA XEH compatible.
    For existing addons you may put the cba_enable_autoXEH.pbo (or similiar) from the CBA optionals folder to the /addons folder.

    If you are doing an addon yourself you may want to ping CBA dev team, they can help you with it!

  20. Hello all, thanks for your help and your advice. However, I still have zero results. Civilians do not spawn with helmets and civilians also do not spawn with the Addaction (I tried to fill script.sqf with all options). I copied what everyone posted in the files... I also tried it with different mod combinations. Last time I just used Alive and CBA. So there is no mod issue.

    I'm clueless about whats going on and why this is not working. Do you guys get it to work with the exact same code?

  21. Newer ›
 

or Sign Up to reply!