Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
sxp2high

addAction Local Problem

Recommended Posts

Hello,

i need some help with this. I stuck on this for days. I searched the forums a lot and tried a lot of things but nothing worked.

OK. I want to add a Action to all players in MP. This action should be only visible to the player itself. This is working so far.

Now the problem. The script called by the action is only local. More specific:

The script contains a "say" and a "sideChat". But only the player that is executing the action can hear and read it.

This is how i add it:

player addAction [("<t color=""#cdfdff"">" + ("Need Medic") + "</t>"), "NeedMedic.sqf", [], -2012, false, false, "", "vehicle _target == player"];

And this is what the script contains:

_unit = _this select 0;

(_unit) say ["NeedMedic",1];

_unit sideChat "I need a Medic!";

I want the sideChat and say to be global, for all players.

I know this is very easy stuff for a lot of guys around here - pleeeease help me!! :)

Share this post


Link to post
Share on other sites

2 ways:

  1. setVehicleInit:
    _unit = _this select 0;
    _unit setVehicleInit "
       this say ['NeedMedic',1];
       this sideChat 'I need a Medic!';
    "; processInitCommands; 
    


    It's the easier way. Drawback: setVehicleInit code is stored and transferred to join in progress (jip) players. So it is likely that a player who joins in progress will get tons of "i need a medic" messages and, what's even more problematic: the amount data to transfer to the jip player grows and grows. However, if you're creating a mission without jip/respawn etc., this is pretty much all you need.

  2. publicVariable/-EventHandler:
    _unit = _this select 0;
    (_unit) say ["NeedMedic",1];
    _unit sideChat "I need a Medic!";
    soldier_needs_medic = _unit; publicVariable "soldier_needs_medic";
    


    The "soldier_needs_medic" of course is something you can choose by yourself.
    You also have to write the following into your Init.sqf:

    "soldier_needs_medic" addpublicVariableEventHandler {
      _unit = _this select 1;
      _unit say ["NeedMedic",1];
      _unit sideChat "I need a Medic!";
    };
    


Share this post


Link to post
Share on other sites

Yay, sounds perfect ...it's with jip and respawn.

Thank you very much for the quick response. I'll check this out!

:yay:

Share this post


Link to post
Share on other sites

What I have often done would be to have the only actions in "NeedMedic.sqf" be to make a variable true and public, and then have a trigger on the map that, when that variable is detected to be true, execute the intended commands. That would be an alternative to Bon's second option.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×