Advertisement
Guest User

Untitled

a guest
Jul 25th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.32 KB | None | 0 0
  1. new PlayersHungerTimer[MAX_PLAYERS];
  2. new PlayersHungerHealTimer[MAX_PLAYERS];
  3.  
  4. enum pInfo
  5. {
  6.     pHunger
  7. };
  8.  
  9. OnPlayerRegister
  10. {
  11.     PlayerInfo[playerid][pHunger] = 100;
  12. }
  13.  
  14. public OnPlayerConnect(playerid)
  15. {
  16.     PlayersHungerTimer[playerid] = SetTimerEx("HungerRemoval", 30000, 1, "i", playerid);
  17.     PlayersHungerHealTimer[playerid] = SetTimerEx("HungerHealthAddition", 60000, 1, "i", playerid);
  18.     return 1;
  19. }
  20.  
  21. public OnPlayerDisconnect(playerid,reason)
  22. {
  23.     KillTimer(PlayersHungerHealTimer[playerid]);
  24.     KillTimer(PlayersHungerTimer[playerid]);
  25.     return 1;
  26. }
  27.  
  28. forward HungerHealthAddition(playerid);
  29. public HungerHealthAddition(playerid)
  30. {
  31.     new Float:health;
  32.     if(PlayerInfo[playerid][pHunger] == 100)
  33.     {
  34.         GetPlayerHealth(playerid, health);
  35.         SetPlayerHealth(playerid, health+10);
  36.     }
  37.     if(PlayerInfo[playerid][pHunger] > 100 && GetPlayerHealth(playerid, health) < 100)
  38.     {
  39.         new healthh = 0;
  40.         healthh = PlayerInfo[playerid][pHunger] - 100;
  41.         GetPlayerHealth(playerid, health);
  42.         SetPlayerHealth(playerid, health+health);
  43.     }
  44. }
  45.  
  46. forward HungerRemoval(playerid);
  47. public HungerRemoval(playerid)
  48. {
  49.     PlayerInfo[playerid][pHunger] -= 10;
  50.     if(PlayerInfo[playerid][pHunger] <= 0)
  51.     {
  52.         new Float:health;
  53.         GetPlayerHealth(playerid, health);
  54.         SetPlayerHealth(playerid, health-5);
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement