SA-MP Forums Archive
[Include] Textdraw Animations - 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] Textdraw Animations (/showthread.php?tid=328022)



Textdraw Animations 1.1 - clavador - 23.03.2012

NEW VERSION AVAILABLE 2.0!

TEXTDRAW ANIMATIONS 1.1


With this include you can add a little more life to your textdraws:

Click here for a quick preview!

The effects include:

- Showing textdraws in a progressive way.
- Showing textdraws growing from 0 to x.
- Showing textdraws with a pulsating effect.


So, let's see how it's done...

First, you need to copy the .inc file to your includes folder and put inside your filterscript or gamemode:

pawn Код:
#include <TextDrawAnimations>
This effects are meant to be used with textdraws created inside an array called "T_Buffer" wich it's max length you can define by writing:

pawn Код:
#define MAX_BUFFER 100
You have to define it before including the file, so it should look like this:

pawn Код:
#define MAX_BUFFER 100
#include <a_samp>
#include <TextDrawAnimations>
If you don't define it, max size is 24.

Once you've done that, you need to create the textdraws wich you want to apply an effect to.

You can just set the buffer to 200 and create them all at once, or you can create them dinamically and have a smaller T_Buffer array size ( later i'll show you how you can call different T_Buffer values to show certain textdraws ).

pawn Код:
#define TEXTDRAWS_ANIMATION_0 0
#define TEXTDRAWS_ANIMATION_1 1

CreateDynamicTextdraws( index )
{
    switch( index )
    {
        case TEXTDRAWS_ANIMATION_0:
        {
            T_Buffer[0] = TextDrawCreate(320.000000, 130.000000, "You");
            TextDrawAlignment(T_Buffer[0], 2);
            TextDrawBackgroundColor(T_Buffer[0], 255);
            TextDrawFont(T_Buffer[0], 1);
            TextDrawLetterSize(T_Buffer[0], 1.300000, 4.000000);
            TextDrawColor(T_Buffer[0], -16776961);
            TextDrawSetOutline(T_Buffer[0], 0);
            TextDrawSetProportional(T_Buffer[0], 1);
            TextDrawSetShadow(T_Buffer[0], 1);

            T_Buffer[1] = TextDrawCreate(320.000000, 160.000000, "Can");
            TextDrawAlignment(T_Buffer[1], 2);
            TextDrawBackgroundColor(T_Buffer[1], 255);
            TextDrawFont(T_Buffer[1], 1);
            TextDrawLetterSize(T_Buffer[1], 1.300000, 4.000000);
            TextDrawColor(T_Buffer[1], -16776961);
            TextDrawSetOutline(T_Buffer[1], 0);
            TextDrawSetProportional(T_Buffer[1], 1);
            TextDrawSetShadow(T_Buffer[1], 1);

            T_Buffer[2] = TextDrawCreate(320.000000, 190.000000, "Animate");
            TextDrawAlignment(T_Buffer[2], 2);
            TextDrawBackgroundColor(T_Buffer[2], 255);
            TextDrawFont(T_Buffer[2], 1);
            TextDrawLetterSize(T_Buffer[2], 1.300000, 4.000000);
            TextDrawColor(T_Buffer[2], -16776961);
            TextDrawSetOutline(T_Buffer[2], 0);
            TextDrawSetProportional(T_Buffer[2], 1);
            TextDrawSetShadow(T_Buffer[2], 1);

            T_Buffer[3] = TextDrawCreate(320.000000, 220.000000, "this text!");
            TextDrawAlignment(T_Buffer[3], 2);
            TextDrawBackgroundColor(T_Buffer[3], 255);
            TextDrawFont(T_Buffer[3], 1);
            TextDrawLetterSize(T_Buffer[3], 1.300000, 4.000000);
            TextDrawColor(T_Buffer[3], -16776961);
            TextDrawSetOutline(T_Buffer[3], 0);
            TextDrawSetProportional(T_Buffer[3], 1);
            TextDrawSetShadow(T_Buffer[3], 1);
           
            T_Buffer[4] = TextDrawCreate(340.000000, 280.000000, "Or make it grow!!!");
            TextDrawAlignment(T_Buffer[4], 2);
            TextDrawBackgroundColor(T_Buffer[4], 255);
            TextDrawFont(T_Buffer[4], 1);
            TextDrawLetterSize(T_Buffer[4], 1.300000, 4.000000);
            TextDrawColor(T_Buffer[4], -16711681);
            TextDrawSetOutline(T_Buffer[4], 0);
            TextDrawSetProportional(T_Buffer[4], 1);
            TextDrawSetShadow(T_Buffer[4], 1);
        }
               case TEXTDRAWS_ANIMATION_1:
        {
            T_Buffer[0] = TextDrawCreate(340.000000, 280.000000, "Another text with effect");
            TextDrawAlignment(T_Buffer[0], 2);
            TextDrawBackgroundColor(T_Buffer[0], 255);
            TextDrawFont(T_Buffer[0], 1);
            TextDrawLetterSize(T_Buffer[0], 1.300000, 4.000000);
            TextDrawColor(T_Buffer[0], -16711681);
            TextDrawSetOutline(T_Buffer[0], 0);
            TextDrawSetProportional(T_Buffer[0], 1);
            TextDrawSetShadow(T_Buffer[0], 1);
        }
    }
   
    return 1;
}
So before you apply an effect, you call CreateDynamicTextdraws( index ) to create the textdraw inside T_Buffer, wich is from where we're gonna read the values to show the textdraws later.

So, suppose you want to make the effects you saw on the video.

You create the textdraws first as explained, and then you use the Callback "OnAnimFinish" to control what happens after an effect ends:

pawn Код:
public OnAnimFinish( playerid, index )
{
    switch( index )
    {
        case TEXTDRAWS_ANIMATION_0:
        {
            TextDraw_Grow(playerid,TEXTDRAWS_ANIMATION_1,100,2500, 0, 4, 1.3, 4.0);
        }
        case TEXTDRAWS_ANIMATION_1:
        {
            TextDraw_Pulsate(playerid,TEXTDRAWS_ANIMATION_FINISH,10,100,0,4 );
        }
        case TEXTDRAWS_ANIMATION_FINISH:
        {
            TextDraw_Hide( playerid, 0, -1 );
        }
    }
   
    return 1;
}
And to start the magic, you can use a command like:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/anm", cmdtext, true, 10) == 0)
    {      
        CreateDynamicTextdraws( TEXTDRAWS_ANIMATION_0 );
        TextDraw_FadeIn( playerid, TEXTDRAWS_ANIMATION_0, 100, 2000, 0, 4 );       
        return 1;
    }

    return 0;
}
And you're done!

Now let's see each function to know what they do:

TextDraw_Grow( playerid, index, anim_speed, duration, T_Buffer_min, T_Buffer_max, Float:max_x, Float:max_y );



This one makes the text grow from 0 to X
TextDraw_FadeIn(playerid,index,speed,duration,T_Bu ffer_min,T_Buffer_max)



This one makes textdraw appear one after another.
TextDraw_Pulsate( playerid, index, repetitions, speed, T_Buffer_min, T_Buffer_max )



This one creates a pulsating effect.
TextDraw_Hide(playerid,T_Buffer_min,T_Buffer_max)

This function hides the textdraws from min to max. Set the max parameter to -1 and it will hide every textdraw inside T_Buffer.

StopTextDrawAnimations( playerid );

You can call this one to stop any animation or timer currently running.

And that's it!

Download from PASTEBIN:

- TextDrawAnimations.inc v1.1.
- Testit.pwn ( an example showing the basic stuff ).

Bugs fixed:

- Some variables where changed after they were used and could cause unwanted behaviour.

Other:

- I'll try to add more effects later.
- I added another define: PLY_MX wich equals to MAX_PLAYERS if not defined. This is to calculate the array size of the array called T_Stuff wich handles some player data.
- Don't try to use more than one effect at a time or it will mess up, because it only uses one timer. I'll do an update soon so you can use many effects at once.

NEW VERSION AVAILABLE 2.0!



Re: Textdraw Animations - Blunt - 23.03.2012

Really nice, gonna test this as soon as I get some time.


Re: Textdraw Animations - WoodPecker - 23.03.2012

Very nice job man, 3rep4u.


Re: Textdraw Animations - AMEENAMEEN - 23.03.2012

Nice man


Re: Textdraw Animations - IstuntmanI - 23.03.2012

It's awesome, great job ! +rep for you work.


Re: Textdraw Animations - Faisal_khan - 23.03.2012

WTF!! 0_0
Its Damn COOL!!

+rep


Re: Textdraw Animations - GBLTeam - 23.03.2012

Btw looks nice. I will test it later and tell you if there some bugs.. Good work!


Re: Textdraw Animations - petrolhead - 23.03.2012

thanks for this usefull release.


Re: Textdraw Animations - Ballu Miaa - 24.03.2012

Damn good work! TextDraw_Pulsate , im in love with this!


Re: Textdraw Animations - Guilherme_. - 24.03.2012

nice !


Re: Textdraw Animations - Lorenc_ - 24.03.2012

Very nice include! Well done!


Re: Textdraw Animations - Kar - 24.03.2012

Nice ^

You gave me a idea for my new gamemode


Re: Textdraw Animations - Niko_boy - 24.03.2012

OMFG :O
REALLY AMAZING
I ENJOYED IT )) +good work


Re: Textdraw Animations - Awankz - 27.03.2012

Nice


Re: Textdraw Animations - DarkScripter - 27.03.2012

Very nice!


Re: Textdraw Animations - [IZ]Kira - 27.03.2012

x_O" it's coo , good job ;P