Progress Bar help with timer
#1

So i know how to create a progress bar but i want to know how to make it load in like 30 seconds.
Reply
#2

Specify an example please? You just want a timer and have it load in 30 seconds?
Reply
#3

No, i mean i want to make a /rob command so when you do /rob, you get a progress bar that load for 30sec.
Reply
#4

Top of game mode:

pawn Код:
new ShowProgressBar[MAX_PLAYERS];
new ProgressTime[MAX_PLAYERS];

Where rest of public callbacks are:

pawn Код:
forward ShowProgress(playerid);
pawn Код:
public ShowProgress(playerid)
{
    // Display progress bar to show for player here
    if(ProgressTime[playerid] > 0)
    {
        ProgressTime[playerid] --;
    }
    if(ProgressTime[playerid] < 1)
    {
        // Hide the progress bar text draw for player here
        ProgressTime[playerid] = 0;
        KillTimer(ShowProgressBar[playerid]);
    }
    return 1;
}
Put this in your /rob command:

pawn Код:
ProgressTime[playerid] = 30;
ShowProgressBar[playerid] = SetTimerEx("ShowProgress", 60000, true, "i", playerid);
Reply
#5

Quote:
Originally Posted by Xenforox
Посмотреть сообщение
No, i mean i want to make a /rob command so when you do /rob, you get a progress bar that load for 30sec.
To be completely honest with you, I've never attempted such a thing. But if I were to attempt it I'd start by creating a "Main timer". Once the main timer is called, it will create another timer that loops every second or so, updating the progress bar each loop.

So if I were you, I'd create the main timer of 31 second and the second timer inside the main timer that repeats every second, updating the progress bar. (If there's an easier way someone please correct me.)
Reply
#6

Quote:
Originally Posted by rangerxxll
Посмотреть сообщение
To be completely honest with you, I've never attempted such a thing. But if I were to attempt it I'd start by creating a "Main timer". Once the main timer is called, it will create another timer that loops every second or so, updating the timer each loop.

So if I were you, I'd create the main timer of 31 second and the second timer inside the main timer that repeats every seconds, updating the progress bar. (If there's an easier way someone please correct me.)
That is a very bad idea, only need one timer and no loop as done above.
Reply
#7

Quote:
Originally Posted by AphexCCFC
Посмотреть сообщение
That is a very bad idea, only need one timer and no loop as done above.

I actually just thought it through and noticed that you can update it every time the timer is called. Thanks for the correction.

EDIT: After reading through your code, I don't see where the progress bar gradually updates.
Reply
#8

Quote:
Originally Posted by AphexCCFC
Посмотреть сообщение
Top of game mode:

pawn Код:
new ShowProgressBar[MAX_PLAYERS];

Where rest of public callbacks are:

pawn Код:
forward ShowProgress(playerid);
pawn Код:
public ShowProgress(playerid)
{
    // Display progress bar to show for player here
    return 1;
}
Put this in your /rob command:

pawn Код:
ShowProgressBar[playerid] = SetTimerEx("ShowProgress", 30000, false, "i", playerid); // Sets timer for 30 seconds
I think you missunderstood me, I mean when i do /rob, the progress bar show up and start loading then after 30sec it dissappear.
Reply
#9

Quote:
Originally Posted by Xenforox
Посмотреть сообщение
I think you missunderstood me, I mean when i do /rob, the progress bar show up and start loading then after 30sec it dissappear.
Follow my advice. I'm not too sure if there's another way to do it.
Reply
#10

Edited my code above, misread first of all sorry
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)