Comrades in Arms Discussion Board
Custom actions; show text to a specific player only - Printable Version

+- Comrades in Arms Discussion Board (http://forum.ciahome.net)
+-- Forum: Comrades in Arms Life (http://forum.ciahome.net/forumdisplay.php?fid=3)
+--- Forum: Mission Making (http://forum.ciahome.net/forumdisplay.php?fid=8)
+--- Thread: Custom actions; show text to a specific player only (/showthread.php?tid=3298)



Custom actions; show text to a specific player only - Suchy - 02-11-2016

I have a problem with custom action. I've added an action to an object in a MP-compatible way:

Code:
addActionMP =
{
    private["_object","_screenMsg","_scriptToCall"];
    _object = _this select 0;
    _screenMsg = _this select 1;
    _scriptToCall = _this select 2;

    if(isNull _object) exitWith {};

    _object addAction [_screenMsg,_scriptToCall, nil,10,true,true,"","_this distance _target < 3"];
};

Now inside the script called when the action is executed...

1. How cen I get the player that triggered this action?
2. How can I display a text, either via hint or cutText to this player only?




Re: Custom actions; show text to a specific player only - Alwarren - 02-11-2016

_this select 1 in the action script is usually the unit that activated the action.

The effect of the script is local, so it SHOULD be running on the unit's machine only to be sure, you can use something like

Code:
if (local (_this select 1)) then {
   Hint "Fire and Blood!";
};




Re: Custom actions; show text to a specific player only - Suchy - 02-11-2016

Thanks. So far I used "player" instead of _this select 1, not sure if correctly, but worked for me. When testing in SP. As for the hint to specific player I found some good info here https://forums.bistudio.com/topic/143835-hint-to-just-one-playervehicle/
and after slight modification got it working with:

Code:
rHINT = [];
fnc_rHINT = {

    private ["_player","_message"];

    _player = _this select 0;

    if(!local _player) exitWith {};

    _message = _this select 1;

    if (!isNull _player && {local _player}) then {

        hint _message;

    };

};
"rHINT" addPublicVariableEventHandler {(_this select 1) call fnc_rHINT;};

calling it from action script with
Code:
rHINT = [_this select 1, "local message"];
rHINT call fnc_rHINT;