====== ArmA 2 addPublicVariableEventhandler ======
[[https://www.pmctactical.org/forum/viewforum.php?f=50|ArmA 2 Forum]], [[:arma2|ArmA 2 Home]], [[arma2:config|ArmA 2 Config]], [[arma2:file_formats|ArmA 2 File Formats]], [[arma2:missions|ArmA 2 Missions]], [[arma2:modeling|ArmA 2 3D Modeling]], [[arma2:scripting|ArmA 2 Scripting]], [[arma2:terrain|ArmA 2 Terrain]], [[arma2:texturing|ArmA 2 Texturing]], [[arma2:tools|ArmA 2 Tools]]
Quick **addPublicVariableEventhandler** example.
This was done to have marker placed on map when aircraft crashes.
If you are client, you get this marker, but if you JIP after this has been created, you wont see it.
**init.sqf**
"PMC_Downed_Aircraft" addPublicVariableEventhandler
{
private ["_markerobj", "_m"];
_m = format ["PMC_Aircraft_%1", (round random 1000)];
_markerobj = createMarkerLocal [_m, getPos (_this select 1)];
_markerobj setMarkerTypeLocal "mil_pickup";
_markerobj setMarkerColorLocal "ColorBlue";
_markerobj setMarkerTextLocal format ["%1", _m];
hint "Downed Aircraft Marker Placed!\n\nCheck map.";
[_m] spawn { sleep 1800; (_this select 0) setMarkerColorLocal "ColorBlack"; sleep 1800; deleteMarker (_this select 0); };
};
Then just call it by giving the variable the aircraft vehicle name and publicVariable it, like this:
PMC_Downed_Aircraft = _vcl;
publicVariable "PMC_Downed_Aircraft";
Put that somewhere that detects the aircraft being shot down, perhaps in killed eventhandler or other script.
Easy.
====== ArmA 2 Global Broadcast ======
"PMC_Hint" addPublicVariableEventHandler
{
hint format["%1", (_this select 1)];
};
Then use it like:
PMC_Hint = "Hello world!";
And hello world is displayed as hint on every client. Very simple way to show hints from server to clients.