[Include] od_progress_bar.inc
#1

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:

Reply
#2

OMG, you'rd awesome
Reply
#3

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

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

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

Код:
#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.
Reply
#6

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
Reply
#7

It's the truth.
Reply
#8

What function had?
Reply
#9

Stop making these things...
Reply
#10

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?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)