Health and armour problem
#1

A problem I made a function with a health and kevlar textdraw and is not working
When i add it to the server its show 0
How to fix it?

pawn Код:
forward HealthTimer();
public HealthTimer()
{
    foreach(Player, i)
    {
        if(GetPlayerState(i)==PLAYER_STATE_SPAWNED) SetBarValues(i);
    }
}

stock SetBarValues(playerid)
{
    new Float:hp,Float:ap;
    GetPlayerHealth(playerid,hp);
    GetPlayerArmour(playerid,ap);
    ShowBars(playerid);
    switch(floatround(hp,floatround_round))
    {
        case 0:
        {
            SetHealthValue(playerid,0);
        }
        case 1..10:
        {
            SetHealthValue(playerid,1);
        }
        case 11..20:
        {
            SetHealthValue(playerid,2);
        }
        case 21..30:
        {
            SetHealthValue(playerid,3);
        }
        case 31..40:
        {
            SetHealthValue(playerid,4);
        }
        case 41..50:
        {
            SetHealthValue(playerid,5);
        }
        case 51..60:
        {
            SetHealthValue(playerid,6);
        }
        case 61..70:
        {
            SetHealthValue(playerid,7);
        }
        case 71..80:
        {
            SetHealthValue(playerid,8);
        }
        case 81..90:
        {
            SetHealthValue(playerid,9);
        }
        case 91..100:
        {
            SetHealthValue(playerid,10);
        }
    }
    switch(floatround(ap,floatround_round))
    {
        case 0:
        {
            SetArmourValue(playerid,0);
        }
        case 1..10:
        {
            SetArmourValue(playerid,1);
        }
        case 11..20:
        {
            SetArmourValue(playerid,2);
        }
        case 21..30:
        {
            SetArmourValue(playerid,3);
        }
        case 31..40:
        {
            SetArmourValue(playerid,4);
        }
        case 41..50:
        {
            SetArmourValue(playerid,5);
        }
        case 51..60:
        {
            SetArmourValue(playerid,6);
        }
        case 61..70:
        {
            SetArmourValue(playerid,7);
        }
        case 71..80:
        {
            SetArmourValue(playerid,8);
        }
        case 81..90:
        {
            SetArmourValue(playerid,9);
        }
        case 91..100:
        {
            SetArmourValue(playerid,10);
        }
    }
    return 1;
}
Reply
#2

What shows 0? This is also quite a redundant way to go about things. You can get rid of the entire switch structure using only this:
PHP код:
SetHealthValue(playeridfloatround((hp 10.0), floatround_ceil)); 
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
What shows 0? This is also quite a redundant way to go about things. You can get rid of the entire switch structure using only this:
PHP код:
SetHealthValue(playeridfloatround((hp 10.0), floatround_ceil)); 
Tutorial on 'Redundant ways to go about things' with the appropriate ways please Vince lol!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)