User Tools

Site Tools


arma2:scripting:addpublicvariableeventhandler

ArmA 2 addPublicVariableEventhandler

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.

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.

arma2/scripting/addpublicvariableeventhandler.txt · Last modified: 2024/08/01 22:16 by snakeman

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

All PMC web site download services are temporarily suspended until web site yearly fees have been recovered, want to download addons/mods? Then Support PMC.

If you are grateful for all the work PMC has done in the past 25 years, use Support PMC page.