SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/05/2016, 09:32 PM   #1
BizzyD
Gangsta
 
BizzyD's Avatar
 
Join Date: Jan 2011
Location: Home
Posts: 879
Reputation: 66
Default Progressbar refuses to destroy

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?
__________________
We never fail, we only shine with brilliance. One king one faith one religion. And if you hear me come and join the revolution
BizzyD is offline   Reply With Quote
Old 15/05/2016, 06:40 AM   #2
Mic_H
Big Clucker
 
Join Date: Oct 2011
Posts: 178
Reputation: 19
Default Re: Progressbar refuses to destroy

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.
__________________

****** is your best friend.
Search:
Question site:forum.sa-mp.com
Mic_H is offline   Reply With Quote
Old 15/05/2016, 12:40 PM   #3
BizzyD
Gangsta
 
BizzyD's Avatar
 
Join Date: Jan 2011
Location: Home
Posts: 879
Reputation: 66
Default Re: Progressbar refuses to destroy

Yeah double checked all that. Still it wont dissapear
__________________
We never fail, we only shine with brilliance. One king one faith one religion. And if you hear me come and join the revolution
BizzyD is offline   Reply With Quote
Old 15/05/2016, 12:48 PM   #4
AndreT
Gangsta
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 966
Reputation: 414
Default Re: Progressbar refuses to destroy

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).
AndreT is offline   Reply With Quote
Old 15/05/2016, 12:53 PM   #5
BizzyD
Gangsta
 
BizzyD's Avatar
 
Join Date: Jan 2011
Location: Home
Posts: 879
Reputation: 66
Default Re: Progressbar refuses to destroy

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.
__________________
We never fail, we only shine with brilliance. One king one faith one religion. And if you hear me come and join the revolution
BizzyD is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refuses to load plugins. Kyle_Olsen Scripting Help 6 27/03/2012 08:06 PM
bot refuses to get in vehicle lolumadd_ Help Archive 6 19/07/2011 05:40 PM
Refuses the count score erxaz Help Archive 5 03/04/2011 11:32 PM
SAMP refuses to start valmiustila Client Support 1 25/10/2010 12:54 PM


All times are GMT. The time now is 09:05 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.