SetObjectMaterialText lags like hell in a timer.
#1

What I want: a display of player names using SetObjectMaterialText and some objects.

The issue: SetObjectMaterialText lags the whole server each time it's called in this timer, making the objects being changed flash textures and the server pause:

RESOLVED! See comments.

pawn Код:
public BoardsUpdate()
{
    new Status[16];
    if(GameJoin == true)
    {
        Status = "Joinable";
    }
    else
    {
        Status = "Not Joinable";
    }
    SetObjectMaterialText(board1[2],"Status:",0,OBJECT_MATERIAL_SIZE_256x128,"Arial Black",36,0,0xFF000000,0x00000000);
    SetObjectMaterialText(board1[3],Status,0,OBJECT_MATERIAL_SIZE_256x128,"Arial Black",36,0,0xFF000000,0x00000000);
    switch(BoardSet)
    {
        case 0:
        {
            SetObjectMaterialText(board1[0],"Players",0,OBJECT_MATERIAL_SIZE_256x128,"Arial Black",36,0,0xFF000000,0x00000000);
            SetObjectMaterialText(board1[1],"Connected",0,OBJECT_MATERIAL_SIZE_256x128,"Arial Black",36,0,0xFF000000,0x00000000);

            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    SetObjectMaterialText(board[i],GetName(i),0,OBJECT_MATERIAL_SIZE_256x128,"Arial",24,1,0xFF000000,0x00000000);
                }
                else
                {
                    SetObjectMaterialText(board[i],"===",0,OBJECT_MATERIAL_SIZE_256x128,"Arial",24,1,0xFF000000,0x00000000);
                }
            }
        }
        case 1:
        {
            SetObjectMaterialText(board1[0],"Players",0,OBJECT_MATERIAL_SIZE_256x128,"Arial Black",36,0,0xFF000000,0x00000000);
            SetObjectMaterialText(board1[1],"In-Game",0,OBJECT_MATERIAL_SIZE_256x128,"Arial Black",36,0,0xFF000000,0x00000000);

            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(PlayerIsInLobby[i] == false)
                {
                    new Float:health, color;
                    GetPlayerHealth(i, health);
                    if(100 >= health >= 75) color = 0xFF00AA00;
                    if(74 >= health >= 50) color = 0xFFAAAA00;
                    if(49 >= health >= 25) color = 0xFFFF9900;
                    if(24 >= health >= 1) color = 0xFFAA0000;
                    if(health == 0) color = 0xFFAAAAAA;
                    SetObjectMaterialText(board[i],GetName(i),0,OBJECT_MATERIAL_SIZE_256x128,"Arial",24,1,color,0x00000000);
                }
                else
                {
                    SetObjectMaterialText(board[i],"===",0,OBJECT_MATERIAL_SIZE_256x128,"Arial",24,1,0xFF000000,0x00000000);
                }
            }
        }
    }
    return 1;
}
Reply
#2

are you set that code for all player that join to your server
Reply
#3

Quote:
Originally Posted by semara123
Посмотреть сообщение
are you set that code for all player that join to your server
Nope, it's a global timer. (SetTimer)
Reply
#4

so why u using this script ?? imean for what u use

cause that script makes the server lag (fps lag)
Reply
#5

Quote:
Originally Posted by semara123
Посмотреть сообщение
so why u using this script ?? imean for what u use

cause that script makes the server lag (fps lag)
I've worked around the lag by creating variables to only change the texture if it needs to update.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)