Advertisement
Guest User

Injury System

a guest
May 16th, 2016
3,122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.55 KB | None | 0 0
  1. // Injury System by GoldenLion
  2. #define FILTERSCRIPT
  3. #define COLOR_GRAY 0xAFAFAFFF
  4. #define COLOR_LIGHTRED 0xFF6347FF
  5.  
  6. #include <a_samp>
  7. #include <zcmd>
  8. #include <sscanf2>
  9.  
  10. #if defined FILTERSCRIPT
  11.  
  12. new Injured[MAX_PLAYERS];
  13. new AcceptDeath[MAX_PLAYERS];
  14. new AcceptDeathTimer[MAX_PLAYERS];
  15. new LoseHealthTimer[MAX_PLAYERS];
  16. new Hospitalized[MAX_PLAYERS];
  17. new Float:x, Float:y, Float:z;
  18. new Float:angle;
  19.  
  20. forward CanAcceptDeath(playerid);
  21. public CanAcceptDeath(playerid)
  22. {
  23. AcceptDeath[playerid] = 1;
  24. SendClientMessage(playerid, COLOR_GRAY, "You can now accept death.");
  25. }
  26.  
  27. forward HospitalTimer(playerid);
  28. public HospitalTimer(playerid)
  29. {
  30. Hospitalized[playerid] = 0;
  31. SendClientMessage(playerid, -1, "You have recovered at the All Saints General Hospital.");
  32. SetPlayerPos(playerid, 1178.4012, -1323.2754, 14.1183);
  33. SetPlayerFacingAngle(playerid, 270.0);
  34. SetCameraBehindPlayer(playerid);
  35. SetPlayerHealth(playerid, 100.0);
  36. TogglePlayerControllable(playerid,1);
  37. }
  38.  
  39. forward LoseHealth(playerid);
  40. public LoseHealth(playerid)
  41. {
  42. new Float:health;
  43. GetPlayerHealth(playerid,health);
  44. SetPlayerHealth(playerid,health-5);
  45. }
  46.  
  47. public OnPlayerUpdate(playerid)
  48. {
  49. if (Injured[playerid] == 1 && GetPlayerAnimationIndex(playerid) != 386)
  50. {
  51. ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 1, 0, 1);
  52. }
  53. return 1;
  54. }
  55.  
  56. public OnPlayerDeath(playerid, killerid, reason)
  57. {
  58. if (Injured[playerid] == 0)
  59. {
  60. Injured[playerid] = 1;
  61. GetPlayerPos(playerid, x, y, z);
  62. GetPlayerFacingAngle(playerid, angle);
  63. }
  64. else if (Injured[playerid] == 1)
  65. {
  66. KillTimer(AcceptDeathTimer[playerid]);
  67. KillTimer(LoseHealthTimer[playerid]);
  68. AcceptDeath[playerid] = 0;
  69. Injured[playerid] = 0;
  70. Hospitalized[playerid] = 1;
  71. }
  72. return 1;
  73. }
  74.  
  75. public OnPlayerSpawn(playerid)
  76. {
  77. if (Injured[playerid] == 1)
  78. {
  79. SetPlayerPos(playerid, x, y, z);
  80. SetPlayerFacingAngle(playerid, angle);
  81. SetCameraBehindPlayer(playerid);
  82. SendClientMessage(playerid, COLOR_LIGHTRED, "You are injured.");
  83. SendClientMessage(playerid, COLOR_LIGHTRED, "Either wait for assistance or /acceptdeath.");
  84. AcceptDeathTimer[playerid] = SetTimer("CanAcceptDeath", 60000, false);
  85. LoseHealthTimer[playerid] = SetTimer("LoseHealth", 10000, true);
  86. ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 1, 0, 1);
  87. }
  88.  
  89. if (Hospitalized[playerid] == 1)
  90. {
  91. SetTimer("HospitalTimer", 10000, false);
  92. TogglePlayerControllable(playerid,0);
  93. SetPlayerPos(playerid, 1169.9645, -1323.8893, 15.6929);
  94. SetPlayerCameraPos(playerid, 1201.5150, -1323.3530, 24.7329);
  95. SetPlayerCameraLookAt(playerid, 1173.2358, -1323.2872, 19.4348);
  96. SendClientMessage(playerid, COLOR_GRAY, "You must stay 10 seconds at the hospital to recover.");
  97. GameTextForPlayer(playerid, "~n~~w~Recovering...", 10000, 3);
  98. }
  99. return 1;
  100. }
  101.  
  102. CMD:acceptdeath(playerid, params[])
  103. {
  104. if (Injured[playerid] == 1)
  105. {
  106. if (AcceptDeath[playerid] == 1)
  107. {
  108. SetPlayerHealth(playerid, 0.0);
  109. KillTimer(LoseHealthTimer[playerid]);
  110. SendClientMessage(playerid, COLOR_GRAY, "You have accepted death.");
  111.  
  112. }
  113. else if (AcceptDeath[playerid] == 0)
  114. {
  115. SendClientMessage(playerid, COLOR_GRAY, "You must wait at least 1 minute before accepting death.");
  116. }
  117. }
  118. else if (Injured[playerid] == 0)
  119. {
  120. SendClientMessage(playerid, COLOR_GRAY, "You are not injured right now.");
  121. }
  122. return 1;
  123. }
  124.  
  125. CMD:revive(playerid, params[])
  126. {
  127. new targetid;
  128.  
  129. if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GRAY, "You are not an admin.");
  130.  
  131. if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_GRAY, "Usage: /revive [playerid]");
  132.  
  133. if (targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GRAY, "That player is not online.");
  134.  
  135. if (Injured[targetid] == 0) return SendClientMessage(playerid, COLOR_GRAY, "That player is not injured.");
  136.  
  137. new playername[MAX_PLAYER_NAME];
  138. GetPlayerName(playerid, playername, sizeof(playername));
  139.  
  140. new targetname[MAX_PLAYER_NAME];
  141. GetPlayerName(targetid, targetname, sizeof(targetname));
  142.  
  143. new string[24+MAX_PLAYER_NAME];
  144.  
  145. format(string, sizeof(string), "You have revived %s.", targetname);
  146. SendClientMessage(playerid, -1, string);
  147.  
  148. format(string, sizeof(string), "%s has revived you.", playername);
  149. SendClientMessage(targetid, -1, string);
  150.  
  151. KillTimer(AcceptDeathTimer[targetid]);
  152. KillTimer(LoseHealthTimer[targetid]);
  153. AcceptDeath[targetid] = 0;
  154. Injured[targetid] = 0;
  155. ClearAnimations(targetid);
  156. SetPlayerHealth(targetid, 100.0);
  157. return 1;
  158. }
  159.  
  160. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement