Progressbar refuses to destroy
#1

Hey, I'm working with progressbar that "loads". And when its finished loading it wont go away.
Here is the code:

Code:
stock freeze(playerid)
{
	TogglePlayerControllable(playerid, 0);
	ShowPlayerProgressBar(playerid, UnfreezeBar[playerid]);
	UnfreezeBar[playerid] = CreatePlayerProgressBar(playerid,258.00, 367.00, 124.50, 14.50, -16776961, 100.0);
	UnfreezeBarUpdater[playerid] = SetTimerEx("unfreezetimer", 1000, true, "i", playerid);
	GameTextForPlayer(playerid, "~r~Loading Objects", 3000, 5);
}
public DeleteBar(playerid)
{
    DestroyPlayerProgressBar(playerid,UnfreezeBar[playerid]);
    UnfreezeProgress[playerid] = 0;
    return 1;
}

public unfreezetimer(playerid)
{
    if(GetPlayerProgressBarValue(playerid,UnfreezeBar[playerid]) == 100)
    {
        DestroyPlayerProgressBar(playerid,UnfreezeBar[playerid]);
		UnfreezeProgress[playerid] = 0;
		SetTimerEx("DeleteBar", 2000, true, "i", playerid);
		TogglePlayerControllable(playerid, 1);
		GameTextForPlayer(playerid, "~g~Done",2000, 5);
		return true;
	}
	UnfreezeProgress[playerid] += 25;
    SetPlayerProgressBarValue(playerid,UnfreezeBar[playerid], UnfreezeProgress[playerid]);
	return true;
}
Even tried adding the DeleteBar timer to it, but still nothing.
Anyone have an idea whats wrong?
Reply
#2

Check if you accidently reset the ID-Variable before its deleted.
Check if you reset the ProgressBarID when it becomes 100%.
Check if you are trying to delete wrongID... Like, Instead of trying to delete "ProgressBarID", you tried to delete ProgressBarPercentage" etc.
Reply
#3

Yeah double checked all that. Still it wont dissapear
Reply
#4

Code:
...
	ShowPlayerProgressBar(playerid, UnfreezeBar[playerid]);
	UnfreezeBar[playerid] = CreatePlayerProgressBar(playerid,258.00, 367.00, 124.50, 14.50, -16776961, 100.0);
...
Looking at the code... you first show a progress bar the ID of which is in the UnfreezeBar array. Then you create a new one (CreatePlayerProgressBar returns a value and it is written into the UnfreezeBar array).

Therefore, in the unfreezetimer, you actually hide the NEWLY CREATED progress bar, but the one that you show earlier still remains.

Extra suggestion to make: If you already store the progression value in the UnfreezeProgress array, why call GetPlayerProgressBarValue from some libary (you're not sure what's the overhead of this function). Furthermore, the library most likely already stores the progression value on its own. Therefore it is unnecessary to keep a copy of this array in your own script.
You can optimize your memory usage by not keeping a local copy of your own if the library provides these functions (and you use them anyway, currently).
Reply
#5

Quote:
Originally Posted by AndreT
View Post
Code:
...
	ShowPlayerProgressBar(playerid, UnfreezeBar[playerid]);
	UnfreezeBar[playerid] = CreatePlayerProgressBar(playerid,258.00, 367.00, 124.50, 14.50, -16776961, 100.0);
...
Looking at the code... you first show a progress bar the ID of which is in the UnfreezeBar array. Then you create a new one (CreatePlayerProgressBar returns a value and it is written into the UnfreezeBar array).

Therefore, in the unfreezetimer, you actually hide the NEWLY CREATED progress bar, but the one that you show earlier still remains.

Extra suggestion to make: If you already store the progression value in the UnfreezeProgress array, why call GetPlayerProgressBarValue from some libary (you're not sure what's the overhead of this function). Furthermore, the library most likely already stores the progression value on its own. Therefore it is unnecessary to keep a copy of this array in your own script.
You can optimize your memory usage by not keeping a local copy of your own if the library provides these functions (and you use them anyway, currently).
That solved it, thanks mate.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)