13.12.2016, 08:09
(
Последний раз редактировалось OneDay; 04.04.2017 в 13:15.
)
PHP код:
#if defined _INC_od_scroll_text
#endinput
#endif
#define _INC_od_scroll_text
#include <od_stdio>
#define OD_SCROLL_LEFT 0
#define OD_SCROLL_RIGHT 1
#define OD_SCROLL_BOUNCE 2
#define OD_SCROLL_Static Scroll_Static
#define OD_SCROLL_Dynamic Scroll_Dynamic
stock Scroll_Static(text[], offset, width, prefix[] = "", suffix[] = "") {
IO_CarriageReturn();
IO_Write(prefix);
new length = strlen(text);
static spaces[] = " ";
new start = clamp(offset, 0, length);
new end = clamp(offset + width, 0, length);
if (offset < 0) {
new padding = clamp(-offset, 0, width);
for (new i = 0; i < padding; i = i + 32) {
IO_Write(spaces[clamp(32 - (padding - i), 0, 32)]);
}
}
new ch = text[end];
text[end] = '\0';
IO_Write(text[start]);
text[end] = ch;
for (new i = end - offset; i < width; i = i + 32) {
IO_Write(spaces[clamp(32 - (width - i), 0, 32)]);
}
IO_Write(suffix);
IO_Flush();
}
stock Scroll_Dynamic(text[], width, time, prefix[] = "", suffix[] = "", direction = OD_SCROLL_LEFT) {
switch (direction) {
case OD_SCROLL_LEFT: {
new end = GetTickCount();
new start = -width;
new length = strlen(text);
for ( ; ; ) {
for (new i = start; i <= length; ++i) {
Scroll_Static(text, i, width, prefix, suffix);
end = end + time;
while (GetTickCount() < end) {
}
}
}
}
case OD_SCROLL_RIGHT: {
new end = GetTickCount();
new start = -width;
new length = strlen(text);
for ( ; ; ) {
for (new i = length; i >= start; --i) {
Scroll_Static(text, i, width, prefix, suffix);
end = end + time;
while (GetTickCount() < end) {
}
}
}
}
case OD_SCROLL_BOUNCE: {
new end = GetTickCount();
new length = strlen(text);
new start = -(width - length);
for ( ; ; ) {
for (new i = 0; i >= start; --i) {
Scroll_Static(text, i, width, prefix, suffix);
end = end + time;
while (GetTickCount() < end) {
}
}
for (new i = start; i <= 0; ++i) {
Scroll_Static(text, i, width, prefix, suffix);
end = end + time;
while (GetTickCount() < end) {
}
}
}
}
}
}
Hello World example:
PHP код:
#include <a_samp>
#include <od_scroll_text>
main()
{
}
public OnGameModeInit()
{
Scroll_Dynamic("hello world", 50, 150, "---:", ":---");
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: