The fading effect from timer at first use is laggy?
#1

Hello, I have timer that will fade textdraws in, it's working fine, but I have issue, that when I restart server, first fade in is laggy. When I fade in again, it's working just fine.

pawn Код:
//Inside of my debug command:
gs_MaintenanceFadeInTimer = SetTimerEx("FadeIn", 5, false, "ii", type, 0);

//The callback
forward FadeIn(type, alpha);
public FadeIn(type, alpha)
{
    switch(type)
    {
        case 1:
        {
            alpha += 1;
            //
            new
                R,
                G,
                B,
                A;
            //
            PlayersLoop(i)
            {
                if(IsPlayerConnected(i))
                {
                    for(new k; k < MAX_DNMAINTENANCE_IB_TEXTDRAWS; k++)
                    {
                        get_rgba(gs_MaintenanceInfoBoxColor[k], R, G, B, A);
                        //
                        if(alpha <= A)
                        {
                            printf("DEBUG: FadeIn timer function - Setting alpha %i", A);
                            PlayerTextDrawBoxColor(i, gs_MaintenanceInfoBox[i][k], RGBToHex(R, G, B, alpha));                       PlayerTextDrawShow(i, gs_MaintenanceInfoBox[i][k]);
                        }
                    }
                }
            }
            if(alpha >= 255)
            {
                //If textdraws are faded in, stop the code
                return 1;
            }
            else
            {
                //If not recall timer with increaded alpha
                gs_MaintenanceFadeInTimer = SetTimerEx("FadeIn", 5, false, "ii", type, alpha);
            }
        }
    }
    return 1;
}
So after gmx when I type my debug command for first time the fade effect is crappy and laggy
After that when I type my debug command again and again it's still working fine. I really can't figure problem, when it's working fine on second fade in effect and more.

Video: https://*********/Y6M5vL9vkyI
Reply
#2

Bump, you can see in video (first post) how is first call slower (when server starts, not GMX) in fading textdraws, than the all others.
Reply
#3

I am quite sure that it isn't related to textdraws. I have same issue with my backpack crafting/skills/collectibles textdraws when I have to show all of them for the first time, but when I have to do it second time it works way faster.

It's not even code or SA-MP's problem. That's how textdraws work and client-sided technique that is used. It's pretty much the same rule as with the web-site related stuff. For the first time when you load a page, it might take longer than you open the same webpage again (eg. refresh it).
Reply
#4

Yeah, that's completely it, it works just fine after the first use, when I use gmx to restart server it's still working fine though, but when I do exit and afterwards I again start server it's way slower than it should be.
Reply
#5

hmm thats interesting.. did u try commenting out stuff to find out which functions slow it down? is it PlayerTextDrawBoxColor ?

does it still happen if you decrease the first time run timer from 5 ms to like 2ms and see if its about the same fade in time. that could be a temporary solution

idk im curious why this happens now as well maybe someone has an answer .. i agree with what Riddick94 said but he didnt say what causes it, ur browser stores temporary files/ images i guess but how is that the same with textdraws
Reply
#6

The client needs to load/create the textdraws first of course and that is going to take time for the client.
Reply
#7

Quote:
Originally Posted by Pottus
Посмотреть сообщение
The client needs to load/create the textdraws first of course and that is going to take time for the client.
but i thought he said it only happens after server restart not game restart ..
Reply
#8

Yes, when I exit and start the samp-server. (I don't reopen client). The fun is when I use gmx to restart server it works fine even after the restart.
Reply
#9

Edit:// I've found it out, as Pottus said client needs to load textdraws, when I restart client (server is running) it's laggy for first time again.

Is there way to make some "init" for these textdraws? On player connect? Thanks.
Reply
#10

You could create a black textdraw this needs to be the last one created then show that textdraw first then show all other textdraws to pre-load them.

My suggestion make an include file that hooks the create functions and keeps track of all created textdraws.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)