07.03.2014, 17:07
Hello. So this is a bit complicated, but I'll try my best to explain.
I have a hunger and thirst system that uses a textdraw. When a player connects, it sets their thirst and hunger variable to 100 automatically, and it also sets the timer to begin lowering the variable. I've also created a stock to update the textdraw's with ease.
Now the problem is quite strange. Every time the textdraw's variable goes down, it flashes a un-desored variable. Example: Current Hunger: 100. It goes down 1%, and it will quickly flash "55" and then turn to 99. I'm not sure if anything is conflicting with each other, that sets the variable differently or what.
Here's some necessary code.
If you need any other information, let me know. Thank you.
I have a hunger and thirst system that uses a textdraw. When a player connects, it sets their thirst and hunger variable to 100 automatically, and it also sets the timer to begin lowering the variable. I've also created a stock to update the textdraw's with ease.
Now the problem is quite strange. Every time the textdraw's variable goes down, it flashes a un-desored variable. Example: Current Hunger: 100. It goes down 1%, and it will quickly flash "55" and then turn to 99. I'm not sure if anything is conflicting with each other, that sets the variable differently or what.
Here's some necessary code.
pawn Код:
stock updatetd(playerid) //the updatetd stock that updates my td's string. We're focusing on hunger and thirst.
{
format(hungertdstring,sizeof(hungertdstring), "Hunger: %d", hunger[playerid]);
format(thirsttdstring,sizeof(thirsttdstring), "Thirst: %d", thirst[playerid]);
TextDrawSetString(hungertd, hungertdstring);
TextDrawSetString(thirsttd, thirsttdstring);
TextDrawHideForPlayer(playerid, hungertd);
TextDrawShowForPlayer(playerid, hungertd);
TextDrawHideForPlayer(playerid, thirsttd);
TextDrawShowForPlayer(playerid, thirsttd);
if(GameProgress == 0)
{
TextDrawSetString(StatusTD, "Status: In Lobby");
TextDrawHideForPlayer(playerid, StatusTD);
TextDrawShowForPlayer(playerid, StatusTD2);
}
if(GameProgress == 1)
{
TextDrawSetString(StatusTD, "Status: In Game");
TextDrawHideForPlayer(playerid, StatusTD2);
TextDrawShowForPlayer(playerid, StatusTD);
}
//under onplayerconnect. To show the textdraw, and update it.
TextDrawShowForPlayer(playerid, hungertd);
TextDrawShowForPlayer(playerid, thirsttd);
TextDrawShowForPlayer(playerid, StatusTD);
updatetd(playerid);
// The timers that lowers the textdraw's variables.
forward HungerTimer(playerid);
public HungerTimer(playerid)
{
hunger[playerid] --;
updatetd(playerid);
if(hunger[playerid] == 1)
{
SetPlayerHealth(playerid, 0);
SendClientMessage(playerid,COLOR_RED, "You have died of starvation.");
KillTimer(hTimer);
return 1;
}
if(hunger[playerid] < 20)
{
RemovePlayerHealth(playerid, 10);
SendClientMessage(playerid,COLOR_RED, "You're now starving from starvation. Find food.");
return 1;
}
return 1;
}