SHARE
TWEET

Untitled

a guest May 19th, 2017 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Credit to Backwardsman97 for Textdraw
  2.  
  3. #include <a_samp>
  4.  
  5. new Text:HealthBar[MAX_PLAYERS];
  6. new showHB[MAX_PLAYERS];
  7.  
  8. public OnFilterScriptInit()
  9. {
  10.     print("\n------------------------------------");
  11.     print(" Health Bar - Loaded - by BSRK ");
  12.     print("------------------------------------\n");
  13.     for(new i; i<MAX_PLAYERS; i++)
  14.     {
  15.         if(IsPlayerConnected(i))
  16.         {
  17.             showHB[i] = 1;
  18.             HealthBar[i] = TextDrawCreate(549.000000,52.000000,".");
  19.             TextDrawAlignment(HealthBar[i],1);
  20.             TextDrawBackgroundColor(HealthBar[i],0x00ff00ff);
  21.             TextDrawFont(HealthBar[i],3);
  22.             TextDrawLetterSize(HealthBar[i],0.569999,2.549999);
  23.             TextDrawColor(HealthBar[i],i);
  24.             TextDrawSetOutline(HealthBar[i],1);
  25.             TextDrawSetProportional(HealthBar[i],1);
  26.             TextDrawSetShadow(HealthBar[i],1);
  27.             if(showHB[i]) TextDrawShowForPlayer(i,HealthBar[i]);
  28.         }
  29.     }
  30. }
  31.  
  32. public OnFilterScriptExit()
  33. {
  34.     for(new i; i<MAX_PLAYERS; i++)
  35.     {
  36.         if(IsPlayerConnected(i))
  37.         {
  38.             TextDrawDestroy(HealthBar[i]);
  39.         }
  40.     }
  41.     return 1;
  42. }
  43.  
  44. public OnPlayerConnect(playerid)
  45. {
  46.     if(IsPlayerNPC(playerid)) return 0;
  47.    
  48.     showHB[playerid] = 1;
  49.     HealthBar[playerid] = TextDrawCreate(549.000000,52.000000,".");
  50.     TextDrawAlignment(HealthBar[playerid],1);
  51.     TextDrawBackgroundColor(HealthBar[playerid],0x00ff00ff);
  52.     TextDrawFont(HealthBar[playerid],3);
  53.     TextDrawLetterSize(HealthBar[playerid],0.569999,2.549999);
  54.     TextDrawColor(HealthBar[playerid],0x00ff0033);
  55.     TextDrawSetOutline(HealthBar[playerid],1);
  56.     TextDrawSetProportional(HealthBar[playerid],1);
  57.     TextDrawSetShadow(HealthBar[playerid],1);
  58.     TextDrawShowForPlayer(playerid,HealthBar[playerid]);
  59.     return 1;
  60. }
  61.  
  62. public OnPlayerDisconnect(playerid)
  63. {
  64.     TextDrawDestroy(HealthBar[playerid]);
  65.     return 1;
  66. }
  67.  
  68. public OnPlayerDeath(playerid)
  69. {
  70.     TextDrawHideForPlayer(playerid,HealthBar[playerid]);
  71.     return 1;
  72. }
  73.  
  74. public OnPlayerSpawn(playerid)
  75. {
  76.     if(showHB[playerid])
  77.     {
  78.         TextDrawShowForPlayer(playerid,HealthBar[playerid]);
  79.     }
  80.     return 1;
  81. }
  82.  
  83. public OnPlayerUpdate(playerid)
  84. {
  85.     new Float:Health;
  86.     GetPlayerHealth(playerid,Health);
  87.    
  88.     if(showHB[playerid] == 1)
  89.     {
  90.         if(Health >= 200)
  91.         {
  92.             TextDrawSetString(HealthBar[playerid],"..........");
  93.         }
  94.         else if(Health >= 190)
  95.         {
  96.             TextDrawSetString(HealthBar[playerid],".........");
  97.         }
  98.         else if(Health >= 180)
  99.         {
  100.             TextDrawSetString(HealthBar[playerid],"........");
  101.         }
  102.         else if(Health >= 170)
  103.         {
  104.             TextDrawSetString(HealthBar[playerid],".......");
  105.         }
  106.         else if(Health >= 160)
  107.         {
  108.             TextDrawSetString(HealthBar[playerid],"......");
  109.         }
  110.         else if(Health >= 150)
  111.         {
  112.             TextDrawSetString(HealthBar[playerid],".....");
  113.         }
  114.         else if(Health >= 140)
  115.         {
  116.             TextDrawSetString(HealthBar[playerid],"....");
  117.         }
  118.         else if(Health >= 130)
  119.         {
  120.             TextDrawSetString(HealthBar[playerid],"...");
  121.         }
  122.         else if(Health >= 120)
  123.         {
  124.             TextDrawSetString(HealthBar[playerid],"..");
  125.         }
  126.         else if(Health >= 110)
  127.         {
  128.             TextDrawSetString(HealthBar[playerid],".");
  129.         }
  130.         else if(Health <= 100)
  131.         {
  132.             TextDrawSetString(HealthBar[playerid],"");
  133.         }
  134.     }
  135.     return 1;
  136. }
  137.  
  138. public OnPlayerCommandText(playerid, cmdtext[])
  139. {
  140.     if(strcmp(cmdtext, "/healthbar", true) == 0)
  141.     {
  142.         if(IsPlayerConnected(playerid))
  143.         {
  144.             if(showHB[playerid])
  145.             {
  146.                 SendClientMessage(playerid,0xFF8000FF, "[WARNING]: HeathBar textdraw On!!");
  147.                 TextDrawHideForPlayer(playerid,HealthBar[playerid]);
  148.                 showHB[playerid] = 0;
  149.             }
  150.             else if(!showHB[playerid])
  151.             {
  152.                 SendClientMessage(playerid,0xFF8000FF, "[WARNING]: HeathBar textdraw Off!!");
  153.                 TextDrawShowForPlayer(playerid,HealthBar[playerid]);
  154.                 showHB[playerid] = 1;
  155.             }
  156.         }
  157.         else
  158.         {
  159.             SendClientMessage(playerid,0xFF8000FF, "[WARNING]: You are not login.");
  160.         }
  161.     }
  162. }
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top