Textdraws
#1

~~~~~~
Reply
#2

Impossible to guess without showing code.

You either have mixed textdraw ids or forgot to reset player variables. Are you mixing global textdraws with player textdraws?
Reply
#3

~~~~~~
Reply
#4

You're showing all the checkpoints in onplayerconnect, only show them, when say a command is called or when they need to read that textdraw.

EDIT: Oh I think I get you, but are all the textdraws created in the same spot?
Reply
#5

~~~~~~
Reply
#6

The problem with having textdraws distributed among filterscripts is that they take each other ids and then there are lots of textdraws with changed ids;

There are two ways to solve this:

The hard: Basically add a lot of checks, use INVALID_TEXT_DRAW hidden definition, make sure you create and destroy textdraws whenever needed, use non repeated variables, etc.
The easy: merge all textdraws into main gamemode or one script.
Reply
#7

~~~~~~
Reply
#8

Quote:
Originally Posted by Ananisiki
Посмотреть сообщение
What do you mean with "same spot"?
If your textdraws are in the same spot on the screen, same position... and you're showing them all at the same time, maybe you want a different one to show every 5 seconds for example... then they will all show, mergings themselves together, messing it up. If you're not doing this however, try what the other guy said
Reply
#9

Well yes, and before creating a textdraw check first if it's invalid, if it's not, destroy it (That would mean another textdraw has got the ID of the textdraw to create).

After destroying a textdraw, reset the variable to INVALID_TEXT_DRAW.
Reply
#10

~~~~~~
Reply
#11

I have a similar problem.
I have a hidden textdraw at the top of my screen.
It's only shown when doing convoys and displays the amount of convoy-members during the convoy.
It's also used for my traindriver class to inform you about the distance to the checkpoint.

But for some reason, after using "gmx" to restart the server, this textdraw is shown and my clock moves from the default position (right side of the screen, next to your weapon-display) into this textdraw.
But there is no code to add this clock into that textdraw anywhere.
Reply
#12

Before you use TextDrawCreatecheck if the variable you're using is not an invalid_text_Draw, for example

pawn Code:
if(TextDraw1 != Text:INVALID_TEXT_DRAW)
    TextDrawDestroy(Textdraw1);

TextDraw1 = TextDrawCreate(...)
This will destroy any textdraw that was stored at TextDraw1 (which should not happen). If you set the script correctly then there should be no problems (Such as creating the textdraws only once, destroying them only once, etcetera..)

Also when you destroy the Textdraws:

pawn Code:
TextDrawDestroy(Textdraw1);
TextDraw1 = Text:INVALID_TEXT_DRAW;
Note: It also works with player Textdraws, use the PlayerText label before INVALID_TEXT_DRAW
Reply
#13

~~~~~~
Reply
#14

Well, that will not create the textdraw if the ID is interfeered. It'll work, as not getting ID's mixed, though.

Use brackets for better idents:

pawn Code:
if(AdminCMDS0[playerid] != Text:INVALID_TEXT_DRAW)
{
    AdminCMDS0[playerid] = TextDrawCreate(20.000000, 100.000000, "~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ");
    TextDrawBackgroundColor(AdminCMDS0[playerid], 255);
    TextDrawFont(AdminCMDS0[playerid], 1);
    TextDrawLetterSize(AdminCMDS0[playerid], 0.500000, 1.000000);
    TextDrawColor(AdminCMDS0[playerid], -1);
    TextDrawSetOutline(AdminCMDS0[playerid], 0);
    TextDrawSetProportional(AdminCMDS0[playerid], 1);
    TextDrawSetShadow(AdminCMDS0[playerid], 1);
    TextDrawUseBox(AdminCMDS0[playerid], 1);
    TextDrawBoxColor(AdminCMDS0[playerid], 170);
    TextDrawTextSize(AdminCMDS0[playerid], 210.000000, -1.000000);
    TextDrawSetSelectable(AdminCMDS0[playerid], 0);
}
   
or

if(AdminCMDS0[playerid] != Text:INVALID_TEXT_DRAW)
    TextDrawDestroy(AdminsCMDS0[playerid]);
   
AdminCMDS0[playerid] = TextDrawCreate(20.000000, 100.000000, "~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ");
TextDrawBackgroundColor(AdminCMDS0[playerid], 255);
TextDrawFont(AdminCMDS0[playerid], 1);
TextDrawLetterSize(AdminCMDS0[playerid], 0.500000, 1.000000);
TextDrawColor(AdminCMDS0[playerid], -1);
TextDrawSetOutline(AdminCMDS0[playerid], 0);
TextDrawSetProportional(AdminCMDS0[playerid], 1);
TextDrawSetShadow(AdminCMDS0[playerid], 1);
TextDrawUseBox(AdminCMDS0[playerid], 1);
TextDrawBoxColor(AdminCMDS0[playerid], 170);
TextDrawTextSize(AdminCMDS0[playerid], 210.000000, -1.000000);
TextDrawSetSelectable(AdminCMDS0[playerid], 0);
The last one is better;

This will all work assuming you've set AdminCMDS0 as invalid textdraws: AdminCMDS0[MAX_PLAYERS] = {Text:INVALID_TEXT_DRAW, ...}

Also you can use bidimensional arrays for textdraws:

AdminCMDS[playerid][0], AdminCMDS[playerid][1], etc...
Reply
#15

~~~~~~
Reply
#16

Use the second method I've provided on all textdraws.

pawn Code:
if(AdminCMDS0[playerid] != Text:INVALID_TEXT_DRAW)
    TextDrawDestroy(AdminsCMDS0[playerid]);
   
AdminCMDS0[playerid] = TextDrawCreate(20.000000, 100.000000, "~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ");
TextDrawBackgroundColor(AdminCMDS0[playerid], 255);
TextDrawFont(AdminCMDS0[playerid], 1);
TextDrawLetterSize(AdminCMDS0[playerid], 0.500000, 1.000000);
TextDrawColor(AdminCMDS0[playerid], -1);
TextDrawSetOutline(AdminCMDS0[playerid], 0);
TextDrawSetProportional(AdminCMDS0[playerid], 1);
TextDrawSetShadow(AdminCMDS0[playerid], 1);
TextDrawUseBox(AdminCMDS0[playerid], 1);
TextDrawBoxColor(AdminCMDS0[playerid], 170);
TextDrawTextSize(AdminCMDS0[playerid], 210.000000, -1.000000);
TextDrawSetSelectable(AdminCMDS0[playerid], 0);
P.S: Using a MAX_PLAYERS loop to create a player-arrayed textdraw will create 500 textdraws since there is no !IsPlayerConnected exceptual; Create textdraws when the player connects and delete them when he disconnects.
Reply
#17

~~~~~~
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)