13.02.2013, 20:53
(
Last edited by Bombo; 10/05/2016 at 01:40 PM.
)
Скрипт в тему
На TextDrawCreate() такой не получится. Выводит только первые 5 символов. Мож кто знает почему?
PHP Code:
// LiveText v1.0 by Bombo
#include <a_samp>
#include "../include/gl_common.inc"
#define LIVE_TEXT_LEN 15 //необходимо указать длину текста
//сам текст
new LiveTextString[] = "forum.sa-mp.com";
//позиция (posx, posy) и интервал между буквами (width)
//задаются в 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 TimerMove;
new Float:size_add;
forward TimerMoveText();
public OnFilterScriptInit()
{
new i;
print("\n--------------------------------------");
print(" LiveText v1.0 by Bombo");
print("--------------------------------------\n");
for(i = 0; i < MAX_PLAYERS; ++i)
{
if(IsPlayerConnected(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) //Вызов в 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);
}
//расчёт начальной позиции букв
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) //Вызов в обработчике таймера 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)
{
//расчёт следующех координат текста
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 OnPlayerDisconnect(playerid, reason)
{
DestroyLiveText(playerid);
return 1;
}
public TimerMoveText()
{
new i;
for(i = 0; i < MAX_PLAYERS; ++i)
{
if(IsPlayerConnected(i))
{
MoveLiveText(i);
}
}
}