hurt.inc 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // TextDraw developed using Zamaroht's Textdraw Editor 1.0
  2. //functions
  3. forward ShowBloodForPlayer(playerid, loss);
  4. forward HideBloodForPlayer(playerid);
  5. forward IsPlayerHurt(playerid);
  6. //callbacks
  7. forward OnPlayerHurt(playerid, loss);
  8. static bool:shown[MAX_PLAYERS];
  9. static timer[MAX_PLAYERS];
  10. static Text:blood1;
  11. static Text:blood2;
  12. Hook:Hurt_OnGameModeInit() {
  13. blood1 = TextDrawCreate(-81.000000, -100.000000, "particle:bloodpool_64");
  14. TextDrawBackgroundColor(blood1, 255);
  15. TextDrawFont(blood1, 4);
  16. TextDrawLetterSize(blood1, 0.500000, 1.000000);
  17. TextDrawColor(blood1, -16776961);
  18. TextDrawSetOutline(blood1, 0);
  19. TextDrawSetProportional(blood1, 1);
  20. TextDrawSetShadow(blood1, 1);
  21. TextDrawUseBox(blood1, 1);
  22. TextDrawBoxColor(blood1, 0xFFFFFF70);
  23. TextDrawTextSize(blood1, 410.000000, 403.000000);
  24. blood2 = TextDrawCreate(199.000000, 210.000000, "particle:bloodpool_64");
  25. TextDrawBackgroundColor(blood2, 255);
  26. TextDrawFont(blood2, 4);
  27. TextDrawLetterSize(blood2, 0.500000, 1.000000);
  28. TextDrawColor(blood2, -16776961);
  29. TextDrawSetOutline(blood2, 0);
  30. TextDrawSetProportional(blood2, 1);
  31. TextDrawSetShadow(blood2, 1);
  32. TextDrawUseBox(blood2, 1);
  33. TextDrawBoxColor(blood2, 0xFFFFFF70);
  34. TextDrawTextSize(blood2, 410.000000, 403.000000);
  35. return 1;
  36. }
  37. //Check the status of the player
  38. public IsPlayerHurt(playerid) {
  39. if( shown[playerid] ) return true;
  40. else return false;
  41. }
  42. //Enable the hurt effects for player, playerid
  43. public ShowBloodForPlayer(playerid, Float:loss) {
  44. shown[playerid] = true;
  45. TextDrawShowForPlayer(playerid, blood1);
  46. TextDrawShowForPlayer(playerid, blood2);
  47. timer[playerid] = SetTimerEx("OnPlayerHurt", 500, true, "if", playerid, loss);
  48. return 1;
  49. }
  50. //What to do when the player is under hurting effects
  51. public HideBloodForPlayer(playerid, Float:loss) {
  52. /*if(shown[playerd]) {
  53. HideTextDrawForPlayer(playerid, blood1);
  54. HideTextDrawForPlayer(playerid, blood2);
  55. }
  56. else {
  57. ShowTextDrawForPlayer(playerid, blood1);
  58. ShowTextDrawForPlayer(playerid, blood2);
  59. }
  60. shown[playerd] = !shown[playerd];
  61. */
  62. new Float:health;
  63. GetPlayerHealth(playerid, health);
  64. SetPlayerHealth(playerid, health - loss )
  65. return 1;
  66. }
  67. //Stop the hurting effects
  68. public HidePlayerHurt(playerid) {
  69. shown[playerid] = false;
  70. KillTimer(timer[playerid]);
  71. TextDrawHideForPlayer(playerid, blood1);
  72. TextDrawHideForPlayer(playerid, blood2);
  73. return 1;
  74. }