Stacked textdraw problem
#1

Hey! So my problem is pretty self explanatory cause the video but I'll explain it as much as I can. When I enter the CP the textdraws are made and the timer goes off at the same time which hides the textdraws after 5 seconds. Well its working fine, but when I enter twice in a row the second textdraw just dont disappear after 5 seconds. Here is some code:

PHP код:
hook OnPlayerEnterDynamicCP(playeridcheckpointid)
{
    if(
pData[playerid][pGroup] == GROUP_TYPE_LAW)
    {
        if(
checkpointid == checkpoint)
        {
            
Law_VS_Pressy(playerid);
            
SetTimerEx("DLaw_VS_Pressy"40000"i"playerid);
            
PlayerPlaySound(playerid,1150,1568.5251,-1610.2024,11);
        }
    }
    return 
1;
}
forward DLaw_VS_Pressy(playerid);
public 
DLaw_VS_Pressy(playerid)
{
    
TextDrawHideForPlayer(playeridLaw_VS_Pressy1);
    
TextDrawDestroy(Law_VS_Pressy1);

Whats the best work-around for this problem? Thanks for the help in advance.
Reply
#2

This is why you create textdraws ONCE and only show and hide them! The problem is you keep creating them even though they are created you would have to destroy first then create new ones. Yes you can do it like this not recommended though. There is even a further error.

Код:
TextDrawDestroy(Law_VS_Pressy1);
How would you ever expect that to work with more than one player?

There is no work around here because there is nothing to work around! You need to do things correctly otherwise you will have problem after problem.
Reply
#3

Quote:
Originally Posted by Pottus
Посмотреть сообщение
This is why you create textdraws ONCE and only show and hide them! The problem is you keep creating them even though they are created you would have to destroy first then create new ones. Yes you can do it like this not recommended though. There is even a further error.

Код:
TextDrawDestroy(Law_VS_Pressy1);
How would you ever expect that to work with more than one player?

There is no work around here because there is nothing to work around! You need to do things correctly otherwise you will have problem after problem.
Thank you Pottus! Honestly I dont know why I put the TextDrawDestroy line there, I was trying everything at the end. Im relatively new to pawn so most of my questions are stupid, Im sorry. I tried to search answers for similar problems but I couldnt find any so I was like "mmkay, Im going to ask it even if its dumb". Anyways, thank you, its working like a charm now!
Reply
#4

Here is the rules with textdraws.

1.) You have 2000 limit for global textdraws. Global textdraws are used for any textdraw that either doesn't change or changes for everyone! These are not created/deleted in good practice.
2.) Player textdraws are used when you have per-player output and are limited to 256. For that reason on occasion it may be necessary to use the create/delete method when lots are used.
3.) Recycle textdraws that are similar ie. You have a background that doesn't change but text that does. Either a.) Create text for each situation b.) Use a player textdraw and change text as needed - Depending on the situation action "b" is typically the best way to go.

I know the rules are so simple! But people have trouble following the concept of their use.
Reply
#5

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Here is the rules with textdraws.

1.) You have 2000 limit for global textdraws. Global textdraws are used for any textdraw that either doesn't change or changes for everyone! These are not created/deleted in good practice.
2.) Player textdraws are used when you have per-player output and are limited to 256. For that reason on occasion it may be necessary to use the create/delete method when lots are used.
3.) Recycle textdraws that are similar ie. You have a background that doesn't change but text that does. Either a.) Create text for each situation b.) Use a player textdraw and change text as needed - Depending on the situation action "b" is typically the best way to go.

I know the rules are so simple! But people have trouble following the concept of their use.
Thank you for the additional information as well! I'll work with a lot of textdraws so its going to be handy!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)