PDA

View Full Version : Textdraw Problem


leongky94
21/12/2011, 11:10 PM
Hi guys,
I have a problem with animated textdraw, when i start my server it works fine but after awhile it starts to speed up and speed up until it unreadable. How can i fix it?

leongky94
22/12/2011, 12:05 AM
Ops, forgot to post the code :)


new Text:TextLogo;
new TextLogoCount = 0;
forward ChangeTextLogo(text[]);
#define logocount 58
forward logorotate();

//Logo Textdraw
TextLogo = TextDrawCreate(506.000000, 96.000000, "FREE_PLAY");
TextDrawBackgroundColor(TextLogo, 255);
TextDrawFont(TextLogo, 3);
TextDrawLetterSize(TextLogo, 0.579999, 1.700000);
TextDrawColor(TextLogo, -1);
TextDrawSetOutline(TextLogo, 1);
TextDrawSetProportional(TextLogo, 1);

Public OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid, TextLogo);
SetTimer("logorotate",500,1);
}

public OnGameModeExit()
{
TextDrawDestroy(TextLogo);
}

public ChangeTextLogo(text[])
{
TextDrawSetString(TextLogo,text);
return 1;
}

public logorotate()
{
if(TextLogoCount > logocount) TextLogoCount = 0;
switch(TextLogoCount)
{
case 0:{ChangeTextLogo("~h~~y~F~w~REE_PL~w~AY");}
case 1:{ChangeTextLogo("~h~~w~F~y~R~w~EE_PLA~w~Y");}
case 2:{ChangeTextLogo("~h~~w~FR~y~E~w~E_PLA~w~Y");}
case 3:{ChangeTextLogo("~h~~w~FRE~y~E_~w~PLA~w~Y");}
case 4:{ChangeTextLogo("~h~~w~FREE_~y~P~w~LA~w~Y");}
case 5:{ChangeTextLogo("~h~~w~FREE_P~y~L~w~A~w~Y");}
case 6:{ChangeTextLogo("~h~~w~FREE_PL~y~A~w~Y");}
case 7:{ChangeTextLogo("~h~~g~F~w~REE_PL~y~A~w~Y");}
case 8:{ChangeTextLogo("~h~~w~F~g~R~w~EE_PL~y~A~w~Y");}
case 9:{ChangeTextLogo("~h~~w~FR~g~E~w~E_PL~y~A~w~Y");}
case 10:{ChangeTextLogo("~h~~w~FRE~g~E_~w~PL~y~A~w~Y");}
case 11:{ChangeTextLogo("~h~~w~FREE_~g~P~w~L~y~A~w~Y");}
case 12:{ChangeTextLogo("~h~~w~FREE_P~g~L~y~A~w~Y");}
case 13:{ChangeTextLogo("~h~~r~F~w~REE_P~g~L~y~A~w~Y");}
case 14:{ChangeTextLogo("~h~~w~F~r~R~w~EE_P~g~L~y~A~w~Y");}
case 15:{ChangeTextLogo("~h~~w~FR~r~E~w~E_P~g~L~y~A~w~Y");}
case 16:{ChangeTextLogo("~h~~w~FRE~r~E_~w~P~g~L~y~A~w~Y");}
case 17:{ChangeTextLogo("~h~~w~FREE_~r~P~g~L~y~A~w~Y");}
case 18:{ChangeTextLogo("~h~~b~F~w~REE_~r~P~g~L~y~A~w~Y");}
case 19:{ChangeTextLogo("~h~~w~F~b~R~w~EE_~r~P~g~L~y~A~w~Y");}
case 20:{ChangeTextLogo("~h~~w~FR~b~E~w~E_~r~P~g~L~y~A~w~Y");}
case 21:{ChangeTextLogo("~h~~w~FRE~b~E_~r~P~g~L~y~A~w~Y");}
case 22:{ChangeTextLogo("~h~~y~F~w~RE~b~E_~r~P~g~L~y~A~w~Y");}
case 23:{ChangeTextLogo("~h~~w~F~y~R~w~E~b~E_~r~P~g~L~y~A~w~Y");}
case 24:{ChangeTextLogo("~h~~w~FR~y~E~b~E_~r~P~g~L~y~A~w~Y");}
case 25:{ChangeTextLogo("~h~~g~F~w~R~y~E~b~E_~r~P~g~L~y~A~w~Y");}
case 26:{ChangeTextLogo("~h~~w~F~g~R~y~E~b~E_~r~P~g~L~y~A~w~Y");}
case 27:{ChangeTextLogo("~h~~r~F~g~R~y~E~b~E_~r~P~g~L~y~A~w~Y");}
case 28:{ChangeTextLogo("_");}
case 29:{ChangeTextLogo("~h~~r~F~g~R~y~E~b~E_~r~P~g~L~y~A~w~Y");}
case 30:{ChangeTextLogo("_");}
case 31:{ChangeTextLogo("~h~~r~F~g~R~y~E~b~E_~r~P~g~L~y~A~w~Y");}
case 32:{ChangeTextLogo("~h~~w~F~g~R~y~E~b~E_~r~P~g~L~y~A~w~Y");}
case 33:{ChangeTextLogo("~h~~g~F~w~R~y~E~b~E_~r~P~g~L~y~A~w~Y");}
case 34:{ChangeTextLogo("~h~~w~FR~y~E~b~E_~r~P~g~L~y~A~w~Y");}
case 35:{ChangeTextLogo("~h~~w~F~y~R~w~E~b~E_~r~P~g~L~y~A~w~Y");}
case 36:{ChangeTextLogo("~h~~y~F~w~RE~b~E_~r~P~g~L~y~A~w~Y");}
case 37:{ChangeTextLogo("~h~~w~FRE~b~E_~r~P~g~L~y~A~w~Y");}
case 38:{ChangeTextLogo("~h~~w~FR~b~E~w~E_~r~P~g~L~y~A~w~Y");}
case 39:{ChangeTextLogo("~h~~w~F~b~R~w~EE_~r~P~g~L~y~A~w~Y");}
case 40:{ChangeTextLogo("~h~~b~F~w~REE_~r~P~g~L~y~A~w~Y");}
case 41:{ChangeTextLogo("~h~~w~FREE_~r~P~g~L~y~A~w~Y");}
case 42:{ChangeTextLogo("~h~~w~FRE~r~E_~w~P~g~L~y~A~w~Y");}
case 43:{ChangeTextLogo("~h~~w~FR~r~E~w~E_P~g~L~y~A~w~Y");}
case 44:{ChangeTextLogo("~h~~w~F~r~R~w~EE_P~g~L~y~A~w~Y");}
case 45:{ChangeTextLogo("~h~~r~F~w~REE_P~g~L~y~A~w~Y");}
case 46:{ChangeTextLogo("~h~~w~FREE_P~g~L~y~A~w~Y");}
case 47:{ChangeTextLogo("~h~~w~FREE_~g~P~w~L~y~A~w~Y");}
case 48:{ChangeTextLogo("~h~~w~FRE~g~E_~w~PL~y~A~w~Y");}
case 49:{ChangeTextLogo("~h~~w~FR~g~E~w~E_PL~y~A~w~Y");}
case 50:{ChangeTextLogo("~h~~w~F~g~R~w~EE_PL~y~A~w~Y");}
case 51:{ChangeTextLogo("~h~~g~F~w~REE_PL~y~A~w~Y");}
case 52:{ChangeTextLogo("~h~~w~FREE_PL~y~A~w~Y");}
case 53:{ChangeTextLogo("~h~~w~FREE_P~y~L~w~A~w~Y");}
case 54:{ChangeTextLogo("~h~~w~FREE_~y~P~w~LA~w~Y");}
case 55:{ChangeTextLogo("~h~~w~FRE~y~E_~w~PLA~w~Y");}
case 56:{ChangeTextLogo("~h~~w~FR~y~E~w~E_PLA~w~Y");}
case 57:{ChangeTextLogo("~h~~w~F~y~R~w~EE_PLA~w~Y");}
}
TextLogoCount++;
}

Alureon
22/12/2011, 12:08 AM
EDIT: Wrong post...

coole210
22/12/2011, 12:12 AM
It speeds up because there is no playerid parameter, making it change speeds whenever somebody spawns.

I suggest using this and setting it up appropriately.

new Text:TextLogo[MAX_PLAYERS];
new TextLogoCount[MAX_PLAYERS] = 0;
forward ChangeTextLogo(playerid,text[]);
#define logocount 58
forward logorotate(playerid);


Also, you would want to create the textdraw, show the textdraw and set the logorotate timer in OnPlayerConnect callback.


public OnPlayerConnect(playerid)
{
TextLogo[playerid] = TextDrawCreate(506.000000, 96.000000, "FREE_PLAY");
TextDrawBackgroundColor(TextLogo[playerid], 255);
TextDrawFont(TextLogo[playerid], 3);
TextDrawLetterSize(TextLogo[playerid], 0.579999, 1.700000);
TextDrawColor(TextLogo[playerid], -1);
TextDrawSetOutline(TextLogo, 1);
TextDrawSetProportional(TextLogo[playerid], 1);
TextDrawShowForPlayer(playerid,TextLogo[playerid]);
SetTimerEx("logorotate",500,1,"d",playerid);
}


Making it individual between all the players and it should fix the problem

leongky94
22/12/2011, 12:24 AM
It speeds up because there is no playerid parameter, making it change speeds whenever somebody spawns.

I suggest using this and setting it up appropriately.

new Text:TextLogo[MAX_PLAYERS];
new TextLogoCount[MAX_PLAYERS] = 0;
forward ChangeTextLogo(playerid,text[]);
#define logocount 58
forward logorotate(playerid);


Also, you would want to create the textdraw, show the textdraw and set the logorotate timer in OnPlayerConnect callback.


public OnPlayerConnect(playerid)
{
TextLogo[playerid] = TextDrawCreate(506.000000, 96.000000, "FREE_PLAY");
TextDrawBackgroundColor(TextLogo[playerid], 255);
TextDrawFont(TextLogo[playerid], 3);
TextDrawLetterSize(TextLogo[playerid], 0.579999, 1.700000);
TextDrawColor(TextLogo[playerid], -1);
TextDrawSetOutline(TextLogo, 1);
TextDrawSetProportional(TextLogo[playerid], 1);
TextDrawShowForPlayer(playerid,TextLogo[playerid]);
SetTimerEx("logorotate",500,1,"d",playerid);
}


Making it individual between all the players and it should fix the problem
Hi, thanks for the reply but i got error when compile.


C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(4082) : error 017: undefined symbol "playerid"
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(4083) : error 017: undefined symbol "playerid"
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(4084) : error 017: undefined symbol "playerid"
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(4085) : error 017: undefined symbol "playerid"
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(4086) : error 017: undefined symbol "playerid"
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(4087) : error 035: argument type mismatch (argument 1)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(4088) : error 017: undefined symbol "playerid"
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(4089) : error 017: undefined symbol "playerid"
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(4090) : error 017: undefined symbol "playerid"
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(7911) : error 035: argument type mismatch (argument 2)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(14024) : error 035: argument type mismatch (argument 1)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(14025) : error 035: argument type mismatch (argument 1)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38753) : error 025: function heading differs from prototype
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38755) : error 035: argument type mismatch (argument 1)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38761) : error 033: array must be indexed (variable "TextLogoCount")
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38761) : error 033: array must be indexed (variable "TextLogoCount")
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38762) : error 033: array must be indexed (variable "-unknown-")
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38764) : error 035: argument type mismatch (argument 1)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38765) : error 035: argument type mismatch (argument 1)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38766) : error 035: argument type mismatch (argument 1)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38767) : error 035: argument type mismatch (argument 1)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38768) : error 035: argument type mismatch (argument 1)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38769) : error 035: argument type mismatch (argument 1)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38770) : error 035: argument type mismatch (argument 1)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38771) : error 035: argument type mismatch (argument 1)
C:\Users\Brandon Leong\Desktop\Gamemodes\DXGFP_V2.pwn(38772) : error 035: argument type mismatch (argument 1)

coole210
22/12/2011, 12:28 AM
Post all the lines that have errors, you didn't change the script appropriately

CyNiC
22/12/2011, 12:33 AM
You could just put the SetTimer on OnGameModeInit.

leongky94
22/12/2011, 01:09 AM
is it new Text:TextLogo[MAX_PLAYERS]; or Text:TextLogo[playerid];?

leongky94
22/12/2011, 01:40 AM
It works now, Thank you. :)
+Rep to you.