Guest User

SA:MP L4D Heal

a guest
Feb 4th, 2012
586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. #include <a_samp>
  2. #include <progress>
  3.  
  4. #define HOLDING(%0) \
  5. ((newkeys & (%0)) == (%0))
  6.  
  7. #define RELEASED(%0) \
  8. (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
  9.  
  10. #define COLOR_RED 0xE81717AA
  11.  
  12. forward OnPlayerHealing(playerid);
  13.  
  14. enum hInfo
  15. {
  16. bool:Heal,
  17. bool:Give,
  18. bool:Get,
  19. Float:HPAdded,
  20. Bar:loading,
  21. hpl
  22. };
  23.  
  24. new Text:loadt;
  25. new HealthInfo[MAX_PLAYERS][hInfo];
  26.  
  27. stock GivePlayerHealPack(playerid)
  28. {
  29. HealthInfo[playerid][Heal] = true;
  30. HealthInfo[playerid][Get] = true;
  31. HealthInfo[playerid][Give] = false;
  32. HealthInfo[playerid][HPAdded] = 0.0;
  33. SetPlayerAttachedObject(playerid, 1, 1580, 1, 0.0, -0.06, 0.0, 88, 0.0, 0.0);
  34. TogglePlayerControllable(playerid, true);
  35. }
  36.  
  37. public OnFilterScriptInit()
  38. {
  39. print("/Left 4 Dead Healing script by GangSteR], [FD] Clan's healing script!/");
  40. print("/L4D Healing: ON! /");
  41. loadt = TextDrawCreate(228,354, "Healing yourself...");
  42. TextDrawFont(loadt,1);
  43. TextDrawColor(loadt, 0xFF0303AA);
  44. TextDrawSetShadow(loadt, 1);
  45. return 1;
  46. }
  47.  
  48. public OnFilterScriptExit()
  49. {
  50. print("L4D Healing: OFF! /");
  51. return 1;
  52. }
  53.  
  54. public OnPlayerConnect(playerid)
  55. {
  56. return 1;
  57. }
  58.  
  59. public OnPlayerDisconnect(playerid, reason)
  60. {
  61. HealthInfo[playerid][Heal] = false;
  62. HealthInfo[playerid][Give] = false;
  63. HealthInfo[playerid][Get] = false;
  64. return 1;
  65. }
  66.  
  67. public OnPlayerSpawn(playerid)
  68. {
  69. GivePlayerHealPack(playerid);
  70. return 1;
  71. }
  72.  
  73. public OnPlayerDeath(playerid, killerid, reason)
  74. {
  75. if(HealthInfo[playerid][Heal] == true)
  76. {
  77. HealthInfo[playerid][Heal] = false;
  78. HealthInfo[playerid][Get] = false;
  79. HealthInfo[playerid][Give] = false;
  80. HealthInfo[playerid][HPAdded] = 0.0;
  81. HideProgressBarForPlayer(playerid, HealthInfo[playerid][loading]);
  82. TextDrawHideForPlayer(playerid, loadt);
  83. DestroyProgressBar(HealthInfo[playerid][loading]);
  84. KillTimer(HealthInfo[playerid][hpl]);
  85. }
  86. return 1;
  87. }
  88.  
  89. public OnPlayerCommandText(playerid, cmdtext[])
  90. {
  91. if(strcmp("/Health", cmdtext, true, 10) == 0)
  92. {
  93. if(HealthInfo[playerid][Get] == true) return 0;
  94. GivePlayerHealPack(playerid);
  95. return 1;
  96. }
  97. return 0;
  98. }
  99.  
  100. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  101. {
  102. if(HOLDING(KEY_FIRE))
  103. {
  104. if(GetPlayerWeapon(playerid) == 0)
  105. {
  106. HealthInfo[playerid][loading] = CreateProgressBar(226.00, 370.00, 204.0, 14.9, 1687547306, 100.0);
  107. SetProgressBarColor(HealthInfo[playerid][loading], 0xFF0303AA);
  108. if(HealthInfo[playerid][Heal] == true)
  109. {
  110. new Float:a;
  111. ClearAnimations(playerid);
  112. GetPlayerFacingAngle(playerid, a);
  113. HealthInfo[playerid][Give] = true;
  114. HealthInfo[playerid][hpl] = SetTimerEx("OnPlayerHealing", 11, 1,"i", playerid);
  115. ShowProgressBarForPlayer(playerid, HealthInfo[playerid][loading]);
  116. TextDrawShowForPlayer(playerid, loadt);
  117. TogglePlayerControllable(playerid, 0);
  118. SetPlayerFacingAngle(playerid, a+180.0);
  119. ApplyAnimation(playerid, "MISC", "Idle_Chat_02", 4.1, 0, 1, 1, 1, 1);
  120. }
  121. }
  122. }
  123. if(RELEASED(KEY_FIRE))
  124. {
  125. if(GetPlayerWeapon(playerid) == 0)
  126. {
  127. if(HealthInfo[playerid][Heal] == true)
  128. {
  129. HealthInfo[playerid][Give] = false;
  130. HealthInfo[playerid][HPAdded] = 0.0;
  131. KillTimer(HealthInfo[playerid][hpl]);
  132. HideProgressBarForPlayer(playerid, HealthInfo[playerid][loading]);
  133. SetCameraBehindPlayer(playerid);
  134. TogglePlayerControllable(playerid, true);
  135. TextDrawHideForPlayer(playerid, loadt);
  136. ClearAnimations(playerid);
  137. DestroyProgressBar(HealthInfo[playerid][loading]);
  138.  
  139. }
  140. }
  141. }
  142. return 1;
  143. }
  144.  
  145. public OnPlayerHealing(playerid)
  146. {
  147. if(HealthInfo[playerid][Heal] == true)
  148. {
  149. if(HealthInfo[playerid][Give] == true)
  150. {
  151. if(HealthInfo[playerid][HPAdded] < 100.0)
  152. {
  153. HealthInfo[playerid][HPAdded] = HealthInfo[playerid][HPAdded]+0.15;
  154. SetProgressBarValue(HealthInfo[playerid][loading], HealthInfo[playerid][HPAdded]);
  155. UpdateProgressBar(HealthInfo[playerid][loading], playerid);
  156. ApplyAnimation(playerid, "MISC", "Idle_Chat_02", 4.1, 0, 1, 1, 1, 1);
  157. }
  158. else if(HealthInfo[playerid][HPAdded] > 100.0)
  159. {
  160. ClearAnimations(playerid);
  161. HealthInfo[playerid][HPAdded] = 0.0;
  162. HealthInfo[playerid][Heal] = false;
  163. HealthInfo[playerid][Give] = false;
  164. HealthInfo[playerid][Get] = false;
  165. HideProgressBarForPlayer(playerid, HealthInfo[playerid][loading]);
  166. SetCameraBehindPlayer(playerid);
  167. TextDrawHideForPlayer(playerid, loadt);
  168. RemovePlayerAttachedObject(playerid, 1);
  169. TogglePlayerControllable(playerid, true);
  170. SendClientMessage(playerid, COLOR_RED, "HEAL INFO: {FAF7F8}Charged your health successfully!");
  171. SetPlayerHealth(playerid, 100.0);
  172. DestroyProgressBar(HealthInfo[playerid][loading]);
  173. KillTimer(HealthInfo[playerid][hpl]);
  174. }
  175. }
  176. }
  177. }
Advertisement
Add Comment
Please, Sign In to add comment