Guest User

Bert

a guest
Sep 9th, 2008
1,407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. //Made By Bert
  4.  
  5. #define COLOR_GREEN 0x00B000FF
  6. #define COLOR_ORANGE 0xFF9900AA
  7. #define COLOR_RED 0xFF4646FF
  8.  
  9. new N2ETimer[MAX_PLAYERS];
  10. new IsHungry[MAX_PLAYERS];
  11. new Float:Health[MAX_PLAYERS];
  12. new Float:tmpHealth[MAX_PLAYERS];
  13. new N2ECount[MAX_PLAYERS];
  14.  
  15. public OnFilterScriptInit()
  16. {
  17. print("\n--------------------------------------");
  18. print(" Hunger & need to eat filterscript ");
  19. print("--------------------------------------\n");
  20. SetTimer("TakeHealthDown", 2500, 1);
  21. return 1;
  22. }
  23.  
  24. public OnPlayerDisconnect(playerid, reason)
  25. {
  26. KillTimer(N2ETimer[playerid]);
  27. IsHungry[playerid] = 0;
  28. return 1;
  29. }
  30.  
  31. public OnPlayerSpawn(playerid)
  32. {
  33. N2ETimer[playerid] = SetTimerEx("NeedsToEat", 300000, 0, "i", playerid);
  34. IsHungry[playerid] = 0;
  35. return 1;
  36. }
  37.  
  38. public OnPlayerDeath(playerid, killerid, reason)
  39. {
  40. KillTimer(N2ETimer[playerid]);
  41. IsHungry[playerid] = 0;
  42. return 1;
  43. }
  44.  
  45. forward NeedsToEat(playerid);
  46. public NeedsToEat(playerid)
  47. {
  48. SendClientMessage(playerid, COLOR_ORANGE, "* You're starting to feel hungry!");
  49. IsHungry[playerid] = 1;
  50. N2ECount[playerid] = 0;
  51. GetPlayerHealth(playerid, Health[playerid]);
  52. if(Health[playerid] == 100.0)
  53. {
  54. Health[playerid] = 99.0;
  55. SetPlayerHealth(playerid, 99.0);
  56. }
  57. SetTimerEx("NeedsToEat2", 1000, 0, "i", playerid);
  58. }
  59.  
  60. forward NeedsToEat2(playerid);
  61. public NeedsToEat2(playerid)
  62. {
  63. if(IsHungry[playerid])
  64. {
  65. if(N2ECount[playerid] >= 0 && N2ECount[playerid] < 60)
  66. {
  67. GetPlayerHealth(playerid, tmpHealth[playerid]);
  68. if(tmpHealth[playerid] > Health[playerid])
  69. {
  70. SendClientMessage(playerid, COLOR_GREEN, "* You satisfied your tummy by eating or drinking!");
  71. IsHungry[playerid] = 0;
  72. N2ETimer[playerid] = SetTimerEx("NeedsToEat", 300000, 0, "i", playerid);
  73. }
  74. else
  75. {
  76. SetTimerEx("NeedsToEat2", 1000, 0, "i", playerid);
  77. N2ECount[playerid] ++;
  78. }
  79. }
  80. else
  81. {
  82. SendClientMessage(playerid, COLOR_ORANGE, "* You're starting to feel really week, hurry to get some food before you pass out!");
  83. IsHungry[playerid] = 2;
  84. }
  85. }
  86. }
  87.  
  88. forward TakeHealthDown();
  89. public TakeHealthDown()
  90. {
  91. for(new i = 0; i < MAX_PLAYERS; i ++)
  92. {
  93. if(IsPlayerConnected(i) && IsHungry[i] == 2)
  94. {
  95. GetPlayerHealth(i, tmpHealth[i]);
  96. if(tmpHealth[i] > Health[i])
  97. {
  98. SendClientMessage(i, COLOR_GREEN, "* You satisfied your tummy by eating or drinking!");
  99. IsHungry[i] = 0;
  100. N2ETimer[i] = SetTimerEx("NeedsToEat", 300000, 0, "i", i);
  101. }
  102. GetPlayerHealth(i, Health[i]);
  103. SetPlayerHealth(i, tmpHealth[i] -1);
  104. if(tmpHealth[i] < 5)
  105. {
  106. SendClientMessage(i, COLOR_RED, "* You're starving from hunger! Run in terror!");
  107. }
  108. }
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment