-
Content Count
14 -
Joined
-
Last visited
-
Medals
Community Reputation
0 NeutralAbout GaryTheNoTrashCougar
-
Rank
Private First Class
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
GaryTheNoTrashCougar started following Help - Adding Event Handler to units spawned with JEBUS, Preload Textures for HUD?, Extend/reset sleep timer? and and 3 others
-
help Preload Textures for HUD?
GaryTheNoTrashCougar posted a topic in ARMA 3 - ADDONS - CONFIGS & SCRIPTING
I have an issue with a health bar HUD I have made. The texture changes based on the variable and the first time a texture is loaded the HUD flickers. Once each texture has been called it no longer flickers, assuming it is now in memory. _health = round ((1 - (damage player)) * 100); ((uiNamespace getVariable "Health_Status") displayCtrl 91997) ctrlSetStructuredText parseText format ["<img valign='middle' size='0.5' image='\Health_Status\data\health_%1.paa'/>", _health]; The texture files are 128x128 .paa converted from .png using ImageToPAA. Is it possible to preload these textures? I know you can preloadTitleRsc but the texture paths are loaded by the script and not the RscTitles class. Any help please? 🙃 -
Extend/reset sleep timer?
GaryTheNoTrashCougar replied to GaryTheNoTrashCougar's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Doesn't seem to change anything, the 'killType' shows on the first kill, which wasn't the problem, it's the score returning 0. I think it has something to do with the score array 'scoreArr' , perhaps the placement of it or the formula for summing up the values. It works when I separate it from the 'killType' notification, but then the notification doesn't show. I'm guessing because you can't have 2 BIS_fnc_textTiles running because if I disable the score the notification shows & vice versa. Score works when I have this in the Entity Killed EH: if (ratingScore > 0) then { if (([0] call BIS_fnc_countdown) <= 0) then {total = 0;}; [4, false] call BIS_fnc_countdown; [] spawn { scoreArr pushBack ratingScore; {total = (_x + total)} forEach scoreArr; scoreArr call scoreMsg; scoreArr = []; }; }; Then scoreMsg is: scoreMsg = {[parseText format ["<t align='right' color='#ffff00' font='PuristaBold' size='1.4'>+%1</t>", total], [safezoneX, safezoneY + safeZoneH * 0.62, safezoneW * 0.475, safeZoneH * 1], nil, 3, 0.7, 0] spawn BIS_fnc_textTiles;}; Another option could be to use a different code for the notifications. It's not mine though, found it on a thread for a kill feed a while back. It's nice but it opens up another out of date bottle of Tobasco sauce. I adapted it to work for my killTypes, but for some reason if you get 2 or more kills at the exact same time (explosive kills mainly), the notifications don't animate & refuse to be deleted, then any notifications after just intersect. Using a ctrlSetFade makes them disappear but technically they're still there & cause performance issues if they build up. Here's the code anyway should you know why it happens: killMsg = { private _text = format ["%1", killType]; disableSerialization; { _ctrl = (findDisplay 46) displayCtrl _x; _pos = ctrlPosition _ctrl; _pos set [1, (_pos select 1) + 0.04]; _ctrl ctrlSetPosition _pos; _ctrl ctrlCommit 0.25; } forEach actKillCtrls; sleep 0.25; _ctrl = (findDisplay 46) ctrlCreate ["RscText", _this select 0]; _ctrl ctrlSetPosition [0.48 * safezoneW + safezoneX, 0.138 * safezoneH + safezoneY, 1 * safezoneW, 1 * safezoneH]; _ctrl ctrlSetFont "PuristaSemibold"; _ctrl ctrlSetFontHeight 0.05; _ctrl ctrlSetTextColor [1, 1, 1, 1]; _ctrl ctrlSetText _text; _ctrl ctrlCommit 0; 0 = (_this select 0) spawn { disableSerialization; _ctrl = (findDisplay 46) displayCtrl _this; sleep 4; ctrlDelete _ctrl; actKillCtrls = actKillCtrls - [_this]; }; actKillCtrls = [_this select 0] + actKillCtrls; killCtrl = killCtrl + 1; }; Outside of this code is defined: killCtrl = 2000; actScoreCtrls = []; Then the code to call: [killCtrl, _this select 0] spawn killMsg; I appreciate you taking time to try & help. Thank you! -
Extend/reset sleep timer?
GaryTheNoTrashCougar replied to GaryTheNoTrashCougar's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Might be best to show you what I have, I'm sure it could use some serious refactoring. I'll play the noob card here as I've only been doing this sort of thing in what little free time I've had for about the last 8 months. Still learning. I initially had a 'scoreMsg' to display the score but I thought it best to try to include it in the 'killMsg' for the ability to change the position on the screen easily if needed. Reason being this is actually part of a mod I have on the workshop 'Kill Confirmed', which uses CBA setting so users can customize it to their liking. The problem I'm having now is the first kill when the countdown starts presents 0 score. Maybe you might be able to see where I've gone wrong? Seems the score shown on the second kill is the score for the first kill if that makes sense. initPlayerLocal.sqf [] execVM "Kill_Confirmed.sqf"; Kill_Confirmed.sqf sleep 0.5; ratingScore = []; assists = 0; scoreArr = []; total = 0; #include "killMsg.sqf" #include "EntityKilled.sqf" #include "HitPart.sqf" #include "HandleDamage.sqf" killMsg.sqf killMsg = { private _messages = _this; private _messageContent = "<t align='right'>"; { _messageContent = _messageContent + format ["<t font='PuristaSemibold' size='1.25'>%1</t><br/>", killType]; } forEach _messages; _messageContent = _messageContent + "</t>"; if (ratingScore > 0) then { if (([0] call BIS_fnc_countdown) <= 0) then {total = 0;}; [4, false] call BIS_fnc_countdown; [] spawn { scoreArr pushBack ratingScore; {total = (_x + total)} forEach scoreArr; scoreArr = []; }; _messageContent = _messageContent + (format ["<t align='right' color='#ffff00' font='PuristaBold' size='1.4'>+%1</t>", total]); }; [parseText _messageContent, [safezoneX, safezoneY + safeZoneH * 0.51, safezoneW * 0.62, safeZoneH * 0.57], nil, 3, 0.7, 0] spawn BIS_fnc_textTiles; }; EntityKilled.sqf addMissionEventHandler ["EntityKilled", { params ["_killed", "_killer", "_instigator"]; if(!local player) exitWith {}; isFriendly = [(side group _killer),(side group _killed)] call BIS_fnc_sideIsFriendly; private _distance = _killer distance _killed; private _minDistance = 100; private _cqbDistance = 2; private _assisters = (_killed getVariable ["shooterIndex",[]]) - [_instigator, objNull]; _assisters = if (_assisters isEqualTo []) then [{""},{format ["assisters: %1", _assisters apply {name _x}] }]; kill = {[[killType]] call killMsg;}; if (isNull _instigator) then { _instigator = _killer; }; if (((driver (vehicle player)) isEqualTo player) && (player isEqualTo _killer)) then { if (((vehicle player isKindOf "LandVehicle") || (vehicle player isKindOf "Air") || (vehicle player isKindOf "Ship")) && (_killed isKindOf "CAManBase")) then { if !(isFriendly) then { killType = "ROAD KILL"; ratingScore = 50; player spawn kill; }; } else { if ((!(vehicle player isKindOf "LandVehicle") && !(vehicle player isKindOf "Air") && !(vehicle player isKindOf "Ship")) && (_killed isKindOf "CAManBase")) then { if !(isFriendly) then { if (head) then { if (_distance >= _minDistance) then { killType = "HEADSHOT"; ratingScore = 200; player spawn kill; } else { if (_distance <= _cqbDistance) then { killType = "HEADSHOT"; ratingScore = 175; player spawn kill; } else { if ((_distance > _cqbDistance && {_distance < _minDistance})) then { killType = "HEADSHOT"; ratingScore = 150; player spawn kill; }; }; }; } else { if !(head) then { if !(frag) then { if (_distance >= _minDistance) then { killType = "LONG RANGE KILL"; ratingScore = 150; player spawn kill; } else { if (_distance <= _cqbDistance) then { killType = "POINT BLANK KILL"; ratingScore = 125; player spawn kill; } else { if ((_distance > _cqbDistance && {_distance < _minDistance})) then { killType = "ENEMY KILLED"; ratingScore = 100; player spawn kill; }; }; }; } else { if (frag) then { if (_distance >= _minDistance) then { killType = "EXPLOSIVE KILL"; ratingScore = 150; player spawn kill; } else { if (_distance <= _cqbDistance) then { killType = "EXPLOSIVE KILL"; ratingScore = 125; player spawn kill; } else { if ((_distance > _cqbDistance && {_distance < _minDistance})) then { killType = "EXPLOSIVE KILL"; ratingScore = 100; player spawn kill; }; }; }; }; }; }; }; }; }; }; }; if (vehicle player isEqualTo _killer) then { if (((vehicle player isKindOf "LandVehicle") || (vehicle player isKindOf "Air") || (vehicle player isKindOf "Ship")) && (_killed isKindOf "CAManBase")) then { if !(isFriendly) then { killType = "VEHICLE KILL"; ratingScore = 50; player spawn kill; }; }; }; if ((player in (UAVControl vehicle _killer)) && (_killed isKindOf "CAManBase")) then { if !(isFriendly) then { killType = "DRONE KILL"; ratingScore = 50; player spawn kill; }; }; if (!((driver (vehicle player)) isEqualTo _killer) && {!(player isEqualTo _killed)}) then { if (name player in _assisters) then { if !(isFriendly) then { killType = "ASSIST"; ratingScore = 20; assists = assists + 1; player spawn kill; }; }; }; }]; HitPart.sqf 0 = [] spawn { while {true} do { { _x addEventHandler ["HitPart", { (_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"]; head = ("head" in (_this select 0 select 5)); frag = (_isDirect isEqualTo false); }]; _x setVariable ["passedThatHitPart",TRUE]; } forEach (allUnits select {isNil {_x getVariable "passedThatHitPart"}}); sleep 2; }; }; HandleDamage.sqf 0 = [] spawn { while {true} do { { _x setVariable ["shooterIndex",[]]; _x addEventHandler ["HandleDamage", { params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; (_unit getVariable "shooterIndex") pushBackUnique _instigator; _damage }]; _x setVariable ["passedThatHandleDamage",TRUE]; } forEach (allUnits select {isNil {_x getVariable "passedThatHandleDamage"}}); sleep 2; }; }; -
Extend/reset sleep timer?
GaryTheNoTrashCougar replied to GaryTheNoTrashCougar's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Got it, doesn't seem to read timeLeft variable. Doing it like this works: if (ratingScore > 0) then { if (([0] call BIS_fnc_countdown) <= 0) then {total = 0;}; [5, false] call BIS_fnc_countdown; [] spawn { scoreArr pushBack ratingScore; {total = (_x + total)} forEach scoreArr; scoreArr call scoreMsg; scoreArr = []; }; }; If there is a better / more optimized way of doing this your help will be much appreciated. -
Extend/reset sleep timer?
GaryTheNoTrashCougar replied to GaryTheNoTrashCougar's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Think I may have found a way using countdown function. timeLeft = [0] call BIS_fnc_countdown; Now I have a variable that counts down to 0 then resets to 5 when I get a kill. if (ratingScore > 0) then { [5, false] call BIS_fnc_countdown; [] spawn { if (timeLeft <= 0) exitWith {total = 0}; scoreArr pushBack ratingScore; {total = (_x + total)} forEach scoreArr; scoreArr call scoreMsg; scoreArr = []; }; }; Only problem now is the score does not display at all 😞 -
Extend/reset sleep timer?
GaryTheNoTrashCougar replied to GaryTheNoTrashCougar's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I have tried something like this but I can't get it to work. I'm obviously doing it wrong. New variable, sleepDelay = 0; Then on each kill, sleepDelay = sleepDelay + 5; Then in code, sleep sleepDelay; This just has the exact same effect as with sleep 5. The thing is though I don't want to keep adding time, I just want it so if the sleep timer hasn't reached zero yet & another kill is made then the sleep timer resets to 5. So on each kill, sleepDelay = 5; Then maybe something like this: if (ratingScore > 0) then { [] spawn { if (sleepDelay <= 0) exitWith {total = 0}; scoreArr pushBack ratingScore; {total = (_x + total)} forEach scoreArr; scoreArr call scoreMsg; scoreArr = []; sleep sleepDelay; }; }; The only thing is sleepDelay doesn't count down within it's variable, it's always 5 so is there a way to maybe count this down or return the sleep value? -
Extend/reset sleep timer?
GaryTheNoTrashCougar posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
I have a script that displays score based on how the player kills an enemy using a Killed EH. I would like the score that is displayed to add up for 5 seconds after a kill, resetting the timer back to 5 seconds if another kill is made (continuing to add up score), then have the score reset to 0 if the timer runs out. I have something that kind of works but I'm struggling to do the timer bit. Score earned is defined by 'ratingScore'. Message is displayed by 'scoreMsg'. scoreArr = []; total = 0; Obviously how I have it here without any formula around the sleep value, the score adds up for 5 seconds after the first kill, then resets & starts again when a kill is made after the 5 seconds. if (ratingScore > 0) then { [] spawn { scoreArr pushBack ratingScore; {total = (_x + total)} forEach scoreArr; scoreArr call scoreMsg; scoreArr = []; sleep 5; total = 0; }; }; If anyone can help with this or knows a better way of adding up values in an array, I have a slightly out of date bottle of Tobasco sauce I would be more than willing to part with. Many Thanks. -
Help - getVariable (ACE)
GaryTheNoTrashCougar replied to GaryTheNoTrashCougar's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Had to define a default value in case the variable returned nil value. player getVariable ["ace_medical_bloodVolume", 6.0]; Can't really see why that matters but works this way. -
Help - getVariable (ACE)
GaryTheNoTrashCougar posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Trying to make a displayCtrl for blood loss when using ace. Problem I'm having is trying to get blood level value: player getVariable "ace_medical_bloodVolume"; This works in debug console but is not recognised in my script. I'm not familiar with returning variables from mods, do I have to define something in order to pass the variable through to my script? -
Help - Detecting Kill Assist
GaryTheNoTrashCougar replied to GaryTheNoTrashCougar's topic in ARMA 3 - MISSION EDITING & SCRIPTING
That's awesome, thank you again. -
Help - Detecting Kill Assist
GaryTheNoTrashCougar replied to GaryTheNoTrashCougar's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thank you for replying. If I understand correctly, this should index (using pushBackUnique) the units that damage another unit into an array so I can check that array to see if a unit is in it? e.g. if (player in killerFeed). For some reason I'm getting an error "Invalid number in expression" which points to '_source'. I have tried '_instigator' as you suggested but as they are the same thing, no joy. Am I right to be running this inside my HitPart EH? Trying to pass '_target' variable through scripts as a global variable is proving difficult, assuming because there is no value until the HitPart EH has fired. -
Help - Detecting Kill Assist
GaryTheNoTrashCougar posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Is it possible to detect if a player has damaged a unit but another unit has killed that unit (kill assist)? I am using a Killed event handler for the unit that is killed & trying to combine that with a HitPart event handler but I can't get my head around the logic. in HitPart EH: playerShooting = (player isEqualTo _shooter); unitShot = _target; in Killed EH: if (playerShooting) //Obviously player is not the shooter when the unit is killed then { if ((_killed isEqualTo unitShot) && !(vehicle player isEqualTo _killer)) then {....blah blah Kill Assist}; }; also tried to use ((damage _target) < 1), but this is not true when _target is killed. Is there a way to check if the player dealt the damage? -
Help - Kill Message show to only the player who gets the kill
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 but is showing the messages to all players when someone gets a kill. Obviously I want it to just show the message to the player that gets the kill. If anyone could please help me fix this, I will gladly send you a Dora the Explorer sticker book. Thanks init.sqf [] execVM "Kill_Reward\Kill_Reward.sqf"; Kill_Reward.sqf player addEventHandler ["Handlescore", {false}]; sleep 0.5; KillMsg = { _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;}; HSKill = { _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;}; LRHSKill = { _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;}; CQBHSKill = { _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;}; LRKill = { _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;}; CQBKill = { _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;}; FriendlyKill = { _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;}; Suicide = { _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;}; if (hasInterface) then { execVM "Kill_Reward\Kill_Type.sqf"; addMissionEventHandler ["EntityKilled", { params ["_killed", "_killer"]; _headDamage = _killed getHitPointDamage "HitHead"; _distance = _killer distance _killed; _minDistance = 100; _cqbDistance = 2; if (isNull _instigator) then { _instigator = _killer }; if (isPlayer _killer) then { if (_killed isKindOf "CAManBase" && {((side group _killed) != playerSide)}) then { if (_distance >= _minDistance && ({_headDamage >= 1;})) then { player addPlayerScores [1, 0, 0, 0, 0]; player addRating 100; [[killType, _ratingScore]] call LRHSKill; } else { if (_distance <= _cqbDistance && ({_headDamage >= 1;})) then { player addPlayerScores [1, 0, 0, 0, 0]; player addRating 75; [[killType, _ratingScore]] call CQBHSKill; } else { if (_distance > _cqbDistance && ({_headDamage >= 1;})) then { player addPlayerScores [1, 0, 0, 0, 0]; player addRating 50; [[killType, _ratingScore]] call HSKill; }; }; if (_distance >= _minDistance && ({_headDamage < 1;})) then { player addPlayerScores [1, 0, 0, 0, 0]; player addRating 50; [["LONG RANGE KILL ", _ratingScore]] call LRKill; } else { if (_distance <= _cqbDistance && ({_headDamage < 1;})) then { player addPlayerScores [1, 0, 0, 0, 0]; player addRating 25; [["POINT BLANK KILL ", _ratingScore]] call CQBKill; } else { if ((_distance > _cqbDistance && {_distance < _minDistance}) && ({_headDamage < 1;})) then { player addPlayerScores [1, 0, 0, 0, 0]; [["ENEMY KILLED ", _ratingScore]] call KillMsg; }; }; }; }; }; if (_killed isKindOf "CAManBase" && {((side group _killed) == playerSide)}) then { if (_killer != _killed) then { player addPlayerScores [0, 0, 0, 0, 0]; [["FRIENDLY KILLED ", _ratingScore]] call FriendlyKill; }; if (_killed == _killer) then { player addPlayerScores [0, 0, 0, 0, 0]; [["SUICIDE ", _ratingScore]] call Suicide; }; }; }; }]; }; Kill_Type.sqf 0 = [] spawn { while {true} do { { _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 "; }; }; }; }; }; }]; _x setVariable ["passedThathitPart",TRUE]; } forEach (allUnits select {isNil {_x getVariable "passedThatHitPart"}}); sleep 2; }; }; -
GaryTheNoTrashCougar changed their profile photo
-
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: