SA-MP Forums Archive
[Include] od_progress_bar.inc - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] od_progress_bar.inc (/showthread.php?tid=624231)



od_progress_bar.inc - Make animated bars in the console. - OneDay - 13.12.2016

PHP код:
#if defined _INC_od_progress_bar
    #endinput
#endif
#define _INC_od_progress_bar
#include <od_stdio>
static gProgressBar[101] = "####################################################################################################";
static 
gEmptyBar[101] = "                                                                                                    ";
#define OD_PROGRESS_Set ProgressBar_Set
#define OD_PROGRESS_Done ProgressBar_Done
#define OD_PROGRESS_Undone ProgressBar_Undone
#define OD_PROGRESS_Up ProgressBar_Up
#define OD_PROGRESS_Down ProgressBar_Down
#define OD_PROGRESS_OneMinuteUp ProgressBar_OneMinuteUp
#define OD_PROGRESS_OneSecondUp ProgressBar_OneSecondUp
#define OD_PROGRESS_OneMinuteDown ProgressBar_OneMinuteDown
#define OD_PROGRESS_OneSecondDown ProgressBar_OneSecondDown
stock ProgressBar_Set(n) {
    
IO_CarriageReturn();
    
IO_Write(gProgressBar[100 clamp(n0100)]);
    
IO_Write(gEmptyBar[clamp(n0100)]);
    
IO_Flush();
}
stock ProgressBar_Done() {
    
IO_Write(" - Done!");
    
IO_NewLine();
    
IO_Flush();
}
stock ProgressBar_Undone() {
    
IO_CarriageReturn();
    
IO_Write("- Undone!");
    
IO_NewLine();
    
IO_Flush();
}
stock ProgressBar_Up(time) {
    new 
end GetTickCount();
    
ProgressBar_Set(0);
    for (new 
1<= 100; ++i) {
        
end end time;
        while (
GetTickCount() < end) {
        }
        
ProgressBar_Set(i);
    }
}
stock ProgressBar_Down(time) {
    new 
end GetTickCount();
    
ProgressBar_Set(100);
    for (new 
99>= 0; --i) {
        
end end time;
        while (
GetTickCount() < end) {
        }
        
ProgressBar_Set(i);
    }
}
stock ProgressBar_OneMinuteUp() {
    
ProgressBar_Up(600);
    
ProgressBar_Done();
}
stock ProgressBar_OneSecondUp() {
    
ProgressBar_Up(10);
    
ProgressBar_Done();
}
stock ProgressBar_OneMinuteDown() {
    
ProgressBar_Down(600);
    
ProgressBar_Undone();
}
stock ProgressBar_OneSecondDown() {
    
ProgressBar_Down(10);
    
ProgressBar_Undone();

It can put a moving progress bar in the console. If you display other writing a triangle will appear instead.

Server loading example:

PHP код:
#include <a_samp>
#include <od_progress_bar>
main()
{
}
public 
OnGameModeInit() {
    
ProgressBar_OneMinuteUp();



Items loading example:

PHP код:
#include <a_samp>
#include <od_progress_bar>
#define SLOW_CODE for (new end = GetTickCount() + ((random(20) == 0) ? (random(10) * 100) : (random(50))); GetTickCount() < end; ) {}
MODE_LoadObjects() {
    
IO_Write("Loading objects...");
    
IO_NewLine();
    for (new 
0100; ++i) {
        
ProgressBar_Set(i);
        
SLOW_CODE
    
}
    
ProgressBar_Set(100);
    
IO_NewLine();
    
IO_NewLine();
}
MODE_LoadVehicles() {
    
IO_Write("Loading vehicles...");
    
IO_NewLine();
    for (new 
0100; ++i) {
        
ProgressBar_Set(i);
        
SLOW_CODE
    
}
    
ProgressBar_Set(100);
    
IO_NewLine();
    
IO_NewLine();
}
MODE_LoadAntiCheat() {
    
IO_Write("Loading anti cheat...");
    
IO_NewLine();
    for (new 
0100; ++i) {
        
ProgressBar_Set(i);
        
SLOW_CODE
    
}
    
ProgressBar_Set(100);
    
IO_NewLine();
    
IO_NewLine();
}
MODE_LoadZones() {
    
IO_Write("Loading zones...");
    
IO_NewLine();
    for (new 
0100; ++i) {
        
ProgressBar_Set(i);
        
SLOW_CODE
    
}
    
ProgressBar_Set(100);
    
IO_NewLine();
    
IO_NewLine();
}
main()
{
}
public 
OnGameModeInit()
{
    
MODE_LoadObjects();
    
MODE_LoadVehicles();
    
MODE_LoadAntiCheat();
    
MODE_LoadZones();
    
IO_Flush();
    return 
1;



To make work on Linux type:

PHP код:
ln -/dev/tty ./scriptfiles/CON 
Uses:

http://forum.sa-mp.com/showthread.ph...22#post3812622

Password for server example:

http://forum.sa-mp.com/showthread.ph...24#post3812624

If it makes the triangle:




Re: od_progress_bar.inc - Eoussama - 21.12.2016

OMG, you'rd awesome


Re: od_progress_bar.inc - OneDay - 22.12.2016

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
OMG, you'rd awesome
Thanks


Re: od_progress_bar.inc - OneDay - 04.04.2017

updated with fixed hooks
nice functions names
works on Linux with:

PHP код:
ln -/dev/tty ./scriptfiles/CON 



Re: od_progress_bar.inc - Pottus - 04.04.2017

Код:
#define SLOW_CODE for (new end = GetTickCount() + ((random(20) == 0) ? (random(10) * 100) : (random(50))); GetTickCount() < end; ) {}
All this is is a semi-fake loading screen fucking bullshit.


Re: od_progress_bar.inc - Dignity - 05.04.2017

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Код:
#define SLOW_CODE for (new end = GetTickCount() + ((random(20) == 0) ? (random(10) * 100) : (random(50))); GetTickCount() < end; ) {}
All this is is a semi-fake loading screen fucking bullshit.
looooooooooooooooooool


Re: od_progress_bar.inc - Pottus - 05.04.2017

It's the truth.


Respuesta: od_progress_bar.inc - Goss - 05.04.2017

What function had?


Re: od_progress_bar.inc - Kar - 05.04.2017

Stop making these things...


Re: od_progress_bar.inc - OneDay - 05.04.2017

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Код:
#define SLOW_CODE for (new end = GetTickCount() + ((random(20) == 0) ? (random(10) * 100) : (random(50))); GetTickCount() < end; ) {}
All this is is a semi-fake loading screen fucking bullshit.
yes, for a example 'your slow code goes here' not the real code. It is showing how to make progress bars, not how to load many things.

Quote:
Originally Posted by Kar
Посмотреть сообщение
Stop making these things...
Why?