Progress Bar Help
#1

I am making a server that is related to the fallout game series, so I have added some features such as hunger, thirst, and radiation. I am using the progress bar include to represent those values. The hunger and thirst values work fine, but the radiation one doesn't work right. What I'm trying to script is that the bar will start out as 9% (since 0% appears behind the bar) and raises when you eat irradiated food or drinks along with an admin command that will set your radiation level. The problem is that it won't go up at all. If I eat irradiated food, it doesn't go up, if I drink irradiated drinks, it doesn't go up, and even if I try setting the value, it doesn't go up. Here's the code that I have so far.

Near the top of the script.
Код:
new PlayerBar:PlayerRadiation[MAX_PLAYERS];
I have a enum titled pData with Radiation being one of the values.
Код:
Radiation
/setradiation command code:
Код:
CMD:setradiation(playerid, params[])
{
	if(Player[playerid][AdminLevel] >= 1)
	{
	    new id, amount, string[128];
	    if(sscanf(params, "ud", id, amount))return SendClientMessage(playerid, GREY, "Command Usage: /setradiation [playerid] [amount]");
	    {
	        Player[id][Radiation] = amount;
	        format(string, sizeof(string), "You have set {FFFFFF}%s's {FF0000}radiation level to {00FF00}%d.", GetName(id), amount);
	        SendClientMessage(playerid, RED, string);
	        format(string, sizeof(string), "Admin {FFFFFF}%s {FF0000}has set your radiation level to {00FF00}%d.", GetName(playerid), amount);
	        SendClientMessage(id, RED, string);
		}
	}
	else return SendClientMessage(playerid, GREY, "You are not an administrator.");
	return 1;
}
This is located under OnPlayerUpdate:
Код:
SetPlayerProgressBarValue(playerid, PlayerRadiation[playerid], Player[playerid][Radiation]);
UpdatePlayerProgressBar(playerid, PlayerRadiation[playerid]);
Since I have a sql saving system, I have this line for the radiation:
Код:
mysql_fetch_field_row(savingstring, "radiation"); Player[playerid][Radiation] = strval(savingstring);
Along with that, I have a format(query, sizeof(query) line with the radiation value in it as:
Код:
`radiation` = %d
And this is apart of the saving stats system:
Код:
Player[playerid][Radiation],
This is the line that makes the progress bar:
Код:
PlayerRadiation[playerid] = CreatePlayerProgressBar(playerid, 560.000000, 30.000000, 35, 7.5, YELLOW, 100.0);//Want that to be 9, but for now I just have it at 100

ShowPlayerProgressBar(playerid, PlayerRadiation[playerid]);//Makes the progress bar show up.
When a player registers, this is what the variable is suppose to be set to by default:
Код:
Player[playerid][Radiation] = 9;
I hope you understand what I'm saying here, but I'm just asking this:

How do I make it so that the radiation bar starts at zero and work perfectly?
Reply
#2

In the OnPlayerConnect do you set the bar to 0?
Reply
#3

0.3x has seemed to fix the bug, not sure what happened.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)