-
Content Count
431 -
Joined
-
Last visited
-
Medals
Everything posted by BEAKSBY
-
Confirm-> Event Handler "Killed" returns _killer == _unit when driven over?
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I think if the _unit is killed, going with the _vehicle = nearestObject [_unit, "LandVehicle"]; approach is probably this simplest instead of adding another Event Handler? Not sure what stacked event handlers is about and how that would fit into this if I created addEventHandler "EpeContact"... -
Hi All, Anyone also notice that addEventHandler [ "Killed", does not execute when a kill is made my driving over a StaticWeapon like a O_GMG_01_high_F or O_HMG_01_high_F? Is this a know issue? I did not find it in the issue tracker with BIS. I guess others have noticed and resolved this with finding the nearest player/driver?
-
eventHandler "Killed" or allUntis Issue?
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thanks Tajin, I think you're right...currently I'm testing this. I'll will let you know the results. -
eventHandler "Killed" or allUntis Issue?
BEAKSBY posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
HI ALL, I can't figure out what is causing the issue described below. When only a vehicle or vehicle with units are killed the correct vallue is passed to the fn_addMoney function. HOWEVER, when a soldier is killed, not in a vehicle, it's value seems to tripple (or some times double) once passed through to the fn_addMoney function. When I test by killing a soldier with hints, the unitValue values are correct except for inside the fn_addMoney function where is it 0 and the money value shows two or three times the expected value. I can't figure out what's causing the problem. InitServer.sqf fn_addMoney.sqf private ["_unitValue", "_textvehicle", "_unitType", "_vehicle", "_picture", "_unit", "_money" ]; _unitValue = [ _this, 0, 0, [0] ] call BIS_fnc_param; _unit = _this select 1; //---THIS WORKS //--- Add money to global DNA_Money = DNA_Money + _unitValue; _money = DNA_Money; hint format ["_unitValue: %1 \n _unit: %2 \n _money: %3", _unitValue, _unit, _money]; true -
Problem with my "if" conditions logic...please help me solve
BEAKSBY posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
HI folks, I using two addEventHandler "Killed", the first for only empty vehicles and vehicles with crew inside, and the second for only soliers (outside of vehicles). I cant't figure out why only the second addEventHandler "Killed" is firing even when a vehicle with crew is destroyed. When I hide the second addEventHandler "Killed" with comments the first one works fine, but obviously the soldiers outside portion will not fire. here's the "if" conditions for the first for only empty vehicles and vehicles with crew inside: if ((side group _killer != side group _unit) && (side _killer != sideEnemy) && (typeOf vehicle _unit isKindOf "LandVehicle") ) then { here's the "if" conditions for only soliers (outside of vehicles): if ((side group _killer != side group _unit) && (side _killer != sideEnemy) && (vehicle _unit == _unit) && (typeOf vehicle _unit isKindOf "Man")) then {money = 12.5}; Here's my entire initServer.sqf { //--- Add killed EH to unit FOR VEHICLES AND UNITS IN VEHICLES _handle = _x addEventHandler [ "Killed", { _unit = _this select 0; _killer = _this select 1; _handle = _unit getVariable [ "DNA_EH_Killed_Money", -1 ]; money=0; if ((side group _killer != side group _unit) && (side _killer != sideEnemy) && (typeOf vehicle _unit isKindOf "LandVehicle") ) then { //--- Check if opposite side is killed by _killer && _Killer is not an renegade //if (typeOf vehicle _unit isKindOf "LandVehicle") then { //---condition of vehicles only hint "vehicle or vehicle with soldiers inside killed"; }; } ]; //--- Store killed EH handle in unit namespace _x setVariable [ "DNA_EH_Killed_Money", _handle ]; } forEach vehicles; // THIS WORKS { //--- Add killed EH to unit FOR UNITS ONLY (NOT IN VEHICLES) _handle = _x addEventHandler [ "Killed", { _unit = _this select 0; _killer = _this select 1; _handle = _unit getVariable [ "DNA_EH_Killed_Money", -1 ]; money=0; //--- Check if opposite side is killed by _killer && _Killer is not an renegade && "_unit is NOT in a vehicle" (vehicle _unit == _unit) if ((side group _killer != side group _unit) && (side _killer != sideEnemy) && (vehicle _unit == _unit) && (typeOf vehicle _unit isKindOf "Man")) then { hint "soldier killed"; money =12.5}; } ]; //--- Store killed EH handle in unit namespace _x setVariable [ "DNA_EH_Killed_Money", _handle ]; } forEach allUnits; // THIS WORKS -
Problem with my "if" conditions logic...please help me solve
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thanks Mariodu62, I just tried as you suggested above but also does not work since the hint returns soldier killed, whether a vehicle, vehicle with soldiers inside or soldier is killed... { //--- Add killed EH to unit FOR VEHICLES AND UNITS IN VEHICLES _handle = _x addEventHandler [ "Killed", { _unit = _this select 0; _killer = _this select 1; _handle = _unit getVariable [ "DNA_EH_Killed_Money", -1 ]; money=0; if ((side group _killer != side group _unit) && (side _killer != sideEnemy) && (_unit isKindOf "Man") ) then { hint "soldier killed"; } else { hint "vehicle or vehicle with soldiers inside killed"; // if ((side group _killer != side group _unit) && (side _killer != sideEnemy) && (typeOf vehicle _unit isKindOf "LandVehicle") ) then { //--- Check if opposite side is killed by _killer && _Killer is not an renegade //if (typeOf vehicle _unit isKindOf "LandVehicle") then { //---condition of vehicles only }; } ]; //--- Store killed EH handle in unit namespace _x setVariable [ "DNA_EH_Killed_Money", _handle ]; } forEach vehicles + allUnits; // THIS WORKS ---------- Post added at 16:00 ---------- Previous post was at 15:03 ---------- Problem solved with this: { //--- Add killed EH to unit FOR VEHICLES AND UNITS IN VEHICLES _handle = _x addEventHandler [ "Killed", { _unit = _this select 0; _killer = _this select 1; _handle = _unit getVariable [ "DNA_EH_Killed_Money", -1 ]; money=0; if ((side group _killer != side group _unit) && (side _killer != sideEnemy) && (typeOf vehicle _unit isKindOf "LandVehicle") ) then { //--- Check if opposite side is killed by _killer && _Killer is not an renegade //if (typeOf vehicle _unit isKindOf "LandVehicle") then { //---condition of vehicles only //hint "vehicle or vehicle with soldiers inside killed"; { __x =_x; { if (( typeof _x) in __x ) then {money = money + (__x select 0)/2}; } foreach crew _unit + [_unit]; } foreach veh; _vehicle = getText (configFile >> "cfgVehicles" >> typeof _unit >> "displayname"); _picture = getText (configFile >> "cfgVehicles" >> typeof _unit >> "picture"); //}; //--- Add money to the client [ [money, _unit, _picture, _vehicle, count crew _unit], "DNA_fnc_addMoney", side group _killer ] call BIS_fnc_MP; /**/ }; } ]; //--- Store killed EH handle in unit namespace _x setVariable [ "DNA_EH_Killed_Money", _handle ]; } forEach vehicles; // THIS WORKS { //--- Add killed EH to unit FOR UNITS ONLY (NOT IN VEHICLES) _handle = _x addEventHandler [ "Killed", { _unit = _this select 0; _killer = _this select 1; _handle = _unit getVariable [ "DNA_EH_Killed_Money", -1 ]; money=0; //--- Check if opposite side is killed by _killer && _Killer is not an renegade && "_unit is NOT in a vehicle" (vehicle _unit == _unit) if ((side group _killer != side group _unit) && (side _killer != sideEnemy) && (vehicle _unit == _unit) && (typeOf vehicle _unit isKindOf "Man")) then {; money = 12.5; // hint "soldier killed"; _vehicle = getText (configFile >> "cfgVehicles" >> typeof _unit >> "displayname"); [ [money, _unit, _picture, _vehicle, count crew _unit], "DNA_fnc_addMoney", side group _killer ] call BIS_fnc_MP; /**/}; } ]; //--- Store killed EH handle in unit namespace _x setVariable [ "DNA_EH_Killed_Money", _handle ]; } forEach allUnits; // THIS WORKS -
I went with this one and it works. To DarkWanderer's point I think this is no longer true, as the addEventHandler "Killed" respects the if condition in my code now that I replaced it with side _killer != sideEnemy.Thanks again everyone
-
Has anyone had issues with sideEnemy before? I'm running the following in my initServer.sqf _handle = _x addEventHandler [ "Killed", { _unit = _this select 0; _killer = _this select 1; _handle = _unit getVariable [ "DNA_EH_Killed_Money", -1 ]; if ((side group _killer != side group _unit) && (side group _killer != sideEnemy)) then { hint format ["side group _killer: %1 \n side group _unit: %2", side group _killer, side group _unit]; {...more code} }; ...and when a player kills a friendly on the map he turns purple, yet the hint still diplays he is still on his original side, and the code after the if statement is also executed as if the condition was TRUE?I thought it would display as "renegade" or "enemy"? How then do I ensure that if a player kills one of his own the following is FALSE? ((side group _killer != side group _unit) && (side group _killer != sideEnemy))
-
Hint, parseText format, composeText,... confused please help
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thanks F2k Sel, Damn. You're good you. :) -
Hint, parseText format, composeText,... confused please help
BEAKSBY posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi Folkes, I'm trying to make my hint message easier to script. Instead of one continuous line I would like to parse it so I can read the script better. Why don't the following two scripts equal? This works: hint parsetext format ["<t size='0.85' align='left'>You killed: </t><t size='0.85' align='left'>%1</t><br/><t size='0.85' align='left'>You gained $</t><t size='0.85' color='#ff0000' align='left'> %2</t><br/><t size='0.85' align='left'>Cash Remaining $</t> <t size='0.85' color='#ff0000' align='left'>%3</t>", _textKilled, _amount, _money]; But this doesn't match up? _text1 = parsetext format ["<t size='0.85' align='left'>You killed: </t><t size='0.85' align='left'>%1</t><br/>", _textKilled]; _text2 = parsetext format ["<t size='0.85' align='left'>You gained $</t><t size='0.85' color='#ff0000' align='left'> %1</t><br/>",_amount]; _text3 = parsetext format ["<t size='0.85' align='left'>Cash Remaining $</t> <t size='0.85' color='#ff0000' align='left'>%1</t>",_money]; hint parseText (_text1 + _text2 + _text3); /* My notes on hint https://community.bistudio.com/wiki/hint starL = "<img image='\ca\ui\data\debr_star.paa' align='left'/>"; _starL = _starL + _starL + _starL; _starR = "<img image='\ca\ui\data\debr_star.paa' align='right'/>"; _starR = _starR + _starR + _starR; _title = "<t color='#ff0000' size='1.2' shadow='1' shadowColor='#000000' align='center'>TITLE</t><br/><br/>"; _text = "Bla bla bla bla bla..."; hint parseText (_starL + _starR + _title + _text); */ -
Where can I find the "picture" .paa file for soldiers?
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
SO...instead of "picture" I should replace it with "icon" for getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "picture");? -
Where can I find the "picture" .paa file for soldiers?
BEAKSBY posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi Folks, Using the script below I can retrieve the vehicle "picture" files but where do I find the ones for soldiers? _vehicle = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "displayname"); _picture = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "picture"); -
HI All, I'm trying to pass the following array [_unitValue,_textvehicle] to a function but does not read it from the function side: // Identify vehicle and its value _textvehicle = []; for "_i" from 0 to (count veh)-1 do { // also add the value of vehicle killed if (_unitType == ((veh select _i) select 1)) then {_unitValue = (((veh select _i) select 0)/2); // each unit value is half original price _vehicle = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "displayname"); _picture = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "picture"); _textvehicle = parsetext format ["<t size='0.85' ><img size='1' image='%1'/><t size='0.85'> %2", _picture,_vehicle]; //--- Add money to the client [ [_unitValue,_textvehicle] , "DNA_fnc_addMoney", _killer ] call BIS_fnc_MP; fn_addMoney.sqf private ["_amountAAA", "_amount", "_textKilled"]; _amountAAA = [ _this, 0, 0, [0] ] call BIS_fnc_param; hint _amountAAA; // THIS DOES NOT DISPLAY WHEN I TEST _amount = _amountAAA select 0; _textKilled = _amountAAA select 1; //--- Add money to global DNA_Money = DNA_Money + _amount; _money = DNA_Money; // hint You gained _amount Cash Remaining $ _money You Killed: _textKilled // THIS DOES NOT DISPLAY WHEN I TEST hint parsetext format ["<t size='0.85' align='left'>You gained $</t><t size='0.85' color='#ff0000' align='left'> %1</t><br/> <t size='0.85' align='left'>Cash Remaining $</t> <t size='0.85' color='#ff0000' align='left'>%2</t> <br/><t size='0.85' align='left'>You killed: </t><t size='0.85' align='left'>%3</t>", _amount, _money, _textKilled,]; true Thanks in-advance.
-
How do I pass an Array to a Function
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
This works, thanks! -
Do my two addEventHandlers “Killed� need a different Number (index)?
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thanks cuel, I thought by removing them it would avoid any conflicts between both my eventHandlers, but by the sounds of it, using removeEventHandler in this case may only add potential problems. At first I tried to create on eventHandlers to account for empty vehicles, vehicles and their crew, and only units (soldiers) but ran into problems trying to differentiate the latter two. The {more code} inside my event handlers add a dollar value I assign to allUnits and vehicles. Here's my complete initServer.sqf with both eventhandlers to give you an idea. initServer.sqf -
Do my two addEventHandlers “Killed� need a different Number (index)?
BEAKSBY posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi Folks, Do my two addEventHandlers “Killed†need a different Number? (The index of the currently added event handler is returned)? Both addEventHandlers are using _handle and incidentally both my removeEventHandlers are using _unit. Both are included in my initServer.sqf The first addEventHandlers “Killed†is used to handle vehicles and the units killed inside. { //--- Add killed EH to unit FOR VEHICLES AND UNITS IN VEHICLES _handle = _x addEventHandler ["Killed", { _unit = _this select 0; _killer = _this select 1; _handle = _unit getVariable [ "DNA_EH_Killed_Money", -1 ]; {more code}; _unit removeEventHandler [ "Killed", _handle ]; //--- Remove the event handler } ]; _x setVariable [ "DNA_EH_Killed_Money", _handle ]; //--- Store killed EH handle in unit namespace } forEach vehicles; The second addEventHandlers “Killed†is used for all units, not inside a vehicle. { //--- Add killed EH to unit FOR UNITS ONLY (NOT IN VEHICLES) _handle = _x addEventHandler ["Killed", { _unit = _this select 0; _killer = _this select 1; _handle = _unit getVariable [ "DNA_EH_Killed_Money", -1 ]; {more different code}; _unit removeEventHandler [ "Killed", _handle ]; //--- Remove the event handler } ]; _x setVariable [ "DNA_EH_Killed_Money", _handle ]; //--- Store killed EH handle in unit namespace } forEach allUnits; -
Hint, parseText format, composeText,... confused please help
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
correct veh is an array veh = [[1200, "B_MBT_01_TUSK_F"],[900, "B_APC_Tracked_01_rcws_F"],[750, "B_APC_Tracked_01_AA_F"],[600, "I_APC_Wheeled_03_cannon_F"], [300,"B_MRAP_01_gmg_F"],[150,"B_MRAP_01_hmg_F"],[100,"B_G_Offroad_01_armed_F"],[200,"B_static_AT_F"],[200, "B_static_AA_F"],[150,"B_soldier_LAT_F"], [100,"B_G_Soldier_LAT_F"],[25, "B_Soldier_F"],[150,"B_GMG_01_high_F"],[100,"B_HMG_01_high_F"],[1200, "O_MBT_02_cannon_F"],[900, "O_APC_Tracked_02_cannon_F"], [750, "O_APC_Tracked_02_AA_F"],[600, "O_APC_Wheeled_02_rcws_F"],[300,"O_MRAP_02_gmg_F"],[150,"O_MRAP_02_hmg_F"],[100,"O_G_Offroad_01_armed_F"], [200,"O_static_AT_F"],[200, "O_static_AA_F"],[150,"O_soldierU_LAT_F"],[100,"O_G_Soldier_LAT_F"],[150,"O_GMG_01_high_F"],[100,"O_HMG_01_high_F"], [25, "O_Soldier_F"], [66, "O_crew_F"],[66, "B_crew_F"]]; Basically I was trying to build a string for the units killed inside the vehicle as well as the vehicle itself and pass it to my money script. So it would display "you killed [vehicle and units killed inside], you gained [total of vehicle and units killed inside] and current account [current balance + gained for kills - purchased vehicles]. I've got everything working so far except for the concatonated string of units killed inside and the vehicle. Pictures of the units and vehicles is a "nice to have" and would be faster that reading a message with string/text information. -
How do I pass an Array to a Function
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I've tested the above and it returns the number value for _unitValue but the _textvehicle is not displayed. fn_addMoney.sqf I am sending this to the function: [ [_unitValue, _textvehicle], "DNA_fnc_addMoney", _killer ] call BIS_fnc_MP; where _unitValue = _unitValue + _unitsInVehicleSumValue; //---total value of vehicle and units killed inside and _textvehicle = parsetext format ["<t size='0.85' ><img size='1' image='%1'/><t size='0.85'> %2", _picture,_vehicle]; I tested with hint _textvehicle; //---THIS WORKS and this diplays the picture and display name of the vehicle before sending it the functions. if (_unitType == ((veh select _i) select 1)) then {_unitValue = (((veh select _i) select 0)/2); //---each unit value is half original price listed above _vehicle = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "displayname"); _picture = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "picture"); _textvehicle = parsetext format ["<t size='0.85' ><img size='1' image='%1'/><t size='0.85'> %2", _picture,_vehicle]; //hint _textvehicle; //---THIS WORKS }; Does BIS_fnc_param accept pictures from configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "picture"); as a dataType? I also tested it without the picture so _textvehicle is just a string and it still does not seem to be passed as it is not displaying? -
Hint, parseText format, composeText,... confused please help
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I've tried this... _textcrew = []; for "_i" from 0 to (count veh)-1 do { //---check value for each unit killed in vehicle and obtain its name and picture if (_unitInVehicle == ((veh select _i) select 1)) then {_unitsInVehicleSumValue = _unitsInVehicleSumValue + (((veh select _i) select 0)/2); // each unit value is half original price listed above _vehicle = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "displayname"); _picture = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "picture"); _textcrew = str _textcrew + str (parseText format ["<t size='0.85' ><img size='1' image='%1'/><t size='0.85'> %2", _picture,_vehicle]); hint _textcrew; }; }; ...and it returns this [] crewman. But the vehicle has a crew of 3. SO I was expecting crewmancrewmancrewman. It also doesn't seem to find the pictures for soldiers in configFile >> "cfgVehicles" >> However, this works beautifully with picture and displayname, _textvehicle = ""; for "_i" from 0 to (count veh)-1 do { //---also add the value of vehicle killed and obtain its name and picture if (_unitType == ((veh select _i) select 1)) then {_unitValue = (((veh select _i) select 0)/2); //---each unit value is half original price listed above _vehicle = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "displayname"); _picture = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "picture"); _textvehicle = parsetext format ["<t size='0.85' ><img size='1' image='%1'/><t size='0.85'> %2", _picture,_vehicle]; hint _textvehicle; }; }; Note the declaration for the vehicles variable is _textvehicle = ""; I think for the crew I need to declare an array of empty strings? -
HI All, I'm a bit confused with how I should handle the following. Currently my addEventHandler [Killed] script only runs once for the player client side but works all the time for the player on the server side. I'm not sure if I should be using addMPEventHandler [MPKilled] instead? I'm worried that if I use MPKilled then call my money script to add money to the _killer, I will get this function [ _unitValue, "DNA_fnc_addMoney", _killer ] call BIS_fnc_MP; running on every machined and slow down the game? I based this assumption on "Triggered when the unit is killed. EH can be added on any machine and EH code will trigger globally on every connected client and server. Add it only on server because if you have 10 machines on network and add this EH to every machine, when triggered the EH code will be executed 10 x 10 = 100 times." See MPKilled. My script is in the initServer.sqf as follows:
-
How do I pass an Array to a Function
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thanks Das, FYI, my original script worked without the array, nor the private _unitValue declaration as follows (same as above except for): //--- Add money to the client // _unitValueAndText = [_unitValue,_textvehicle]; DOES NOT WORK [ _unitValue, "DNA_fnc_addMoney", _killer ] call BIS_fnc_MP; and original fn_addMoney.sqf without array either: private "_amount"; _amount = [ _this, 0, 0, [0] ] call BIS_fnc_param; //--- Add money to global DNA_Money = DNA_Money + _amount; _money = DNA_Money; hint parsetext format ["<t size='0.85' align='center'>You gained $</t><t size='0.85' color='#ff0000' align='center'> %1</t><br/> <t size='0.85' align='center'>Cash Remaining $</t> <t size='0.85' color='#ff0000' align='center'>%2</t>", _amount, _money]; However I will still test your suggestion and use the diag_log (this is new to me). Thanks again. -
Hint, parseText format, composeText,... confused please help
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi Again, Please help with this one, it is supposed to display all the units from the do loop in the hint display. _textcrew = []; for "_i" from 0 to (count veh)-1 do { // check value for each unit in vehicle if (_unitInVehicle == ((veh select _i) select 1)) then {_unitsInVehicleSumValue = _unitsInVehicleSumValue + (((veh select _i) select 0)/2)}; // each unit value is half original price _vehicle = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "displayname"); _picture = getText (configFile >> "cfgVehicles" >> ((veh select _i) select 1) >> "picture"); _textcrew = parseText (_textcrew + format ["<t size='0.85' ><img size='1' image='%1'/><t size='0.85'> %2", _picture,_vehicle]); hint _textcrew; }; The hint with this works but does not add the _textcrew as desired. _textcrew = parseText format ["<t size='0.85' ><img size='1' image='%1'/><t size='0.85'> %2", _picture,_vehicle]; hint _textcrew; -
Hi Anyone who can help, I'm trying to get this script to work for a MP game. A unit from one side (AI or player) who kills a unit from opposite side is suppoed to get money equivalent to half the original cost of the killed unit. I've added this this script to the initServer.sqf but I think there's a problem with the // aray of original cost of units and do loop? Also, how do I get the hint message to display to only the client that earned the money? initServer.sqf { //--- Add killed EH to unit _handle = _x addEventHandler [ "Killed", { _unit = _this select 0; _killer = _this select 1; _handle = _unit getVariable [ "DNA_EH_Killed_Money", -1 ]; //--- Check if opposite side is killed by killer if (side group _killer != side group _unit) then { //--- Determine money value of _unit based on unit class _unitType = typeOf _unit; // aray of original cost of units and do loop _veh = [[1200, "B_MBT_01_TUSK_F"],[900, "B_APC_Tracked_01_rcws_F"],[750, "B_APC_Tracked_01_AA_F"],[600, "I_APC_Wheeled_03_cannon_F"],[300,"B_MRAP_01_gmg_F"],[150,"B_MRAP_01_hmg_F"],[100,"B_G_Offroad_01_armed_F"],[200,"B_static_AT_F"],[200, "B_static_AA_F"],[150,"B_soldier_LAT_F"],[100,"B_G_Soldier_LAT_F"],[150,"B_GMG_01_high_F"],[100,"B_HMG_01_high_F"],[1200, "O_MBT_02_cannon_F"],[900, "O_APC_Tracked_02_cannon_F"],[750, "O_APC_Tracked_02_AA_F"],[600, "O_APC_Wheeled_02_rcws_F"],[300,"O_MRAP_02_gmg_F"],[150,"O_MRAP_02_hmg_F"],[100,"O_G_Offroad_01_armed_F"],[200,"O_static_AT_F"],[200, "O_static_AA_F"],[150,"O_soldierU_LAT_F"],[100,"O_G_Soldier_LAT_F"],[150,"O_GMG_01_high_F"],[100,"O_HMG_01_high_F"]]; for "_i" from 0 to (count _veh)-1 do { if _unitType = ((_veh select _i) select 1) then {_unitValue = (((_veh select _i) select 1)/2)}; // _unitValue will be half the original price of the unit }; //--- Add money to the client [ _unitValue, "DNA_fnc_addMoney", _killer ] call BIS_fnc_MP; // hint format [ "You have gained $%1", _unitValue ]; // THIS ONLY WORKS ON SERVER SIDE }; //--- Remove the event handler _unit removeEventHandler [ "Killed", _handle ]; } ]; //--- Store killed EH handle in unit namespace _x setVariable [ "DNA_EH_Killed_Money", _handle ]; } forEach allUnits; Thanks in advance...if you can help me.
-
Based on your feedback from post #11 I am now exeperiencing the problem you mentioned and not sure how to account for it. My money script for vehicles with units inside is running forEach time there is a unit "killed" inside as well as the vehicle because of my forEach vehicles + allUnits; loop. Shouls I just run two separate "Killed" addEventHandlers, one for vehicles and the other for units? Or can you suggest another solution? Here's my initServer.sqf that over multiplies the eventHandler. initServer.sqf
-
units in vehicles & "Killed" eventhandler - Help with my script
BEAKSBY replied to BEAKSBY's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I still have not found the problem, but my MP game works but none of the do loops or in thenstatements are executing from post#1. I tested with just these lines isolated from the script. if (_unitType isKindOf "LandVehicle") then { // hint format["_unitType %1",_unitType] TESTED & WORKS // obtain count and type of units killed inside as well as the vehicle killed _unitArrayInVehicle = allUnits in units _unitType; // array of units in vehicle _countUnitsInVehicle = count _unitArrayInVehicle; // number of units in vehicle hint format["_unitArrayInVehicle: %1 ",_unitArrayInVehicle ]; //TESTED & DOES NOT WORK }; I'll try crew in the morning. I don't think this line below is working because it is not hinting. _unitArrayInVehicle = allUnits in units _unitType; // array of units in vehicle I simply want the array of units in the vehicle. This was finally resolved with _unitArrayInVehicle = units _unit;