Jump to content

pierremgi

Member
  • Content Count

    7273
  • Joined

  • Last visited

  • Medals

  • Medals

Posts posted by pierremgi


  1.  {_x .... } forEach allUnits;

    is OK at start, on server only (no need to re-run that at each JIP)

    Note: For MP scenario, you must check if your sqf are ok for all commands with global effect GE . Multiplayer needs more attention for many things. See multiplayer threads.

    and https://community.bistudio.com/wiki/Multiplayer_Scripting

     

    Once in MEH "entityCreated", just use _entity for all you want to do. As there are plenty of different entities (objects like rabbits, projectiles,...), you need to filter. For example:

    if (faction _entity isEqualTo "BLU_F" && {_entity isKindOf "CAManBase"}) then { [_entity] execVM "scripts\loadouts\BLUFOR\NATO.sqf"};

    Here, you check for faction, which is a strong filter, then (lazy evaluation) you filter only unit ("CAManBase", because rabbits & snakes are "man") and you skip the vehicles of the faction.

    Note: execVMing an sqf is not the best way for performance saving, because you're recompiling the same code again and again. Create a function instead and call or spawn it. (there threads about that and BIKI is your friend).

    https://community.bistudio.com/wiki/Script_File

    https://community.bistudio.com/wiki/Function

    https://community.bistudio.com/wiki/Description.ext

    especially : https://community.bistudio.com/wiki/Arma_3:_Functions_Library

     

     


  2. _newUnits is just allUnits - _checkedUnits ... but _checkedUnits is also allUnits ...  further more, your variable _units seems to be useless.

     

    If I'm right you want to treat edited units and the spawned ones.

    An event handler is usually better than a loop. Here, the easy way is to treat in two parts, in init.sqf:

     

    { _x spawn ...} forEach allUnits;    // or add a filter: ... forEach (allUnits select {!isplayer _x}) (alive _x is useless with allUnits)
    
    addMissionEventHandler ["EntityCreated", {
       params ["_entity"];
      if (_entity isKindOf "CAManBase") then { do something on _entity};
    }];

     


  3. 3 hours ago, avibird 1 said:

    Hello jebus user or perhaps dreadpirate himself.

     

    I am trying to add this to code to one of the above codes that works.

    addMissionEventHandler ["entityRespawned",{ params ["_new","_old"]; if (_new isKindOf "CAManBase") then {  [_new,face _old] remoteExec ["setFace"];[_new,speaker _old] remoteExec ["setSpeaker"]; } }]; 

     

    Can"t get the right setup getting errors with ] } ect to see if it will work. Can somebody just get the codes merged so i can see if it will work.  Avibird.       

     

    We already discussed about that in an other thread. I mentioned this code with MEH "entityRespawned" when I thought you tried to REspawn some playable units.

    After discussion, if I'm right, you are trying to REspawn spawned AI units. This MEH doesn't work for simple AI (spawned or edited) because they are not playable so not eligible for the respawn system.

     

    Usually, moders and scripters use a code for re-creating an AI replacing the dead one, with more or less traits and behaviors (face, waypoints if single unit in group, loadout,...), with options like position (at start, at death...).

    You can also find some codes/modules for triggering a new AI unit/AI wave with same path(s), under conditions or timers. It's something near from your goal.

    The fact is  your demand for same face and speaker is not usual, and probably need specific lines about that, on existing codes.

    I understand and respect your choice for Jebus system. Tell me if you are interested in MGI modules.


  4. 20 hours ago, Furios_Guy said:

    Thank you! I decided to do the simpler one but is there a way to spawn a specific unit class?
    e.g 

    ["Zombie_G_Shambler_Civ","Zombie_G_Shambler_FIA","Zombie_G_Shambler_AAF"]

     

    If you're speaking about MGI module  Spawn Groups attack, yes. You just need to build your group in editor, as you want, with the loadout you want for each unit/vehicle, then link one of the unit to the module. Don't forget to set the side, the repetition, condition... and the spawning area(s) you want in module.

    Documentation is here: MGI ADVANCED MODULES by Pierre MGI

     

    • Thanks 1

  5. 18 hours ago, Furios_Guy said:

     it only works for one group and will not work once another group spawns in. How do I solve this problem?
    Activation: Independent
    Activation Type: Present
    Repeatable: Yes
    Server Only: No

    Condition:

    
    this


    On Activation:

    
    { 
    wp = group _x addWaypoint [getMarkerPos "TaskAssault_Mark",0]; 
    wp setWaypointType "MOVE"; 
    } forEach (units independent inAreaArray thisTrigger);

     

     

    The trigger activates when an indep unit enters its area or spawns in. This trigger must be deactivated before it runs again (rearmed).

    So, your first unit/group  must leave the area or must be treated for exiting thisList (need a variable for example).

     

    What I suggest:

     

    1. If you know how to apply a code on spawned unit/group by your spawned module, add your waypoint this way (no trigger). I don't know if these units/groups are identified somewhere.

     

    2. Far simpler : use MGI advanced modules, especially spawn Groups attack which allows you any group(s), of any side, of any mod, and any behavior (not only attack)... and code straight in module (here just write : (_this #0) addWaypoint [getMarkerPos "TaskAssault_Mark",0];  in code for group(s) field.) Simple as that.

     

     

    3. Try to hack your spawned group. Name your trigger (the area one, say:  spawningZone)
     

    addMissionEventHandler ["GroupCreated", {
      params ["_grp"];
      _grp spawn {
        params ["_grp"];
        sleep 0.5;
        if (side _grp == INDEPENDENT && units _grp inAreaArray spawningZone isNotEqualTo []) then {
          _grp addWaypoint [getMarkerPos "TaskAssault_Mark",0]
        };
      };
    }];

     

     

     


  6. if (!hasInterface) exitWith {}; means dedicated server are out. That means you can't apply from server some MEH for playable (non-played units, but respawnable by Arma engine) as far as they stay on server.

     

    As rule of thumb, all codes for player should be in initPlayerLocal.sqf  (initPlayerServer can help when code concerns player but should run on server. Some commands need that).

    player is defined straight in initPlayerLocal.sqf

     

    Init.sqf is fine for general code, in accordance with Initialisation_Order every time a code must run on every PC (and it runs locally each time a player joins. then, if a command/function is Effect Global, you can have multiple times for this/these effect(s) ).

     

     


  7. 1 hour ago, avibird 1 said:

    Question for you on spawning units. If I change a units clothes weapons and gear it carries over when the unit is spawned into the game but if I change a units character features such as voice or face textures from the editor and if I use jebus and and voice reverts back to the original units and does not keep the editor modified face textures and voice. I don't know if this is a armor limitation or jebus. 

     

    I can't say how jebus work. We can't speak about limitation so far. Probably due to commands used for setting face (setFace?) and voice (setSpeaker?) , which are both Effect Local so you need to remoteExec them everywhere.


  8. On 4/5/2024 at 4:19 PM, avibird 1 said:

     if they are grouped with other OPFOR units the original  predator units they will kill AI teammates or any other unit on its side.

     

    Probably because your predators are enemySide (renegade) and not OPFOR...  Could you elaborate which side or in which context these units are killing teammates?

     

    On 4/5/2024 at 4:19 PM, avibird 1 said:

     How can I stop  friendly fire damage for OPFOR and or IND units that are on the same side.

     

    If you want to prevent unwanted collateral damage for OPFOR only, the EH handleDamage is a good way. Are you sure you apply it on units you want? Are you spawning them?

     

    For edited ones:

    {
      _x addEventHandler ["HandleDamage",{
        params ["_unit", "", "_damage","_source"];
        if (side _source isEqualTo EAST) then {_damage = 0};
        _damage
      }];
    } forEach units OPFOR;

    If you spawn them, you need to apply the EH on them also.


  9. Hello,

    Not sure to understand your problem.

    If you are sure that the spawned group in named grp_predator, so, I can't see why you couldn't make Yautja1, ..2, ..3 join it. joinSilent is a GA GE command, so you can make it work from anywhere.

    First thing to do is verify this group exists with it's name grp_predator, before you try to join some extra units.

     

    By the way:

    When you spawn a group with another function than yours (if yours, you can easily add a code on it), and if you don't have a name for this group, you need to wait for some group created. The useful event handler, here, is the MEH "groupCreated"

    In init.sqf:

    addMissionEventHandler ["GroupCreated", {

       params ["_group"];

       if (your condition here) then {  do something on this group};

    }];

     


  10. Triggers can be server only. In this case the activation code runs on server only. May need some remote execution for desired effect on another PC (client), depending on how argument(s) and effect(s) work in commands of the code . May be not so handy.

     

    Non-server only triggers are firing locally but the code runs everywhere the condition is met.

    Blufor Present, anyPlayer Present    are met everywhere.

    bob inArea thisTrigger , bob in thisList (need pre-condition like above)   are met everywhere bob is defined (everywhere if variable name in editor)

    but:

    player inArea thisTrigger, player in thisList  fires on player's PC only

     

    Then, the activation code itself is effect global whatever the edited trigger is (see more info : makeGlobal in createTrigger command). That means all PCs will be finally sync about the effect of the code.

    If you need a specific effect on a specific PC (using local effect commands), you need to script the makeGlobal false  version of the createTrigger command.


  11. On 2/16/2024 at 5:10 AM, kibaBG said:

    Hi, I cannot make script work on dedicated. I spawn a boat and want to have the option to push it to the water. 

     

    
    private _actionA = ["<t shadow='2' color='#f5f242'>PUSH</t>", {
    params ["_target", "_caller", "_actionId", "_arguments"];
    _target setVelocity [(sin(direction _caller))*3, (cos(direction _caller))*3, 0];
    },nil, 6, false, true,"", "true", 3,false,"",""];
    [_boat, _actionA] remoteExec ["addAction",[0,-2] select isDedicated,_boat];

    Works in eden but not on dedi.  Similar script for unbuilding the boat is working ok in dedi. 

    
    //works perfectlly on dedicated 
    
    private _actionB =  ["<t shadow='2' color='#f5f242'>UNBUILD</t>", {
    params ["_target", "_caller", "_actionId", "_arguments"];
    deleteVehicle _target;
    },nil, 6, false, true,"","true", 3,false,"",""];
    [_boat, _actionB] remoteExec ["addAction",[0,-2] select isDedicated,_boat];

     

     

    That's because your ship is server local.

    When you remoteExec addaction for all clients, it's OK but the script of action itself stays local: run on client who called the action. As your boat is on server, you need to remoteExec (on server : 2) also each command of this code which have a local Argument (LA), as setVelocity Simple as that.

     

    Note: Now, if you have another player as driver, waiting for your push, he is the owner of the boat. You need to remoteExec setVelocity on his PC, where the boat is owned (target for remote exec is _boat)

    not tested.

    • Like 1

  12. On 2/12/2024 at 3:37 AM, kibaBG said:

    @pierremgi Unfortunately I cannot make your code work ... I am trying to add cool time to radio trigger. 

     

    Schatten's code works for me.

     

    You need to wait for the delta time you set (here 10 sec), even at start.

    Cond. : this && {time - (thisTrigger getVariable ["ActivatedAt",0]) > 10}

     

    example on act: thisTrigger setVariable ["ActivatedAt", time]; hint str time

     

    As said above, my code works only for repeatable triggers except for radio triggers which don't have deactivation code.

     

     


  13.  

    5 hours ago, PrizraK11 said:

    When creating a function to play a sound when a person enters the trigger, I was faced with the question: what if a person constantly leaves and enters back into the trigger, continuously? Accordingly, the sound will also be produced anew each time and the result will be complete nonsense

     

    Question: how can I first check that the sound has played to the end, and then play the same sound again?

     

     

     

    Welcome to forum.

    Which sound? How do you run it (playSound or else)?


  14. With a radio trigger thisList is always equal to [] (there is no preset condition like blufor present), so you can't refer to this variable.

     

    thisTrigger works.

    So, you can sort the units in a trigger area:

    {_x playMoveNow "AmovPercMstpSnopWnopDnop_exercisePushup"} count (allUnits select {_x inArea thisTrigger});

     

    Note: count is little bit faster than forEach... but you must check the inside code don't return a variable. Here playMoveNow returns nothing. So, cool.

    • Thanks 1

  15. A lot of work for something automatic. Groups are divided in "infantry" "armored" "mechanized" "specOps"... just for Vanilla Arma . That get worse with mods and DLCs when authors chose totally different class names. Few of them stick to BI classification.  Furthermore, if you set your custom group, there is no more classification.

    Another way could be a check for type of vehicles in group...

×