ArmA 2 Forum, ArmA 2 Home, ArmA 2 Config, ArmA 2 File Formats, ArmA 2 Missions, ArmA 2 3D Modeling, ArmA 2 Scripting, ArmA 2 Terrain, ArmA 2 Texturing, 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.
"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.