[Ajuda] SetTimer
#1

Pessoal.

Qual o Mais Recomendado. - Leg Para o Servidor:


SetTimer - Atualizado Globalmente.

ou

SetTimerEx - Atualizado por Player.


Em Meu Servidor eu Uso:

CallBack OnGamemodeInit:

SetTimer("AtualizarTodos", 990, 1);//Timer de Atualizacao Global para Todos Do Servidor. Atualiza Score,Level etcc..
Em Textdraw..


Seria Mais Recomendado Criar um Timer Repetitivo para Cada Player?


vlw


#2 Duvida. Tem Como Melhorar Isto:

PHP код:
public VisibilityUpdate()////Creditos a Devastator - UGW
{
    new 
dist;
    new 
Float:xFloat:x1Float:yFloat:y1Float:tmp;
    for(new 
0<= MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            
GetPlayerPos(ixytmp);
            for(new 
0<= MAX_PLAYERSj++)
            {
                if(
IsPlayerConnected(j) && != && Player[i][PlayerGPS] != j)
                {
                    
GetPlayerPos(jx1y1tmp);
                    
dist floatround(floatsqroot(floatpower(floatabs(floatsub(x,x1)),2)+floatpower(floatabs(floatsub(y,y1)),2)));
                    if(
Player[i][PlayingWar] == true)
                    {
                        
SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000011));
                      }
                      else if(
GetPlayerVirtualWorld(j) == GetPlayerVirtualWorld(i) && GetPlayerVirtualWorld(i) == 24)
                      {
                          
SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x000000FF));
                      }
                    else if(
dist <= 300)
                    {
                        if( (
PlayerGang[i] != INVALID_GANG && PlayerGang[j] != INVALID_GANG && PlayerGang[i] == PlayerGang[j]) ||
                            (
PlayerGang[i] == T_LEI && Player[i][GangLevel] > && IsPlayerInRadarVehicle(i)) ||
                            (
VillageData[VILL_PALOMINO][Owner] == PlayerGang[i] && PlayerGang[i] != INVALID_GANG && IsPlayerInAnyVehicle(i)) )
                        {
                    
//        if(GetVehicleModel(GetPlayerVehicleID(i)) != 520)   // nгo aplicavel a hydra
                            
SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x000000EE));
                        }
                        else if(
Player[i][AdvancedRadar] == true && GetPlayerVehicleID(j) != 0)
                        {
                            
SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x000000EE));
                        }
                        else
                        {
                            
SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000001));
                        }
                    }
                    else if(
dist <= 400SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x000000AA));
                    else if(
dist <= 500SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000099));
                    else if(
dist <= 600SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000088));
                    else if(
dist <= 700SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000077));
                    else if(
dist <= 800SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000066));
                    else if(
dist <= 900SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000055));
                    else if(
dist <= 1000SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000044));
                    else if(
dist <= 1200SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000033));
                    else if(
dist <= 1400SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000022));
                    else if(
dist <= 1600SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000011));
                    else if(
dist <= 2000SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000011));
                    else 
SetPlayerMarkerForPlayer(ij, ((GetPlayerColor(j) & 0xFFFFFF00) | 0x00000011));
                    if(
GetPlayerInterior(i) != GetPlayerInterior(j)) SetPlayerMarkerForPlayer(ij, (GetPlayerColor(j) & 0xFFFFFF00));
                }
            }
        }
    }

- Isto Aumenta Leg Correto? й atualizado por Timer. a Cada Segundo ele Faz Loop. +Leg?
Reply
#2

Isso irб variar diretamente ao sistema que vocк irб fazer, se for publics sem playerid, й utilizado SetTimer, e se for com playerid, й utilizado SetTimerEx, o que dб lag realmente й muito settimer desnecessбrio.
Reply
#3

vlw..

Mais Ainda Estou Com Duvidas. Da Mto Crash.
Reply
#4

Quote:
Originally Posted by _SysTeM_OFF
Посмотреть сообщение
vlw..

Mais Ainda Estou Com Duvidas. Da Mto Crash.
Acho que o amigo acima deu a explicaзгo errada..


Porque dentro do loop й utilizadas muitas funзхes e cбlculos em um curto perнodo de tempo(sim algumas demoram para ser executadas de acordo com o ping/ms do player). Ainda mais quando й usado SetTimer com tempo curto que pode acarretar a crashs inesperados.

Esses crashs acontecem quando o looping nгo consegue executar as funзхes dentro do escopo a tempo de o timer chamar a funзгo novamente..

O Correto й retirar esta callback ou calcular o tempo de demora hб ser executada e criar um SetTimer Baseado nisto..
Reply
#5

Entгo Garfield voce me recomenda usar um SetTimerEx Para o PLayer ??

Ignore o Sistema de Radar Ali. Ja Retirei esta Hipotese.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)