Advertisement
Guest User

my player_selfbloodbag.sqf

a guest
Dec 7th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.23 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////////////////////////
  2. // Script writen by Krixes //
  3. // Infection chance and some comments added by Player2 //
  4. // Combat check added by istealth //
  5. // //
  6. // Version 1.4 //
  7. // //
  8. // Change Log: //
  9. // 1: Added bloodbag use timer //
  10. // 2: Added a timer for the amount of time before player can use self bloodbag again //
  11. //////////////////////////////////////////////////////////////////////////////////////////////
  12.  
  13. private ["_bloodAmount","_humanityBool","_infectionChance","_humanityNegBool","_humanityNegAmount","_humanityAmount","_infectedLifeLost","_infectedLifeBool","_lastBloodbag","_bloodbagLastUsedTime","_bloodbagTime","_bloodbagUseTime","_bloodbagUsageTime","_incombat","_timeout"];
  14.  
  15.  
  16.  
  17. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  18. // Config Start-----------------------------------------------------------------------------------------------------------------------//
  19. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  20.  
  21. _bloodAmount = 4000; // Amount of blood to give to player
  22. _bloodbagUseTime = 30; // Amount of time it takes in second for the player to use the self bloodbag
  23. _bloodbagLastUsedTime = 60; // Amount of time in seconds before player can use self bloodbag again after a succesful use
  24.  
  25. _infectionChance = 10; // Percent chance of player infection on self bloodbag (10 = 10% | 2 = 50% | 1 = 100%)
  26. _infectedLifeBool = true; // Whether the player can loose life if infected (True = On | False = off)
  27. _infectedLifeLost = 1000; // Amount of life to loose in becomes infected
  28.  
  29. _humanityBool = false; // Whether the player can get humanity from giving self a bloodbag (True = On | False = off)
  30. _humanityAmount = 50; // Amount of humanity to give player if _humanityBool is true (250 is default for normal bloodbags)
  31.  
  32. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  33. // Config End-------------------------------------------------------------------------------------------------------------------------//
  34. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  35.  
  36.  
  37.  
  38.  
  39.  
  40. ///////////////////////////////////////////////////////////////////////////////
  41. // Everything below need not be modified unless you know what you are doing! //
  42. ///////////////////////////////////////////////////////////////////////////////
  43.  
  44. _bloodbagTime = time - lastBloodbag; // Variable used for easy reference in determining the self bloodbag cooldown
  45. _bloodbagUsageTime = time;
  46. _timeout = player getVariable["combattimeout", 0];
  47. _inCombat = if (_timeout >= diag_tickTime) then { true } else { false };
  48.  
  49. if(_bloodbagTime < _bloodbagLastUsedTime) exitWith { // If cooldown is not done then exit script
  50. cutText [format["You may not use Self Bloodbag this soon please wait %1!",(_bloodbagTime - _bloodbagLastUsedTime)], "PLAIN DOWN"]; //display text at bottom center of screen when players cooldown is not done
  51. };
  52.  
  53. if (_inCombat) then { // Check if in combat
  54. cutText [format["You are in Combat and cannot give yourself a Bloodbag"], "PLAIN DOWN"]; //display text at bottom center of screen when in combat
  55. } else {
  56.  
  57. player removeAction s_player_selfBloodbag; //remove the action from users scroll menu
  58.  
  59. player playActionNow "Medic"; //play bloodbag animation
  60.  
  61. ////////////////////////////////////////////////
  62. // Fancy cancel if interrupted addition start //
  63. ////////////////////////////////////////////////
  64. r_interrupt = false; // public interuppt variable
  65. _animState = animationState player; // get the animation state of the player
  66. r_doLoop = true; // while true sets whether to continue self bloodbagging
  67. _started = false; // this starts as false as a check
  68. _finished = false; // this starts as false and when true later sets players blood
  69. while {r_doLoop} do {
  70. _animState = animationState player; // keep checking to make sure player is in correct animation
  71. _isMedic = ["medic",_animState] call fnc_inString; // checking to make sure the animstate is the medic animation still
  72. if (_isMedic) then {
  73. _started = true; // this is a check to make sure everything is still ok
  74. };
  75. if(!_isMedic && !r_interrupt && (time - _bloodbagUsageTime) < _bloodbagUseTime) then {
  76. player playActionNow "Medic"; //play bloodbag animation
  77. _isMedic = true;
  78. };
  79. if (_started && !_isMedic && (time - _bloodbagUsageTime) > _bloodbagUseTime) then {
  80. r_doLoop = false; // turns off the loop
  81. _finished = true; // set finished to true to finish the self bloodbag and give player health/humanity
  82. lastBloodbag = time; // the last self bloodbag time
  83. };
  84. if (r_interrupt) then {
  85. r_doLoop = false; // if interuppted turns loop off early so _finished is never true
  86. };
  87. sleep 0.1;
  88. };
  89. r_doLoop = false; // make sure loop is off on successful self bloodbag
  90. ///////////////////////////////////////////////
  91. // Fancy cancel if interrupted addition end //
  92. //////////////////////////////////////////////
  93.  
  94. if (_finished) then {
  95. player removeMagazine "ItemBloodbag"; //remove the used bloodbag from inventory
  96.  
  97. r_player_blood = r_player_blood + _bloodAmount; //set players LOCAL blood to a certain ammount
  98.  
  99. if(r_player_blood > 12000) then {
  100. r_player_blood = 12000; // If players blood is greater then max amount allowed set it to max allowed (this check keeps an error at bay)
  101. };
  102.  
  103. // check if infected
  104. if (random(_infectionChance) < 1) then {
  105. r_player_infected = true; //set players client to show infection
  106. player setVariable["USEC_infected",true,true]; //tell the server the player is infected
  107. cutText [format["You have used a bloodbag on yourself but the bloodbag was infected!"], "PLAIN DOWN"]; //display text at bottom center of screen if infected
  108.  
  109. // check for if loosing life on infection is turned on
  110. if(_infectedLifeBool) then {
  111. r_player_blood = r_player_blood - _infectedLifeLost; //set players LOCAL blood to a certain ammount
  112. player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database
  113. } else { // if loosing life is turned off
  114. r_player_lowblood = false; //set lowblood setting to false
  115. 10 fadeSound 1; //slowly fade their volume back to maximum
  116. "dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5; //disable post processing blur effect
  117. "colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 1], [1, 1, 1, 1]];"colorCorrections" ppEffectCommit 5; //give them their colour back
  118. r_player_lowblood = false; //just double checking their blood isnt low
  119. player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database
  120. };
  121. } else { // if not infected
  122. r_player_lowblood = false; //set lowblood setting to false
  123. 10 fadeSound 1; //slowly fade their volume back to maximum
  124. "dynamicBlur" ppEffectAdjust [0]; "dynamicBlur" ppEffectCommit 5; //disable post processing blur effect
  125. "colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, 1], [1, 1, 1, 1]];"colorCorrections" ppEffectCommit 5; //give them their colour back
  126. r_player_lowblood = false; //just double checking their blood isnt low
  127. player setVariable["USEC_BloodQty",r_player_blood,true]; //save this blood ammount to the database
  128.  
  129. cutText [format["You have used a bloodbag on yourself!"], "PLAIN DOWN"]; //display text at bottom center of screen on succesful self bloodbag
  130. };
  131.  
  132. // check if giving player humanity is on
  133. if(_humanityBool) then {
  134. [player,_humanityAmount] call player_humanityChange; // Set players humanity based on amount listed in config area
  135. };
  136. } else {
  137. // this is for handling if interrupted
  138. r_interrupt = false;
  139. player switchMove "";
  140. player playActionNow "stop";
  141. cutText [format["You have interrupted giving yourself a bloodbag!"], "PLAIN DOWN"]; //display text at bottom center of screen on interrupt
  142. };
  143. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement