[Include] od_scroll_text.inc - Make moving text in the console.
#1

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[], offsetwidthprefix[] = ""suffix[] = "") {
    
IO_CarriageReturn();
    
IO_Write(prefix);
    new 
length strlen(text);
    static 
spaces[] = "                                ";
    new 
start clamp(offset0length);
    new 
end clamp(offset width0length);
    if (
offset 0) {
        new 
padding clamp(-offset0width);
        for (new 
0padding32) {
            
IO_Write(spaces[clamp(32 - (padding i), 032)]);
        }
    }
    new 
ch text[end];
    
text[end] = '\0';
    
IO_Write(text[start]);
    
text[end] = ch;
    for (new 
end offsetwidth32) {
        
IO_Write(spaces[clamp(32 - (width i), 032)]);
    }
    
IO_Write(suffix);
    
IO_Flush();
}
stock Scroll_Dynamic(text[], widthtimeprefix[] = ""suffix[] = ""direction OD_SCROLL_LEFT) {
    switch (
direction) {
        case 
OD_SCROLL_LEFT: {
            new 
end GetTickCount();
            new 
start = -width;
            new 
length strlen(text);
            for ( ; ; ) {
                for (new 
start<= length; ++i) {
                    
Scroll_Static(textiwidthprefixsuffix);
                    
end end time;
                    while (
GetTickCount() < end) {
                    }
                }
            }
        }
        case 
OD_SCROLL_RIGHT: {
            new 
end GetTickCount();
            new 
start = -width;
            new 
length strlen(text);
            for ( ; ; ) {
                for (new 
length>= start; --i) {
                    
Scroll_Static(textiwidthprefixsuffix);
                    
end end time;
                    while (
GetTickCount() < end) {
                    }
                }
            }
        }
        case 
OD_SCROLL_BOUNCE: {
            new 
end GetTickCount();
            new 
length strlen(text);
            new 
start = -(width length);
            for ( ; ; ) {
                for (new 
0>= start; --i) {
                    
Scroll_Static(textiwidthprefixsuffix);
                    
end end time;
                    while (
GetTickCount() < end) {
                    }
                }
                for (new 
start<= 0; ++i) {
                    
Scroll_Static(textiwidthprefixsuffix);
                    
end end time;
                    while (
GetTickCount() < end) {
                    }
                }
            }
        }
    }

It can make moving text in the console. Call "Scroll_Static" a lot or call "Scroll_Dynamic" once.

Hello World example:

PHP код:
#include <a_samp>
#include <od_scroll_text>
main()
{
}
public 
OnGameModeInit()
{
    
Scroll_Dynamic("hello world"50150"---:"":---");
    return 
1;



To make work on Linux type:

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

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

WOW, awesome, +rep
Reply
#3

If it makes the triangle:

Reply
#4

I don't know how this works but this works can you explain how you're doing this, how "CON" file is annexed to server_log.txt/samp-server.exe? It looks interesting
Reply
#5

Awesome work. Just seen some thing fabulous again!!! +Rep
Reply
#6

How'd you do that password to start GM thingy? that'll be good for security.
Reply
#7

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
WOW, awesome, +rep
Thanks

Quote:
Originally Posted by Swedky
Посмотреть сообщение
I don't know how this works but this works can you explain how you're doing this, how "CON" file is annexed to server_log.txt/samp-server.exe? It looks interesting
It is special in Windows - CON and CONIN$ and CONOUT$ means console.

Quote:
Originally Posted by coool
Посмотреть сообщение
Awesome work. Just seen some thing fabulous again!!! +Rep
Thanks

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
How'd you do that password to start GM thingy? that'll be good for security.
http://forum.sa-mp.com/showthread.ph...24#post3812624
Reply
#8

Download?
Reply
#9

It is in the first post.
Reply
#10

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

PHP код:
ln -/dev/tty ./scriptfiles/CON 
also does many directions and both directions (bounces across the screen)
Reply
#11

I highly recommend do not use this include, because in his core is using the same code from the "wait" function provided by Ryder in his CTime post.
And one of the comments from that post explains how will effect the server:
Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
You can't make a specific player wait to execute code as you can't run code for specific players, everything runs on one thread one thing after another. If that thread is paused (with a wait() function for example) the entire server will stop.
...
If you want an easier way to write timer code, check out y_timers. That library decreases the amount of writing you need to do for deferred or repeated functions.
Reply
#12

so how to do it other way with y_times?
Reply
#13



On this code it makes



When I put \n it goes left, to right, u know what I mean
Reply
#14

Only one line will work
Reply
#15

Quote:
Originally Posted by OneDay
Посмотреть сообщение
Only one line will work
oh okay
Reply
#16

This is so useless. And because it's useless, i fucking love it
Reply
#17

Quote:
Originally Posted by GangstaSunny.
Посмотреть сообщение
This is so useless. And because it's useless, i fucking love it
Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)