Advertisement
Guest User

Untitled

a guest
Sep 27th, 2013
1,647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. /*
  2. ||||||||||||||||||||||||||||||||||||||||||||
  3. ||Hunger System by RedWolfX ||
  4. ||Do not re-release without my permisson ||
  5. ||Hunger bar is raising every 5 minutes ||
  6. ||To test it, use /makemehungry! ||
  7. ||Hope you will enjoy :) ||
  8. ||||||||||||||||||||||||||||||||||||||||||||
  9. */
  10. #include <a_samp>
  11. #include <progress>
  12. #include <zcmd>
  13. #define COLOR_WHITE 0xFFFFFFAA
  14. new Hungry[MAX_PLAYERS];
  15. new Bar:Hunger[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
  16. forward HungerTimer();
  17. public OnFilterScriptInit()
  18. {
  19. print("\n--------------------------------------");
  20. print(" Simple Hunger System By RedWolfX");
  21. print("--------------------------------------\n");
  22. SetTimer("HungerTimer", 300000, true);
  23. return 1;
  24. }
  25.  
  26. public OnFilterScriptExit()
  27. {
  28. return 1;
  29. }
  30.  
  31. public OnPlayerSpawn(playerid)
  32. {
  33. Hunger[playerid] = CreateProgressBar(549.00, 60.00, 57.50, 3.20, -16776961, 100.0);
  34. Hungry[playerid] = 0;
  35. return 1;
  36. }
  37.  
  38. public HungerTimer()
  39. {
  40. for(new i; i<MAX_PLAYERS; i++)
  41. {
  42. if(IsPlayerConnected(i))
  43. {
  44. Hungry[i] = Hungry[i] + 1;
  45. }
  46. }
  47. return 1;
  48. }
  49. public OnPlayerDeath(playerid, killerid, reason)
  50. {
  51. DestroyProgressBar(Hunger[playerid]);
  52. return 1;
  53. }
  54.  
  55. public OnPlayerUpdate(playerid)
  56. {
  57. SetProgressBarValue(Hunger[playerid], Hungry[ playerid ] * 10.0);
  58. UpdateProgressBar(Hunger[playerid], playerid);
  59. return 1;
  60. }
  61.  
  62. CMD:makemehungry(playerid,params[]) // You can delete this command - Its only for testing
  63. {
  64. SendClientMessage(playerid, COLOR_WHITE, "**Your hunger bar has been raised to 6!**");
  65. Hungry[playerid] = 6;
  66. return 1;
  67. }
  68.  
  69. CMD:eat(playerid,params[])
  70. {
  71. if(Hungry[playerid] > 5)
  72. {
  73. SendClientMessage(playerid, COLOR_WHITE, "**You are no longer hungry!**");
  74. Hungry[playerid] = 0;
  75. }
  76. else
  77. {
  78. SendClientMessage(playerid, COLOR_WHITE, "**You are not hungry**");
  79. }
  80. return 1;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement