HellBz

ExileClient_object_item_consume + 1 PopTab

Mar 24th, 2017
317
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.92 KB | None | 0 0
  1. /**
  2.  * ExileClient_object_item_consume
  3.  *
  4.  * Exile Mod
  5.  * www.exilemod.com
  6.  * © 2015 Exile Mod Team
  7.  *
  8.  * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  9.  * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  10.  */
  11.  
  12. private["_itemClassName","_consumingConfig","_configEffects","_feedbackString","_effectAttributeId","_effectValue","_effectDuration","_effectUnit","_effect","_addPlusCharacter","_bloodAlcohol","_bloodAlcoholComment","_animations","_animationIndex","_stopBleeding","_configSounds","_numberOfConfigSounds","_returnItemClass"];
  13. _itemClassName = _this select 0;
  14. if !(_itemClassName in (magazines player)) exitWith {false};
  15.  
  16. switch (_itemClassName) do
  17. {
  18.     case "Exile_Item_PowerDrink":
  19.     {
  20.         _playerMoney = player getVariable ['ExileMoney', 0];
  21.         _lockerMoney = player getVariable ['ExileLocker', 0];
  22.         _playerMoney = _playerMoney + 1;
  23.         _poptabsplayer = _playerMoney + _lockerMoney;
  24.         player setVariable ['ExilePopTabsCheck', _poptabsplayer];
  25.         player setVariable ['ExileMoney', _playerMoney, true];
  26.         player setVariable ['ExileLocker', _lockerMoney, true];
  27.         format['setPlayerMoney:%1:%2', _playerMoney, player getVariable ['ExileDatabaseID', 0]] call ExileServer_system_database_query_fireAndForget;
  28.        
  29.         ["SuccessTitleAndText", ["From PowerDrink", format ["%1<img image='\exile_assets\texture\ui\poptab_inline_ca.paa' size='24'/>", "1"]]] call ExileClient_gui_toaster_addTemplateToast;
  30.  
  31.  
  32.     };
  33.     case "Exile_Item_EnergyDrink":
  34.     {
  35.         _playerMoney = player getVariable ['ExileMoney', 0];
  36.         _lockerMoney = player getVariable ['ExileLocker', 0];
  37.         _playerMoney = _playerMoney + 1;
  38.         _poptabsplayer = _playerMoney + _lockerMoney;
  39.         player setVariable ['ExilePopTabsCheck', _poptabsplayer];
  40.         player setVariable ['ExileMoney', _playerMoney, true];
  41.         player setVariable ['ExileLocker', _lockerMoney, true];
  42.         format['setPlayerMoney:%1:%2', _playerMoney, player getVariable ['ExileDatabaseID', 0]] call ExileServer_system_database_query_fireAndForget;
  43.        
  44.         ["SuccessTitleAndText", ["From EnergyDrink", format ["%1<img image='\exile_assets\texture\ui\poptab_inline_ca.paa' size='24'/>", "1"]]] call ExileClient_gui_toaster_addTemplateToast;
  45.     };     
  46.     case "Exile_Item_MountainDupe":
  47.     {
  48.         _playerMoney = player getVariable ['ExileMoney', 0];
  49.         _lockerMoney = player getVariable ['ExileLocker', 0];
  50.         _playerMoney = _playerMoney + 1;
  51.         _poptabsplayer = _playerMoney + _lockerMoney;
  52.         player setVariable ['ExilePopTabsCheck', _poptabsplayer];
  53.         player setVariable ['ExileMoney', _playerMoney, true];
  54.         player setVariable ['ExileLocker', _lockerMoney, true];
  55.         format['setPlayerMoney:%1:%2', _playerMoney, player getVariable ['ExileDatabaseID', 0]] call ExileServer_system_database_query_fireAndForget;
  56.        
  57.         ["SuccessTitleAndText", ["From MountainDupe", format ["%1<img image='\exile_assets\texture\ui\poptab_inline_ca.paa' size='24'/>", "1"]]] call ExileClient_gui_toaster_addTemplateToast;
  58.     }; 
  59.     case "Exile_Item_ChocolateMilk":
  60.     {
  61.         _playerMoney = player getVariable ['ExileMoney', 0];
  62.         _lockerMoney = player getVariable ['ExileLocker', 0];
  63.         _playerMoney = _playerMoney + 1;
  64.         _poptabsplayer = _playerMoney + _lockerMoney;
  65.         player setVariable ['ExilePopTabsCheck', _poptabsplayer];
  66.         player setVariable ['ExileMoney', _playerMoney, true];
  67.         player setVariable ['ExileLocker', _lockerMoney, true];
  68.         format['setPlayerMoney:%1:%2', _playerMoney, player getVariable ['ExileDatabaseID', 0]] call ExileServer_system_database_query_fireAndForget;
  69.        
  70.         ["SuccessTitleAndText", ["From ChocolateMilk", format ["%1<img image='\exile_assets\texture\ui\poptab_inline_ca.paa' size='24'/>", "1"]]] call ExileClient_gui_toaster_addTemplateToast;
  71.     }; 
  72.    
  73. };
  74.  
  75. if( isClass(configFile >> "CfgMagazines" >> _itemClassName >> "Interactions" >> "Consuming") ) then
  76. {
  77.     _consumingConfig = configFile >> "CfgMagazines" >> _itemClassName >> "Interactions" >> "Consuming";
  78.     _configEffects = getArray (_consumingConfig >> "effects");
  79.     _feedbackString = "";
  80.     {
  81.         _effectAttributeId = _x select 0;
  82.         _effectValue = _x select 1;
  83.         _effectDuration = _x select 2;
  84.         _effectUnit = if (_effectAttributeId isEqualTo 4) then {"‰"} else {"%"};
  85.         _effect =
  86.         [
  87.             _effectAttributeId,
  88.             _effectValue,
  89.             _effectDuration,
  90.             time,
  91.             _effectValue
  92.         ];
  93.         _addPlusCharacter = if (_effectValue > 0) then { "+" } else { "" };
  94.         if( _effectDuration == 0 ) then
  95.         {
  96.             _feedbackString = _feedbackString + format["%1: %2%3%4<br/>", (ExileClientPlayerEffectNames select _effectAttributeId), _addPlusCharacter, _effectValue, _effectUnit];
  97.         }
  98.         else
  99.         {
  100.             _feedbackString = _feedbackString + format["%1: %2%3%4/%5s<br/>", (ExileClientPlayerEffectNames select _effectAttributeId), _addPlusCharacter, _effectValue, _effectUnit, _effectDuration];
  101.         };
  102.         if (_effectAttributeId isEqualTo 4) then
  103.         {
  104.             _bloodAlcohol = (ExileClientPlayerAttributes select 4);
  105.             _bloodAlcohol = (_bloodAlcohol + _effectValue) max 0;
  106.             ExileClientPlayerAttributes set [4, _bloodAlcohol];
  107.             if (_bloodAlcohol > 0) then
  108.             {
  109.                 _bloodAlcoholComment = "You feel tipsy.";
  110.                 if (_bloodAlcohol >= 3) then
  111.                 {
  112.                     _bloodAlcoholComment = "You are drunk as a skunk.";
  113.                 }
  114.                 else
  115.                 {
  116.                     if (_bloodAlcohol >= 2) then
  117.                     {
  118.                         _bloodAlcoholComment = "You are boozed-up.";
  119.                     }
  120.                     else
  121.                     {
  122.                         if (_bloodAlcohol >= 1) then
  123.                         {
  124.                             _bloodAlcoholComment = "You are drunk.";
  125.                         };
  126.                     };
  127.                 };
  128.                 systemChat format["Your blood alcohol level is now %1%2. %3", _bloodAlcohol, "‰", _bloodAlcoholComment];
  129.             };
  130.             if (ExileClientDeliriumThread isEqualTo -1) then
  131.             {
  132.                 call ExileClient_object_player_thread_delirium;
  133.                 ExileClientDeliriumThread = [20, ExileClient_object_player_thread_delirium, [], true] call ExileClient_system_thread_addtask;
  134.             };
  135.         }
  136.         else
  137.         {
  138.             ExileClientPlayerEffects pushBack _effect;
  139.         }; 
  140.     }
  141.     foreach _configEffects;
  142.     _animations = getArray (_consumingConfig >> "animations");
  143.     if !(_animations isEqualTo []) then
  144.     {
  145.         if ((vehicle player) isEqualTo player) then
  146.         {
  147.             _animationIndex = call ExileClient_util_animation_getMatrixIndex;
  148.             player playMove (_animations select _animationIndex);
  149.         };
  150.     };
  151.     _stopBleeding = getNumber (_consumingConfig >> "stopBleeding");
  152.     if (_stopBleeding isEqualTo 1) then
  153.     {
  154.         player setBleedingRemaining 0;
  155.     };
  156.     _configSounds = getArray (_consumingConfig >> "sounds");
  157.     _numberOfConfigSounds = count _configSounds;
  158.     if( _numberOfConfigSounds > 0 ) then
  159.     {
  160.         playSound (_configSounds select (floor (random _numberOfConfigSounds)));
  161.     };
  162.     player removeItem _itemClassName;
  163.     _returnItemClass = getText (_consumingConfig >> "returnedItem");
  164.     if( _returnItemClass != "" ) then
  165.     {
  166.         player addItem _returnItemClass;
  167.     };
  168.     if( _feedbackString != "") then
  169.     {
  170.         ["SuccessTitleAndText", ["Consumed item!", _feedbackString]] call ExileClient_gui_toaster_addTemplateToast;
  171.     };
  172. };
  173. true
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment