SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 24/11/2013, 05:21 PM   #1
Bombo
Huge Clucker
 
Bombo's Avatar
 
Join Date: Jun 2012
Posts: 267
Reputation: 76
Default Animated TextDraw(s)

LiveText


Author: Bombo
Version: 1.1.2


Start in OnPlayerConnect()
Finish in OnPlayerSpawn()


Code:
// LiveText v1.1.2 by Bombo

#include <a_samp>

#include "../include/gl_common.inc"

#define LIVE_TEXT_LEN 15 //you MUST set the text length

//the text
new LiveTextString[] = "forum.sa-mp.com";

//position (posx, posy) and interval between chars (width)
//are set in CreateLiveText()
new Float:posx, Float:posy, Float:width;

new PlayerText:start_b[MAX_PLAYERS*LIVE_TEXT_LEN];
new Float:site_size[MAX_PLAYERS*LIVE_TEXT_LEN];
new Float:add[MAX_PLAYERS*LIVE_TEXT_LEN];
new bool:IsPlayerSpawned[MAX_PLAYERS];
new TimerMove;
new Float:size_add;

forward TimerMoveText();

public OnFilterScriptInit()
{
    new i;

    print("\n--------------------------------------");
    print(" LiveText v1.1.2 by Bombo");
    print("--------------------------------------\n");

	for(i = 0; i < MAX_PLAYERS; ++i)
      IsPlayerSpawned[i] = false;

    for(i = 0; i < MAX_PLAYERS; ++i)
    {
      if(IsPlayerConnected(i) && !IsPlayerSpawned[i])
      {
        CreateLiveText(i);
        ShowLiveText(i);
      }
    }

    TimerMove = SetTimer("TimerMoveText", 50, true);
       
    return 1;
}

public OnFilterScriptExit()
{
    new i;

    for(i = 0; i < MAX_PLAYERS; ++i)
    {
        if(IsPlayerConnected(i))
         DestroyLiveText(i);
    }

    KillTimer(TimerMove);
    
    return 1;
}

CreateLiveText(i) //Is called in OnFilterScriptInit()
{
  new j, k;
  new str[2];

  width = 16.0;
  posx = 400.0;
  posy = 420.0;
  size_add = 0.2;
  
  str[1] = '\0';

  for(j = 0; j < LIVE_TEXT_LEN; ++j)
  {
    format(str, 2, "%c", LiveTextString[j]);
    start_b[i*LIVE_TEXT_LEN+j] = CreatePlayerTextDraw(i,posx+width*j,posy,str);
  }

  //start position calculation
  for(j = 0; j < LIVE_TEXT_LEN; ++j)
  {
    add[i*LIVE_TEXT_LEN+j] = size_add;
    site_size[i*LIVE_TEXT_LEN+j] = 1 + size_add + j%2;
    
    for(k = 0; k < j; ++k)
    {
      if(site_size[i*LIVE_TEXT_LEN+j] > 4 || site_size[i*LIVE_TEXT_LEN+j] < 0.01)
      {
        if(site_size[i*LIVE_TEXT_LEN+j] > 4)
          site_size[i*LIVE_TEXT_LEN+j] = 4;
        else
          site_size[i*LIVE_TEXT_LEN+j] = 0.01;

        if(add[i*LIVE_TEXT_LEN+j] == size_add)
          add[i*LIVE_TEXT_LEN+j] = -size_add;
        else
          add[i*LIVE_TEXT_LEN+j] = size_add;
      }
      site_size[i*LIVE_TEXT_LEN+j] = site_size[i*LIVE_TEXT_LEN+j] + add[i*LIVE_TEXT_LEN+j];
    }
  }

  for(j = 0; j < LIVE_TEXT_LEN; ++j)
  {
    PlayerTextDrawAlignment(i, start_b[i*LIVE_TEXT_LEN+j],0);
    PlayerTextDrawBackgroundColor(i, start_b[i*LIVE_TEXT_LEN+j],0x00705F2F);
    PlayerTextDrawFont(i, start_b[i*LIVE_TEXT_LEN+j],2);
    PlayerTextDrawLetterSize(i, start_b[i*LIVE_TEXT_LEN+j],0.5,1.0);
    PlayerTextDrawColor(i, start_b[i*LIVE_TEXT_LEN+j],0xFFFF00FF);
    PlayerTextDrawSetOutline(i, start_b[i*LIVE_TEXT_LEN+j],1);
    PlayerTextDrawSetProportional(i, start_b[i*LIVE_TEXT_LEN+j],1);
    PlayerTextDrawSetShadow(i, start_b[i*LIVE_TEXT_LEN+j],3);
  }
}

MoveLiveText(i) //Is called in TimerMoveText()
{
  new j;
  new str[2];

  str[1] = '\0';

  HideLiveText(i);
  DestroyLiveText(i);
  
  for(j = 0; j < LIVE_TEXT_LEN; ++j)
  {
    format(str, 2, "%c", LiveTextString[j]);
    start_b[i*LIVE_TEXT_LEN+j] = CreatePlayerTextDraw(i,posx+width*j,posy+site_size[i*LIVE_TEXT_LEN+j]*site_size[i*LIVE_TEXT_LEN+j]+1,str);
  }

  for(j = 0; j < LIVE_TEXT_LEN; ++j)
  {
    //next coordinates colculation
    site_size[i*LIVE_TEXT_LEN+j] = site_size[i*LIVE_TEXT_LEN+j] + add[i*LIVE_TEXT_LEN+j];
    if(site_size[i*LIVE_TEXT_LEN+j] > 4 || site_size[i*LIVE_TEXT_LEN+j] < 0.01)
    {
      if(site_size[i*LIVE_TEXT_LEN+j] > 4)
        site_size[i*LIVE_TEXT_LEN+j] = 4;
      else
        site_size[i*LIVE_TEXT_LEN+j] = 0.01;

      if(add[i*LIVE_TEXT_LEN+j] == size_add)
          add[i*LIVE_TEXT_LEN+j] = -size_add;
      else
        add[i*LIVE_TEXT_LEN+j] = size_add;
    }

    PlayerTextDrawAlignment(i, start_b[i*LIVE_TEXT_LEN+j],0);
    PlayerTextDrawBackgroundColor(i, start_b[i*LIVE_TEXT_LEN+j],0x00705F2F);
    PlayerTextDrawFont(i, start_b[i*LIVE_TEXT_LEN+j],2);
//    PlayerTextDrawLetterSize(i, start_b[i*LIVE_TEXT_LEN+j],0.5,1.0+site_size[i*LIVE_TEXT_LEN+j]);
    PlayerTextDrawColor(i, start_b[i*LIVE_TEXT_LEN+j],0xFFFF00FF);
    PlayerTextDrawSetOutline(i, start_b[i*LIVE_TEXT_LEN+j],1);
    PlayerTextDrawSetProportional(i, start_b[i*LIVE_TEXT_LEN+j],1);
    PlayerTextDrawSetShadow(i, start_b[i*LIVE_TEXT_LEN+j],3);
  }
  
  ShowLiveText(i);
}

ShowLiveText(i)
{
  new j;

  for(j = 0; j < LIVE_TEXT_LEN; ++j)
    PlayerTextDrawShow(i, start_b[i*LIVE_TEXT_LEN+j]);
}

HideLiveText(i)
{
  new j;

  for(j = 0; j < LIVE_TEXT_LEN; ++j)
    PlayerTextDrawHide(i, start_b[i*LIVE_TEXT_LEN+j]);
}

DestroyLiveText(i) //  OnFilterScriptExit()
{
  new j;

  for(j = 0; j < LIVE_TEXT_LEN; ++j)
    PlayerTextDrawDestroy(i,start_b[i*LIVE_TEXT_LEN+j]);
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    CreateLiveText(playerid);
    ShowLiveText(playerid);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    IsPlayerSpawned[playerid] = true;
    DestroyLiveText(playerid);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    IsPlayerSpawned[playerid] = false;
    DestroyLiveText(playerid);
    return 1;
}

public TimerMoveText()
{
  new i;

  for(i = 0; i < MAX_PLAYERS; ++i)
  {
    if(IsPlayerConnected(i) && !IsPlayerSpawned[i])
    {
      MoveLiveText(i);
    }
  }
}
The result:

Tested: 25.11.2013
Attached Files
File Type: pwn livetext.pwn (5.5 KB, 119 views)
File Type: amx livetext.amx (26.3 KB, 19 views)
__________________
[Tool/Web/Other] SA:MP multiloader
[Plugin] Automatic chat translator
[GameMode] DayZ+ [0.3z]
[Plugin] imessage - fast multilanguage strings
[Tool/Web/Other] player search service

Last edited by Bombo; 25/11/2013 at 05:23 PM. Reason: bugfix
Bombo is offline   Reply With Quote
Old 24/11/2013, 05:24 PM   #2
KickInTheMick
Banned
 
Join Date: Mar 2013
Posts: 36
Reputation: 4
Default Re: Animated TextDraw(s)

Awesome +REP
KickInTheMick is offline   Reply With Quote
Old 24/11/2013, 05:24 PM   #3
Kindred
High-roller
 
Join Date: Aug 2011
Posts: 1,252
Reputation: 504
Default Re: Animated TextDraw(s)

Well done. Looks neat.
Kindred is offline   Reply With Quote
Old 24/11/2013, 07:14 PM   #4
xBaDaSSx
Banned
 
Join Date: Oct 2013
Location: Berlin,Germany
Posts: 109
Reputation: 3
Default Re: Animated TextDraw(s)

have bugs, not appear when you enter the server.
xBaDaSSx is offline   Reply With Quote
Old 24/11/2013, 07:39 PM   #5
Rockstar128
Banned
 
Join Date: Sep 2013
Location: Earth
Posts: 98
Reputation: -4
Default Re: Animated TextDraw(s)

Keep it up
Rockstar128 is offline   Reply With Quote
Old 24/11/2013, 08:13 PM   #6
Gen3i
Huge Clucker
 
Gen3i's Avatar
 
Join Date: Jun 2013
Location: New Zealand
Posts: 287
Reputation: 10
Default Re: Animated TextDraw(s)

Nice.
__________________
The Locos Crew since 2013
Gen3i is offline   Reply With Quote
Old 24/11/2013, 08:16 PM   #7
-Prodigy-
Huge Clucker
 
Join Date: Dec 2010
Posts: 398
Reputation: 45
Default Re: Animated TextDraw(s)

That's pretty bad ass!
-Prodigy- is offline   Reply With Quote
Old 24/11/2013, 08:40 PM   #8
Bombo
Huge Clucker
 
Bombo's Avatar
 
Join Date: Jun 2012
Posts: 267
Reputation: 76
Default Re: Animated TextDraw(s)

Quote:
Originally Posted by xBaDaSSx View Post
have bugs, not appear when you enter the server.
Always or sometimes? Does anybody have the same bug?
__________________
[Tool/Web/Other] SA:MP multiloader
[Plugin] Automatic chat translator
[GameMode] DayZ+ [0.3z]
[Plugin] imessage - fast multilanguage strings
[Tool/Web/Other] player search service
Bombo is offline   Reply With Quote
Old 24/11/2013, 08:59 PM   #9
-Prodigy-
Huge Clucker
 
Join Date: Dec 2010
Posts: 398
Reputation: 45
Default Re: Animated TextDraw(s)

It probably happened when he loaded the FS in his server. So it should be like this:
pawn Code:
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" LiveText v1.1 by Bombo");
    print("--------------------------------------\n");

    for(new i = 0; i < MAX_PLAYERS; ++i)
    {
        if(IsPlayerConnected(i))
        {
            CreateLiveText(i);
            ShowLiveText(i);
        }
    }

    TimerMove = SetTimer("TimerMoveText", 50, true);
    return 1;
}
Just tested it and it works pretty good and smooth
-Prodigy- is offline   Reply With Quote
Old 24/11/2013, 09:14 PM   #10
iZN
High-roller
 
Join Date: Jun 2010
Posts: 2,368
Reputation: 569
Default Re: Animated TextDraw(s)

Ah, unique idea. Good work.
__________________
iZN is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Animated TEXT_DRAW_FONT_MODEL_PREVIEW Misiur Scripting Help 2 23/02/2013 09:34 PM
Animated avatars YoUnG_KiD Everything and Nothing 8 25/11/2011 11:42 AM
Animated Avatars? DirtyLilFreak Everything and Nothing 2 16/07/2011 04:05 PM
Animated gif thread. kaisersouse Everything and Nothing 45 10/07/2009 04:57 AM
some funny animated .gif Aji Everything and Nothing 23 07/12/2008 06:16 PM


All times are GMT. The time now is 04:49 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.