Hunger Update
#1

Can somebody please tell me what is wrong with this, it should be 100% in textdraw

OnPlayerSpawn

Code:
	if(ServerLoading[playerid] == 1)
	{
		SetTimerEx("ServerLoad", 7000, false, "d", playerid);
		SetTimerEx("Hungry", 600000, 1, "i", playerid);
		SCM(playerid, WHITE, "Server loading, please wait...");
	}
Server Load

Code:
public ServerLoad(playerid)
{
    ServerLoading[playerid] = 0;
    SetCameraBehindPlayer(playerid);
	TogglePlayerControllable(playerid, 1);
	SCM(playerid, WHITE, "Server loaded...");
	return 1;
}
Hungry Timer

Code:
public Hungry(playerid)
{
	new Float:helt;
	GetPlayerHealth(playerid, helt);

	if(CurHealth[playerid] >= helt)
	{
	    SCM(playerid, WHITE, "You're hungry, you should eat.");
	    SetPlayerHealth(playerid, helt-5);
	    CurHealth[playerid] = helt;
	}
	else
	{
	    CurHealth[playerid] = helt;
	}
}
OnPlayerUpdate

format(str2, sizeof(str), "Hunger: %d%", CurHealth[playerid]);
TextDrawSetString(PHunger[playerid], str2);


it shows textdraw but it's 0% not 100
Reply
#2

I fixed that, but now whats bothering me is showing that, it only saves in float, and float shows in textdraw like 100.00000 % how can i make it only show 100 %
Reply
#3

down
down down
down
Reply
#4

try this
pawn Code:
format(str2, sizeof(str2), "Hunger: %.0f%%", CurHealth[playerid]);// or %.f
TextDrawSetString(PHunger[playerid], str2);
Reply
#5

I've fixed it with floadround, but i've got another problem, now this

pawn Code:
if(CurHealth[playerid] >= helt)
    {
        SCM(playerid, WHITE, "You're hungry, you should eat.");
        SetPlayerHealth(playerid, helt-5);
        CurHealth[playerid] = helt;
    }
Shows me that i'm hungry, even if my health is 100 or 95.
Reply
#6

Anyone ? It's pretty urgent
Reply
#7

Anyone ?
Reply
#8

So i think i got it, how can i convert this - 3 into float, because Hunger is defined as float in enum...

pawn Code:
public Hunger(playerid)
{
    new Float:helt;
    GetPlayerHealth(playerid, helt);

    if(PI[playerid][Hunger] < 20)
    {
        SCM(playerid, WHITE, "You're hungry, you should eat.");
        SetPlayerHealth(playerid, helt-3);
        PI[playerid][Hunger] -= 3;
    }
    else
    {
        PI[playerid][Hunger] -= 3;
    }
}
When i put it like this it shows 13171343% not 100 % or 65 %
Reply
#9

THIS WILL FIX UR FLOAT FORMAT PROBLEM !
Quote:

try this
pawn Code:
format(str2, sizeof(str2), "Hunger: %.0f%%", CurHealth[playerid]);// or %.f
TextDrawSetString(PHunger[playerid], str2);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)