Search the Community
Showing results for tags 'EventHandlers'.
Found 8 results
-
Hey all, I am quite new to scripting and have been looking into eventHandlers a bit lately. I stumbled across the scriptedEventHandlers. I am not sure I really understand the concept of a scipted eventHandler against a "normal" eventHandler. So, what exactly is the difference between those two? I mean, that in my understanding (which I believe to be incomplete) both "kinds" of eventHandlers are called when a specific event is happened and if this is the case what is the difference then? 😕 So, the question I am posing here is quite broad, I know, but if there's any good text I could have a look at somewhere online, or a video or some educational material I would really like to have a look. Otherwise if anyone here could throw some clarifications (without having to spend too much time as to write down a full guide on eventHandlers) they would be extremely welcome. Thanks, Achilles.
- 60 replies
-
- 5
-
- script
- scriptedeventhandler
-
(and 1 more)
Tagged with:
-
Help - Adding Event Handler to units spawned with JEBUS
GaryTheNoTrashCougar posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
I have a kill notification script that displays kill type HUD messages (Enemy Killed, Headshot, Long Range Kill, Point Blank Kill, Explosive Kill, Friendly Kill & Suicide), score values & adjusts player rating based on the kill types. The script works with units placed in the editor but I'm struggling to make it work with AI units spawned & respawned using JEBUS, which I think recreates the units placed in the editor. The part which doesn't work is the HitPart Event Handler I'm using to detect explosive kills. I'm guessing 'allUnits' doesn't apply to the units created by JEBUS. Kill_Type.sqf {_x addEventHandler ["HitPart", { (_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"]; if (_target isKindOf "CAManBase") then { if (!isPlayer _target) then { if (isPlayer _shooter) then { if (_isDirect == true) then { killType = "HEADSHOT "; } else { if (_isDirect == false) then { killType = "EXPLOSIVE KILL "; }; }; }; }; }; }];} forEach allUnits; Other script that calls this script: Kill_Reward.sqf player addEventHandler ["Handlescore", {false}]; execVM "Kill_Reward\Kill_Type.sqf"; killMessage = { _messages = _this; _ratingScore = 0; _messageContent = "<t align='right' size='1.25'>"; { _scoreName = _x select 0; _ratingScore = _ratingScore + 200; _messageContent = _messageContent + format ["<t font='PuristaSemibold'>%1</t>%2<br/>", _scoreName]; } forEach _messages; _messageContent = _messageContent + "</t>"; if (_ratingScore >= 0) then { _messageContent = _messageContent + (format ["<t align='right' color='#ffff00' font='PuristaBold' size='1.4'>+%1</t>", _ratingScore]); }; [ parseText _messageContent, [safezoneX, safezoneY + safeZoneH * 0.55, safezoneW * 0.62, safeZoneH * 0.57], nil, 1, 0.7, 0 ] spawn BIS_fnc_textTiles;}; headshotKillMessage = { _messages = _this; _ratingScore = 0; _messageContent = "<t align='right' size='1.25'>"; { _scoreName = _x select 0; _ratingScore = _ratingScore + 250; _messageContent = _messageContent + format ["<t font='PuristaSemibold'>%1</t>%2<br/>", _scoreName]; } forEach _messages; _messageContent = _messageContent + "</t>"; if (_ratingScore >= 0) then { _messageContent = _messageContent + (format ["<t align='right' color='#ffff00' font='PuristaBold' size='1.4'>+%1</t>", _ratingScore]); }; [ parseText _messageContent, [safezoneX, safezoneY + safeZoneH * 0.55, safezoneW * 0.62, safeZoneH * 0.57], nil, 1, 0.7, 0 ] spawn BIS_fnc_textTiles;}; LRheadshotKillMessage = { _messages = _this; _ratingScore = 0; _messageContent = "<t align='right' size='1.25'>"; { _scoreName = _x select 0; _ratingScore = _ratingScore + 300; _messageContent = _messageContent + format ["<t font='PuristaSemibold'>%1</t>%2<br/>", _scoreName]; } forEach _messages; _messageContent = _messageContent + "</t>"; if (_ratingScore >= 0) then { _messageContent = _messageContent + (format ["<t align='right' color='#ffff00' font='PuristaBold' size='1.4'>+%1</t>", _ratingScore]); }; [ parseText _messageContent, [safezoneX, safezoneY + safeZoneH * 0.55, safezoneW * 0.62, safeZoneH * 0.57], nil, 1, 0.7, 0 ] spawn BIS_fnc_textTiles;}; CQBheadshotKillMessage = { _messages = _this; _ratingScore = 0; _messageContent = "<t align='right' size='1.25'>"; { _scoreName = _x select 0; _ratingScore = _ratingScore + 275; _messageContent = _messageContent + format ["<t font='PuristaSemibold'>%1</t>%2<br/>", _scoreName]; } forEach _messages; _messageContent = _messageContent + "</t>"; if (_ratingScore >= 0) then { _messageContent = _messageContent + (format ["<t align='right' color='#ffff00' font='PuristaBold' size='1.4'>+%1</t>", _ratingScore]); }; [ parseText _messageContent, [safezoneX, safezoneY + safeZoneH * 0.55, safezoneW * 0.62, safeZoneH * 0.57], nil, 1, 0.7, 0 ] spawn BIS_fnc_textTiles;}; longRangeMessage = { _messages = _this; _ratingScore = 0; _messageContent = "<t align='right' size='1.25'>"; { _scoreName = _x select 0; _ratingScore = _ratingScore + 250; _messageContent = _messageContent + format ["<t font='PuristaSemibold'>%1</t>%2<br/>", _scoreName]; } forEach _messages; _messageContent = _messageContent + "</t>"; if (_ratingScore >= 0) then { _messageContent = _messageContent + (format ["<t align='right' color='#ffff00' font='PuristaBold' size='1.4'>+%1</t>", _ratingScore]); }; [ parseText _messageContent, [safezoneX, safezoneY + safeZoneH * 0.55, safezoneW * 0.62, safeZoneH * 0.57], nil, 1, 0.7, 0 ] spawn BIS_fnc_textTiles;}; CQBMessage = { _messages = _this; _ratingScore = 0; _messageContent = "<t align='right' size='1.25'>"; { _scoreName = _x select 0; _ratingScore = _ratingScore + 225; _messageContent = _messageContent + format ["<t font='PuristaSemibold'>%1</t>%2<br/>", _scoreName]; } forEach _messages; _messageContent = _messageContent + "</t>"; if (_ratingScore >= 0) then { _messageContent = _messageContent + (format ["<t align='right' color='#ffff00' font='PuristaBold' size='1.4'>+%1</t>", _ratingScore]); }; [ parseText _messageContent, [safezoneX, safezoneY + safeZoneH * 0.55, safezoneW * 0.62, safeZoneH * 0.57], nil, 1, 0.7, 0 ] spawn BIS_fnc_textTiles;}; addMissionEventHandler ["EntityKilled", { params ["_killed", "_killer"]; _headDamage = _killed getHitPointDamage "HitHead"; _distance = _killer distance _killed; _minDistance = 100; _cqbDistance = 2; if (isNull _instigator) then { _instigator = _killer }; if (_killed isKindOf "CAManBase" && {((side group _killed) == east)}) then { if (isPlayer _killer) then { if (_distance >= _minDistance && ({_headDamage >= 1;})) then { player addPlayerScores [1, 0, 0, 0, 0]; player addRating 100; [[killType, _ratingScore]] call LRheadshotKillMessage; } else { if (_distance <= _cqbDistance && ({_headDamage >= 1;})) then { player addPlayerScores [1, 0, 0, 0, 0]; player addRating 75; [[killType, _ratingScore]] call CQBheadshotKillMessage; } else { player addPlayerScores [1, 0, 0, 0, 0]; player addRating 50; [[killType, _ratingScore]] call headshotKillMessage; }; if (isPlayer _killer && ({_headDamage < 1;})) then { if (_distance >= _minDistance) then { player addPlayerScores [1, 0, 0, 0, 0]; player addRating 50; [["LONG RANGE KILL ", _ratingScore]] call longRangeMessage; } else { if (_distance <= _cqbDistance) then { player addPlayerScores [1, 0, 0, 0, 0]; player addRating 25; [["POINT BLANK KILL ", _ratingScore]] call CQBMessage; } else { player addPlayerScores [1, 0, 0, 0, 0]; [["ENEMY KILLED ", _ratingScore]] call killMessage; }; }; }; }; }; }; }]; friendlyKillMessage = { _messages = _this; _ratingScore = 0; _messageContent = "<t align='right' size='1.25'>"; { _scoreName = _x select 0; _ratingScore = _ratingScore + 1000; _messageContent = _messageContent + format ["<t font='PuristaSemibold'>%1</t>%2<br/>", toUpper _scoreName]; } forEach _messages; _messageContent = _messageContent + "</t>"; if (_ratingScore >= 0) then { _messageContent = _messageContent + (format ["<t align='right' color='#ea0000' font='PuristaBold' size='1.4'>-%1</t>", _ratingScore]); }; [ parseText _messageContent, [safezoneX, safezoneY + safeZoneH * 0.55, safezoneW * 0.62, safeZoneH * 0.57], nil, 1, 0.7, 0 ] spawn BIS_fnc_textTiles;}; addMissionEventHandler ["EntityKilled", { params ["_killed", "_killer"]; if (isNull _instigator) then {_instigator = _killer}; // player driven vehicle road kill if (_killed isKindOf "CAManBase" && {((side group _killed) == west)}) then { if (!isPlayer _killed) then { if (isPlayer _killer) then { player addPlayerScores [0, 0, 0, 0, 0]; [["FRIENDLY KILLED ", _ratingScore]] call friendlyKillMessage; }; }; }; }]; suicideMessage = { _messages = _this; _ratingScore = 0; _messageContent = "<t align='right' size='1.25'>"; { _scoreName = _x select 0; _ratingScore = _ratingScore - 200; _messageContent = _messageContent + format ["<t font='PuristaSemibold'>%1</t>%2<br/>", toUpper _scoreName]; } forEach _messages; _messageContent = _messageContent + "</t>"; if (_ratingScore >= 0) then { _messageContent = _messageContent + (format ["<t align='right' color='#ffff00' font='PuristaBold' size='1.4'>+%1</t>", _ratingScore]); }; [ parseText _messageContent, [safezoneX, safezoneY + safeZoneH * 0.55, safezoneW * 0.62, safeZoneH * 0.57], nil, 1, 0.7, 0 ] spawn BIS_fnc_textTiles;}; sleep 0.5; addMissionEventHandler ["EntityKilled", { params ["_killed", "_killer"]; if (isNull _instigator) then {_instigator = _killer}; // player driven vehicle road kill if (_killed isKindOf "CAManBase" && {(isPlayer _killed)} && {(isPlayer _killer)}) then { player addPlayerScores [0, 0, 0, 0, 0]; [["SUICIDE ", _ratingScore]] call suicideMessage; }; }]; If anyone can help me with this probably very simple issue, I'll send you a cookie.- 1 reply
-
- eventhandlers
- sqf
-
(and 3 more)
Tagged with:
-
Hello people, I am having a really frustrating problem with the "IncomingMissile" EH. The EH works fine when an AI is engaging player vehicle, when AI engages AI vehicle but NOT when player engages AI vehicle. I did some searching in the forums and apparently the was some problem with this EH back in OFP days so I have tried multiple ways of localizing the EH. I have tried the init, CBA class eventhandler system and adding the EH to unit via extended_preInit_eventHandlers. All methods share the same problem. So far I have not even bothered with a dedicated environment so this has been all local. For reference here is the code I am running (I am using CBA and Ace if that is relevant): this addEventHandler ["IncomingMissile", {params ["_target", "_ammo", "_vehicle", "_instigator"];[_target, "SmokeLauncher"] call BIS_fnc_fire;}]
-
bisobjectbug add(MP)EventHandler not working on Dedicated Server
PaxJaromeMalues posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello folks, I am currently working on a mission designed for training puposes. The mission is build upon the OlsenFramework, a mission making framework. Links are to either githubs. I am running into the following problem: a) If I test the mission in the Eden Editors host environment and singleplayer, all code executes flawslessly when addEventHandler is used (obviously no MP). b) When tested on a dedicated server, the EventHandlers (addEventHandler and addMPEventhandler) will not fire at all. This was tested via systemChat messages. The code: (All code can be viewed on the github linked, its the latest changes made and the last version tested on the server) A few months back I was given a script by my units training officer to work with popup targets but it was split in a multitude of files and also only worked partially on dedicated, which I did not like so I rewrote it into a single script. The origin of that code is not known to me, so forgive me for the missing credits. In the init.sqf of the mission, I call code which adds a line of code to each targets which apparently is supposed to 'fix' swivel targets not working in multiplayer dedicated environments. This can be found here. As far as I unterstand this is supposed to disable animation control on all clients (including non dedicated servers and HC), but sofar the targets still behave crappy. if (!isDedicated) then { _localTargets = (entities "Target_Swivel_01_ground_F") + (entities "Land_Target_Swivel_01_F"); { _x setVariable ["BIS_exitScript", false]; } forEach _localTargets; }; later I call my script which is mainly in control of the targets: popup.sqf once via the init.sqf to get all targets into a down position at mission start. This works flawless. Fnc_popup is the same as popup.sqf just processed via: Fnc_popup = compile preprocessFileLineNumbers "customization\popups.sqf"; if (isServer) then { [false,"init",500,initCenter] remoteExec ["Fnc_popup", 2]; }; Players being Instructors are makred via a variable "isInstructor" only players with this restriction will have access to the popup addAction ... actions. Which are placed on landBoards in the mission. en example from the addAction.sqf looks like this: Fnc_popup = compile preprocessFileLineNumbers "customization\popups.sqf"; if (!isDedicated) then { waitUntil { (player == player) }; if (player getVariable "isInstructor") then { arBoard addAction ["<t color='#FF0000'>Raise Bunker Targets",{[true,"setup",15,bnkTgts] remoteExec ["Fnc_popup", 2];}]; arBoard addAction ["<t color='#FF0000'>Lower Bunker Targets",{[false,"reset",15,bnkTgts] remoteExec ["Fnc_popup", 2];}]; }; }; This calls a precompiled form of popup.sqf and now the problöem occurs that everything in that popup.sqf works, except for the damn eventHandlers place on the trainingTargets. case init and case reset work, and throw no script errors. This is the popup.sqf file content: /////////////////////////////////////////////////////////////////////////////////////////// //Script to be called by inits or scripts for operating swivel and popup //targets around a specified object "_center". //params: [ShouldTargetsAutoPop?,WhichSwitchShouldRun?,WhatDistanceFromObject?,WhatObject?] //By PaxJaromeMalues /////////////////////////////////////////////////////////////////////////////////////////// params [["_popenabled",false],["_execution","init"],["_dist",25],["_center",initCenter]]; _targets = nearestObjects [position _center, ["TargetBase"], _dist]; _SwivelTargets = nearestObjects [position _center, ["Target_Swivel_01_base_F"], _dist]; switch (_execution) do { case "init": { { _x setVariable ["nopop", true]; _x animateSource ["terc",1] } forEach _targets; { _x setVariable ["BIS_poppingEnabled", false]; _x animateSource ["terc",1]; } forEach _SwivelTargets; }; case "setup": { "setup called" remoteExec ["systemChat"]; if (_popenabled) then { "popup first condition" remoteExec ["systemChat"]; { _x animateSource ["terc",0]; _x addMPEventHandler [ "MPHit", { "popup first condition EH before CBA" remoteExec ["systemChat"]; (_this select 0) animateSource ["terc",1]; [{ (_this select 0) animateSource ["terc",0]; "popup first condition EH in CBA" remoteExec ["systemChat"]; }, _this, 2 + (random 3)] call CBA_fnc_waitAndExecute; } ] } forEach _targets; } else { "popup second condition" remoteExec ["systemChat"]; { _x animateSource ["terc",0]; _x addMPEventHandler [ "MPHit", { (_this select 0) animateSource ["terc",1]; (_this select 0) removeEventHandler ["MPHit",0]; } ] } forEach _targets; }; if (_popenabled) then { "swivel first condition" remoteExec ["systemChat"]; { _x animateSource ["terc",0]; _x addMPEventHandler [ "MPHitPart", { ((_this select 0) select 0) animateSource ["terc",1]; [{ ((_this select 0) select 0) animateSource ["terc",0]; }, _this, 2 + (random 3)] call CBA_fnc_waitAndExecute; } ] } forEach _SwivelTargets; } else { "swivel second condition" remoteExec ["systemChat"]; { _x animateSource ["terc",0]; _x addMPEventHandler [ "MPHitPart", { ((_this select 0) select 0) animateSource ["terc",1]; ((_this select 0) select 0) removeEventHandler ["MPHit",0]; } ] } forEach _SwivelTargets; }; }; case "reset": { "reset called" remoteExec ["systemChat"]; { _x removeEventHandler ["MPHit",0]; _x animateSource ["terc",1]; } forEach _targets; { _x animateSource ["terc",1]; _x RemoveEventHandler ["MPHitPart",0]; } forEach _SwivelTargets; }; }; I have been sitting at this problem for over a month now, and have no idea what I am doing wrong here. Pls help.- 46 replies
-
- 1
-
Hey! If I want to add eventHandlers to: EDIT: class CfgVehicles { class Man; class CAManBase: Man { class EventHandlers { addEventHandler ["GetInMan", {[player] call Salmon_fnc_function}]; addEventHandler ["GetOutMan", {[player] call Salmon_fnc_function}] }; }; }; How would I go about doing that? I want to call a function every time a player with the mod loaded gets in or out of a vehicle.
- 3 replies
-
- eventhandlers
- config
-
(and 1 more)
Tagged with:
-
How to use EventHandlers init in a mod?
SenkiAlfonz posted a topic in ARMA 3 - ADDONS - CONFIGS & SCRIPTING
Hi, I am fairly new to modding, so I don't understand too much yet. I searched the forums but not found much info about this. I made a script which adds a "HandleDamage" eventHandler and some code in it to a unit. I want to add this script to every man class unit created either on mission init or spawned later. Actually on mission start I can do it with a simple '{} forEach allUnits', but I have troubel with the spawned ones. I think it would be the best to add the code to every units init field. As I understand the eventHandler init should do the trick but I dont really understand how shold I set it up. Sofar I've tried to add this to my mods config.cpp class CfgVehicles { class EventHandlers { class Man; { init = "systemChat format ["Man created: %1", _this]"; }; }; }; Of course I would put run a 'fnc_somescript.sqf', but first I just tried to display a text for testing purposes. Could someone explain how this should work? Or show alterntive ways to run script for every man created. Thanks.- 8 replies
-
- eventhandlers
- init
-
(and 1 more)
Tagged with:
-
Event handlers or script start for specific classes
Ivanoff.N posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
I am trying to make an addon that will make a small hud appear as soon as you enter particular vehicle. I have made the hud itself via script using rsctext. I only need the code for the init.sqf so that: 1) playable unit enters mortar as gunner (only mortar no other vehicle) - script starts 2) playable unit exits mortar - script stops I need this to work with all mortars placed on the map for all playable units, without any naming etc. (of course each player must see the hud individually). Please advise if it is possible to do and the code to do it if possible. Thank you, -
Troubles with "GetInMan" and "GetOutMan" event Handlers.
willithappen posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi all, Im trying to create a very simple log system to find out when a player gets in and out of a vehicle of a certain type. I have the below executed from initPlayerLocal. I have tried a few different combinations of player in the init and in the script itself with no success. The problem is weird as the Killed event handler works perfectly fine and displays output in the .rpt file. both GetIn/GetOut eventHandlers do nothing, there is no error nor log placed in the .rpt. What am I doing wrong? player execVM "WH_Logging.sqf"; WH_Logging.sqf // Kills - NAME Killed by NAME _this addEventHandler ["Killed", "diag_log format ['[--WH Logs--][**KILLS**]%1 Killed by %2',_this select 0,_this select 1]"]; // Vehicle GetIn/GetOut Logs - NAME SEAT VEHICLE _this addEventHandler ["GetInMan", "diag_log format ['[--WH Logs--][**GETIN**]%1 Enters %3 in %2 Seat',_this select 0,_this select 1,_this select 2]"]; _this addEventHandler ["GetOutMan", "diag_log format ['[--WH Logs--][**GETOUT**]%1 Exits %3 From %2 Seat',_this select 0,_this select 1,_this select 2]"];