Szerző Téma: hpBar  (Megtekintve 931 alkalommal)

Nem elérhető totar

  • 425
    • Profil megtekintése
hpBar
« Dátum: 2011. június 30. - 11:14:50 »
0 Show voters
Üdv
Már láttam itt valahol hogy valaki csinált egy hpbart.
Olyan ha lellyebb megy a hp akkor változik a szine.
Ilyen fajta:
 

#include <a_samp>
#include <progress>
new Bar:vhealth[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
forward ProgressBar();
public OnFilterScriptInit()
{
SetTimer(\"ProgressBar\", 500, 1);
return 1;
}
public ProgressBar() //I prefer not to use OnPlayerUpdate with textdraws
{
for(new playerid; playerid < MAX_PLAYERS; playerid++) //I recommend foreach(Player, playerid)
{
new vehicleid;
if((vehicleid = GetPlayerVehicleID(playerid)) && vhealth[playerid] != INVALID_BAR_ID)
{
   new Float:health;
   GetVehicleHealth(vehicleid, health);
   SetProgressBarValue(vhealth[playerid], health);
   UpdateProgressBar(vhealth[playerid], playerid);
}
}
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_DRIVER)
{
DestroyProgressBar(vhealth[playerid]);
vhealth[playerid] = INVALID_BAR_ID;
}
if(newstate == PLAYER_STATE_DRIVER)
{
vhealth[playerid] = CreateProgressBar(548.5, 36.0, _, _, 0x00FF00FF, 1000.0);
ShowProgressBarForPlayer(playerid, vhealth[playerid]);
}
return 1;
}

 
Pls adjon vki egy linket.
pls

Nem elérhető ►ѕтa

  • 2016
  • Newbie
    • Profil megtekintése
hpBar
« Válasz #1 Dátum: 2011. június 30. - 17:47:11 »
0 Show voters
[pawn]
#include <a_samp>
#include <progress>
new Bar:vhealth[MAX_PLAYERS] = {INVALID_BAR_ID, ...};
forward ProgressBar();
public OnFilterScriptInit()
{
SetTimer(\"ProgressBar\", 500, 1);
return 1;
}
public ProgressBar() //I prefer not to use OnPlayerUpdate with textdraws
{
for(new i; i < MAX_PLAYERS; i++) //I recommend foreach(Player, playerid)
{
   new vehicleid = GetPlayerVehicleID(playerid);
   if(IsPlayerInAnyVehicle(playerid) && vhealth[playerid] != INVALID_BAR_ID)
   {
      new Float:health;
      GetVehicleHealth(vehicleid, health);
      SetProgressBarValue(vhealth[playerid], health);
      UpdateProgressBar(vhealth[playerid], playerid);
      if(health >= 750 || health <= 1000)
      {
         SetProgressBarColor(vhealth[playerid], 0x00FF00FF);
      } else if(health >= 500 || health <= 749) {
         SetProgressBarColor(vhealth[playerid], 0xFFD500AA);
      } else if(health >= 250 || health <= 499) {
         SetProgressBarColor(vhealth[playerid], 0xFF0000AA);
      }
   }
}
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_DRIVER)
{
   DestroyProgressBar(vhealth[playerid]);
   vhealth[playerid] = INVALID_BAR_ID;
}
if(newstate == PLAYER_STATE_DRIVER)
{
   vhealth[playerid] = CreateProgressBar(548.5, 36.0, _, _, 0x00FF00FF, 1000.0);
   ShowProgressBarForPlayer(playerid, vhealth[playerid]);
}
return 1;
}
[/pawn]

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal