28.02.2019, 13:33
PHP код:
#include <a_samp>
#include <stamina>
#include <progress2>
#include <zcmd>
new sbtime[MAX_PLAYERS];
new PlayerBar:StaminaBar[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
if(IsPlayerNPC(playerid)) return 1;
StaminaBar[playerid] = CreatePlayerProgressBar(playerid, 547.0, 30.0, 63.0, 5.0, 0xFFFFFFFF, 100.0, BAR_DIRECTION_RIGHT, 0x000000FF);
ShowPlayerProgressBar(playerid, StaminaBar[playerid]);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(IsPlayerNPC(playerid)) return 1;
DestroyPlayerProgressBar(playerid, StaminaBar[playerid]);
return 1;
}
public OnPlayerOutOfStamina(playerid)
{
ApplyAnimation(playerid, "PED", "IDLE_tired", 4.1, 0, 1, 1, 0, STAMINA_UPDATE_TIME*5, 1);
return 1;
}
CMD:sub(playerid, params[])
{
SetPlayerStaminaSubVal(playerid, strval(params));
return 1;
}
public OnPlayerUpdate(playerid)
{
new Float:stamina;
if(!IsPlayerNPC(playerid))
{
if(sbtime[playerid] != gettime())
{
GetPlayerStamina(playerid, stamina);
SetPlayerProgressBarValue(playerid, StaminaBar[playerid], stamina);
sbtime[playerid] = gettime();
}
}
return 1;
}