From 2ef6790a8f7234e5111bb934c8adad76d5981833 Mon Sep 17 00:00:00 2001 From: He-Man Date: Fri, 11 Jan 2019 15:32:00 +0100 Subject: [PATCH] Defuse Bomb / Itemdisplayname Moving "Epoch_Itemdisplayname" also to server will rename it to "EPOCH_fnc_Itemdisplayname", so we now only link to the new function. Means, that you can now use: Client side: "EPOCH_Itemdisplayname" or "EPOCH_fnc_Itemdisplayname" Server side: "EPOCH_fnc_Itemdisplayname" So no eventually third-party scripts will take effect. --- .../epoch_code/compile/EPOCH_DefuseBomb.sqf | 7 +--- .../functions/EPOCH_itemDisplayName.sqf | 26 ++++++++++++ .../Configs/CfgClientFunctions.hpp | 1 + .../epoch_config/Configs/CfgRemoteExec.hpp | 5 +++ .../epoch_server/EPOCH_server_DefuseBomb.sqf | 42 +++++++++++++++++++ Sources/epoch_server/config.cpp | 1 + 6 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 Sources/epoch_code/compile/functions/EPOCH_itemDisplayName.sqf create mode 100644 Sources/epoch_server/compile/epoch_server/EPOCH_server_DefuseBomb.sqf diff --git a/Sources/epoch_code/compile/EPOCH_DefuseBomb.sqf b/Sources/epoch_code/compile/EPOCH_DefuseBomb.sqf index c8eb2288..fb48c116 100644 --- a/Sources/epoch_code/compile/EPOCH_DefuseBomb.sqf +++ b/Sources/epoch_code/compile/EPOCH_DefuseBomb.sqf @@ -12,9 +12,7 @@ if (alive player && !isnull _object) then { if !(_reward isequalto "") then { _chance = ["CfgEpochClient", "DefuseBombChance", 0.4] call EPOCH_fnc_returnConfigEntryV2; if (_chance >= ((random 100) / 100)) then { - deletevehicle _object; - _reward call EPOCH_fnc_addItemOverflow; - [format ['Sucessfully defused %1 - You have it now in your Inventory',_reward call Epoch_ItemDisplayName],5] call Epoch_Message; + [_object,false,player,Epoch_personalToken] remoteexec ["EPOCH_server_DefuseBomb",2]; } else { ['Oh No... The Bomb will explode in a few seconds... RUN!!!!',5] call Epoch_Message; @@ -22,8 +20,7 @@ if (alive player && !isnull _object) then { playSound3D ['a3\sounds_f\air\heli_attack_02\alarm.wss', player, false,getposasl _object, 1, 1, 300]; uisleep 1; }; - 'HelicopterExploSmall' createVehicle (position _object); - deletevehicle _object; + [_object,true,player,Epoch_personalToken] remoteexec ["EPOCH_server_DefuseBomb",2]; }; } else { diff --git a/Sources/epoch_code/compile/functions/EPOCH_itemDisplayName.sqf b/Sources/epoch_code/compile/functions/EPOCH_itemDisplayName.sqf new file mode 100644 index 00000000..e6b133ec --- /dev/null +++ b/Sources/epoch_code/compile/functions/EPOCH_itemDisplayName.sqf @@ -0,0 +1,26 @@ +/* + Author: Aaron Clark - EpochMod.com + + Contributors: + + Description: + Returns the DisplayName of a Vehicle, Weapon, or Magazine. + + Licence: + Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike + + Github: + https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/functions/EPOCH_itemDisplayName.sqf + + Example: + _displayName = _part call EPOCH_itemDisplayName; + + Parameter(s): + _this: STRING - Vehicle, Weapon, or Magazine config class name + + Returns: + STRING +*/ +// Changed function name for usage Server and Client side + +_this call EPOCH_fnc_itemDisplayName; diff --git a/Sources/epoch_config/Configs/CfgClientFunctions.hpp b/Sources/epoch_config/Configs/CfgClientFunctions.hpp index d5589c78..54ed9cfa 100644 --- a/Sources/epoch_config/Configs/CfgClientFunctions.hpp +++ b/Sources/epoch_config/Configs/CfgClientFunctions.hpp @@ -144,6 +144,7 @@ class CfgClientFunctions class fnc_addMagazineOverflow {}; class itemData {}; class itemPicture {}; + class itemDisplayName {}; class SortArrayByDistance {}; class fnc_findRandomPosBehind {}; class fnc_stringLeft {}; diff --git a/Sources/epoch_config/Configs/CfgRemoteExec.hpp b/Sources/epoch_config/Configs/CfgRemoteExec.hpp index b626c1a7..1fa7164a 100644 --- a/Sources/epoch_config/Configs/CfgRemoteExec.hpp +++ b/Sources/epoch_config/Configs/CfgRemoteExec.hpp @@ -345,6 +345,11 @@ class CfgRemoteExec { allowedTargets = 2; jip = 0; + }; + class EPOCH_server_DefuseBomb + { + allowedTargets = 2; + jip = 0; }; }; class Commands diff --git a/Sources/epoch_server/compile/epoch_server/EPOCH_server_DefuseBomb.sqf b/Sources/epoch_server/compile/epoch_server/EPOCH_server_DefuseBomb.sqf new file mode 100644 index 00000000..a1c07061 --- /dev/null +++ b/Sources/epoch_server/compile/epoch_server/EPOCH_server_DefuseBomb.sqf @@ -0,0 +1,42 @@ +/* + Author: He-Man - EpochMod.com + + Contributors: + + Description: + Defuse server side bombs (triggerd by Clients) + + Licence: + Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike + + Github: + https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_server/EPOCH_server_Defusebomb.sqf + + Example: + [_bomb,true,player,Epoch_personalToken] remoteexec ["EPOCH_server_DefuseBomb",2]; + + Returns: + NOTHING +*/ + +params [ + ["_object",objNull,[objNull]], + ["_value",true,[true]], + ["_player",objNull,[objNull]], + ["_token","",[""]] +]; +if (isNull _object) exitWith{}; +if !([_player, _token] call EPOCH_server_getPToken) exitWith{}; +if (_player distance _object > 20) exitWith{}; +if (_value) then { + 'HelicopterExploSmall' createVehicle (position _object); + deletevehicle _object; +} +else { + deletevehicle _object; + _reward = gettext (configfile >> "cfgammo" >> (typeof _object) >> "defaultMagazine"); + if !(_reward isequalto "") then { + _reward remoteexec ["EPOCH_fnc_addItemOverflow",_player]; + [format ['Sucessfully defused %1 - You have it now in your Inventory',_reward call Epoch_fnc_Itemdisplayname],5] remoteexec ["Epoch_Message",_player]; + }; +}; \ No newline at end of file diff --git a/Sources/epoch_server/config.cpp b/Sources/epoch_server/config.cpp index 2e3750e1..48f5a825 100644 --- a/Sources/epoch_server/config.cpp +++ b/Sources/epoch_server/config.cpp @@ -128,6 +128,7 @@ class CfgServerFunctions class server_createGlobalMarkerSet {}; class server_deleteGlobalMarkerSet {}; class server_isNearChecks {}; + class server_DefuseBomb {}; }; class epoch_missions { class Server_createObject {};