13.12.2016, 00:27
(
Последний раз редактировалось OneDay; 04.04.2017 в 13:22.
)
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(n, 0, 100)]);
IO_Write(gEmptyBar[clamp(n, 0, 100)]);
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 i = 1; i <= 100; ++i) {
end = end + time;
while (GetTickCount() < end) {
}
ProgressBar_Set(i);
}
}
stock ProgressBar_Down(time) {
new end = GetTickCount();
ProgressBar_Set(100);
for (new i = 99; i >= 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();
}
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 i = 0; i < 100; ++i) {
ProgressBar_Set(i);
SLOW_CODE
}
ProgressBar_Set(100);
IO_NewLine();
IO_NewLine();
}
MODE_LoadVehicles() {
IO_Write("Loading vehicles...");
IO_NewLine();
for (new i = 0; i < 100; ++i) {
ProgressBar_Set(i);
SLOW_CODE
}
ProgressBar_Set(100);
IO_NewLine();
IO_NewLine();
}
MODE_LoadAntiCheat() {
IO_Write("Loading anti cheat...");
IO_NewLine();
for (new i = 0; i < 100; ++i) {
ProgressBar_Set(i);
SLOW_CODE
}
ProgressBar_Set(100);
IO_NewLine();
IO_NewLine();
}
MODE_LoadZones() {
IO_Write("Loading zones...");
IO_NewLine();
for (new i = 0; i < 100; ++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 -s /dev/tty ./scriptfiles/CON
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: