SA-MP Forums Archive
[Include] od_scroll_text.inc - Make moving text in the console. - 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_scroll_text.inc - Make moving text in the console. (/showthread.php?tid=624243)



od_scroll_text.inc - Make moving text in the console. - OneDay - 13.12.2016

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:




Re: od_scroll_text.inc - Make moving text in the console. - Eoussama - 13.12.2016

WOW, awesome, +rep


Re: od_scroll_text.inc - Make moving text in the console. - OneDay - 14.12.2016

If it makes the triangle:




Re: od_scroll_text.inc - Make moving text in the console. - Swedky - 14.12.2016

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


Re: od_scroll_text.inc - Make moving text in the console. - coool - 14.12.2016

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


Re: od_scroll_text.inc - Make moving text in the console. - ISmokezU - 14.12.2016

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


Re: od_scroll_text.inc - Make moving text in the console. - OneDay - 14.12.2016

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


Re: od_scroll_text.inc - Make moving text in the console. - ISmokezU - 14.12.2016

Download?


Re: od_scroll_text.inc - Make moving text in the console. - OneDay - 22.12.2016

It is in the first post.


Re: od_scroll_text.inc - Make moving text in the console. - OneDay - 04.04.2017

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)


Re: od_scroll_text.inc - Make moving text in the console. - Jessyy - 04.04.2017

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.



Re: od_scroll_text.inc - Make moving text in the console. - OneDay - 04.04.2017

so how to do it other way with y_times?


Re: od_scroll_text.inc - Make moving text in the console. - ghostbalkan - 12.04.2017



On this code it makes



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


Re: od_scroll_text.inc - Make moving text in the console. - OneDay - 14.04.2017

Only one line will work


Re: od_scroll_text.inc - Make moving text in the console. - ghostbalkan - 15.04.2017

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


Re: od_scroll_text.inc - Make moving text in the console. - GangstaSunny. - 15.04.2017

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


Re: od_scroll_text.inc - Make moving text in the console. - OneDay - 25.04.2017

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