Like in jctf when users use a adrenaline it shows a hud
x of 100 adrenaline used
where x is the amount of adrenaline left ..
And as soon as x=0 the adrenaline ends
Here's the code
PHP Code:
public player_adrenalineDrain(id)
{
id += TASK_ADRENALINE
if(!g_bAlive[id] || !g_iAdrenalineUse[id] || !(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE))
{
g_iAdrenaline[id] = 0
return
}
if(g_iAdrenaline[id] > 0)
{
new iDrain = (player_hasFlag(id) ? 2 : 1)
g_iAdrenaline[id] = clamp(g_iAdrenaline[id] - (g_iAdrenalineUse[id] == ADRENALINE_REGENERATE ? iDrain : iDrain * 2), 0, 100)
switch(g_iAdrenalineUse[id])
{
case ADRENALINE_REGENERATE:
{
new iHealth = get_user_health(id)
if(iHealth < (g_iMaxHealth[id] + REGENERATE_EXTRAHP))
set_user_health(id, iHealth + 1)
else
{
new CsArmorType:ArmorType
new iArmor = cs_get_user_armor(id, ArmorType)
if(iArmor < g_iMaxArmor[id])
cs_set_user_armor(id, iArmor + 1, ArmorType)
}
player_healingEffect(id)
}
}
task_set(0.25, "player_adrenalineDrain", id - TASK_ADRENALINE)
}
else
{
new iUsed = g_iAdrenalineUse[id]
g_iAdrenaline[id] = 0
g_iAdrenalineUse[id] = 0 /* to allow player_updateSpeed() to work correctly */
switch(iUsed)
{
case ADRENALINE_SPEED:
{
player_updateSpeed(id)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_KILLBEAM)
write_short(id)
message_end()
}
case ADRENALINE_BERSERK, ADRENALINE_INVISIBILITY: player_updateRender(id)
}
}
player_hudAdrenaline(id)
}
I want to use a same drain function ..
For example if i buy a power for 100 money
then it would show a hud with .. of 100 money left
and as its 0 it would end ...
Any helps please ?