Guest User

Untitled

a guest
May 10th, 2010
3,703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.48 KB | None | 0 0
  1. //System Hungry By David Sean
  2.  
  3. #include <a_samp>
  4.  
  5.  
  6. //Hungry Systems
  7.  
  8. #define FILTERSCRIPT
  9.  
  10. //Includes
  11. #include <a_samp>
  12.  
  13. #undef MAX_PLAYERS       //
  14. #define MAX_PLAYERS 50  //Change this to your player slot amount
  15. #define N2E_TIME 600000//Edit this value to change the timer, now = 10 mins
  16. #define LOOSING_HP 21  //The HP the player will lose You can set it                            |
  17.  
  18. #define COLOR_YELLOW 0xDABB3EAA
  19.  
  20. //Forwards
  21. forward NeedToEat(playerid);
  22.  
  23. //Arrays
  24. new FirstSpawn[MAX_PLAYERS];
  25. new Float:CurHealth[MAX_PLAYERS];
  26.  
  27.  
  28. new Text:HealthBar[MAX_PLAYERS];
  29.  
  30. public OnFilterScriptInit()
  31. {
  32.     for(new i; i<MAX_PLAYERS; i++)
  33.     {
  34.         if(IsPlayerConnected(i))
  35.         {
  36.             OnPlayerConnect(i);
  37.         }
  38.     }
  39.     return 1;
  40. }
  41.  
  42. public OnFilterScriptExit()
  43. {
  44.     for(new i; i<MAX_PLAYERS; i++)
  45.     {
  46.         if(IsPlayerConnected(i))
  47.         {
  48.             TextDrawDestroy(HealthBar[i]);
  49.         }
  50.     }
  51.     return 1;
  52. }
  53.  
  54. public OnPlayerConnect(playerid)
  55. {
  56.     HealthBar[playerid] = TextDrawCreate(549.000000,52.000000,"..........");
  57.     TextDrawAlignment(HealthBar[playerid],1);
  58.     TextDrawBackgroundColor(HealthBar[playerid],0x00ff00ff);
  59.     TextDrawFont(HealthBar[playerid],3);
  60.     TextDrawLetterSize(HealthBar[playerid],0.569999,2.549999);
  61.     TextDrawColor(HealthBar[playerid],0x00ff0033);
  62.     TextDrawSetOutline(HealthBar[playerid],1);
  63.     TextDrawSetProportional(HealthBar[playerid],1);
  64.     TextDrawSetShadow(HealthBar[playerid],1);
  65.     return 1;
  66. }
  67.  
  68. public OnPlayerDisconnect(playerid)
  69. {
  70.     TextDrawDestroy(HealthBar[playerid]);
  71.     return 1;
  72. }
  73.  
  74. public OnPlayerDeath(playerid)
  75. {
  76.     TextDrawHideForPlayer(playerid,HealthBar[playerid]);
  77.     return 1;
  78. }
  79.  
  80. public OnPlayerSpawn(playerid)
  81. {
  82.     TextDrawSetString(HealthBar[playerid],"..........");
  83.     TextDrawShowForPlayer(playerid,HealthBar[playerid]);
  84.     FirstSpawn[playerid] += 1;
  85.     new Float:health;
  86.     GetPlayerHealth(playerid, health);
  87.     CurHealth[playerid] = health;
  88.     if(FirstSpawn[playerid] == 1) SetTimerEx("Hungry",N2E_TIME,1,"i",playerid);
  89.  
  90.     return 1;
  91. }
  92.  
  93. public OnPlayerUpdate(playerid)
  94. {
  95.     new Float:Health;
  96.     GetPlayerHealth(playerid,Health);
  97.     if(Health >= 90)
  98.     {
  99.         TextDrawSetString(HealthBar[playerid],"..........");
  100.         return 1;
  101.     }
  102.     if(Health >= 80)
  103.     {
  104.         TextDrawSetString(HealthBar[playerid],".........");
  105.         return 1;
  106.     }
  107.     if(Health >= 70)
  108.     {
  109.         TextDrawSetString(HealthBar[playerid],"........");
  110.         return 1;
  111.     }
  112.     if(Health >= 60)
  113.     {
  114.         TextDrawSetString(HealthBar[playerid],".......");
  115.         return 1;
  116.     }
  117.     if(Health >= 50)
  118.     {
  119.         TextDrawSetString(HealthBar[playerid],"......");
  120.         return 1;
  121.     }
  122.     if(Health >= 40)
  123.     {
  124.         TextDrawSetString(HealthBar[playerid],".....");
  125.         return 1;
  126.     }
  127.     if(Health >= 30)
  128.     {
  129.         TextDrawSetString(HealthBar[playerid],"....");
  130.         return 1;
  131.     }
  132.     if(Health >= 20)
  133.     {
  134.         TextDrawSetString(HealthBar[playerid],"...");
  135.         return 1;
  136.     }
  137.     if(Health >= 10)
  138.     {
  139.         TextDrawSetString(HealthBar[playerid],"..");
  140.         return 1;
  141.     }
  142.     if(Health > 0)
  143.     {
  144.         TextDrawSetString(HealthBar[playerid],".");
  145.         return 1;
  146.     }
  147.     return 1;
  148. }
  149. //========================================================================
  150.  
  151.  
  152. public NeedToEat(playerid)
  153. {
  154.     new Float:health;
  155.     GetPlayerHealth(playerid, health);
  156.     if(CurHealth[playerid] >= health)
  157.     {
  158.      SendClientMessage(playerid,COLOR_YELLOW,"You is start to Hungry, You need to eat");
  159.      SetPlayerHealth(playerid,health-LOOSING_HP);
  160.      CurHealth[playerid] = health;
  161.     }
  162.     else
  163.     {
  164.      CurHealth[playerid] = health;
  165.     }
  166. }
Advertisement
Add Comment
Please, Sign In to add comment