SA-MP Forums Archive
[Ajuda] Label Nгo carrega - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Label Nгo carrega (/showthread.php?tid=424892)



Label Nгo carrega - dPlaYer_ - 24.03.2013

Boa noite, estou com um problema com 3dText,

Criei um sistema que ele checa os "Labels" do servidor emcima da cabeзa dos jogadores.
se estб afk, ou nгo se й admin ou moderador, ou a profissгo do jogador.

usei a funзгo CheckLabels no OnPlayerUpdate ( Atualiza a cada 1 segundo )

Sу que o problema й que nгo estб atualizando nem criando o label encima do jogador.

No GameModeInit tambem tem o
pawn Код:
SetTimer("CheckLabels", 1000, true);
Cуdigo:

pawn Код:
FC:CheckLabels()
{
    for (new p = 0; p < GetMaxPlayers(); p++)
    {
        if(pInfo[p][dAfk] == false)
        {
            switch(pInfo[p][dLAdmin])
            {
                case 0:
                {
                    format(sGlobal, sizeof(sGlobal), "%s", gProfName(p));
                    pInfo[p][LabelAdmin] = Create3DTextLabel(sGlobal, COR_LARANJA2, 0.0, 0.0, 0.0, 15.0, 0, 1);
                    Attach3DTextLabelToPlayer(pInfo[p][LabelAdmin], p, 0.0, 0.0, 0.5);
                }
                case 1:
                {
                    Delete3DTextLabel(pInfo[p][LabelAdmin]);
                    pInfo[p][LabelAdmin] = Create3DTextLabel("* Moderador *", COR_LARANJA2, 0.0, 0.0, 0.0, 15.0, 0, 1);
                    Attach3DTextLabelToPlayer(pInfo[p][LabelAdmin], p, 0.0, 0.0, 0.5);
                }
                case 2:
                {
                    Delete3DTextLabel(pInfo[p][LabelAdmin]);
                    pInfo[p][LabelAdmin] = Create3DTextLabel("* Adminstrador *", COR_LARANJA2, 0.0, 0.0, 0.0, 15.0, 0, 1);
                    Attach3DTextLabelToPlayer(pInfo[p][LabelAdmin], p, 0.0, 0.0, 0.5);
                }
            }
        }
        if(pInfo[p][dAfk] == true)
        {
            Delete3DTextLabel(pInfo[p][LabelAdmin]);
            pInfo[p][AFK_Label] = Create3DTextLabel("* Jogador AFK *", -1, 0.0, 0.0, 0.0, 15.0, 0, 1);
            Attach3DTextLabelToPlayer(pInfo[p][AFK_Label], p, 0.0, 0.0, 0.5);
        }
    }
    return 1;
}
Oque pode ser?


Re: Label Nгo carrega - Maklister - 24.03.2013

Tente

pawn Код:
FC:CheckLabels()
{
    for (new p = 0; p < MAX_PLAYERS; p++)
    {
        if(pInfo[p][dAfk] == false)
        {
            switch(pInfo[p][dLAdmin])
            {
                case 0:
                {
                    format(sGlobal, sizeof(sGlobal), "%s", gProfName(p));
                    CreateDynamic3DTextLabel(sGlobal, COR_LARANJA2, 0.0, 0.0, 0.5, 50.0, pInfo[p][LabelAdmin], INVALID_VEHICLE_ID);
                }
                case 1:
                {
                    CreateDynamic3DTextLabel("*Moderador*", COR_LARANJA2, 0.0, 0.0, 0.5, 50.0, pInfo[p][LabelAdmin], INVALID_VEHICLE_ID);
                }
                case 2:
                {
                    CreateDynamic3DTextLabel("*Moderador*", COR_LARANJA2, 0.0, 0.0, 0.5, 50.0, pInfo[p][LabelAdmin], INVALID_VEHICLE_ID);
                }
            }
        }
        if(pInfo[p][dAfk] == true)
        {
            CreateDynamic3DTextLabel("*AFK*", COR_LARANJA2, 0.0, 0.0, 0.5, 50.0, pInfo[p][LabelAdmin], INVALID_VEHICLE_ID);
        }
    }
    return 1;
}
ou use: Attach3DTextLabelToPlayer


Re: Label Nгo carrega - Crueliz0n - 24.03.2013

nгo deveria ter um if(IsPlayerConnected(p)) depois do loop


Re: Label Nгo carrega - Maklister - 24.03.2013

Quote:
Originally Posted by BlackDonelly
Посмотреть сообщение
nгo deveria ter um if(IsPlayerConnected(p)) depois do loop
nгo й necessбrio apesar de ser bem ъtil na reduзгo de passagem por ID's offlines


Re: Label Nгo carrega - Dwayne-Pheonix - 24.03.2013

Quote:
Originally Posted by Murilo_sousa
Посмотреть сообщение
Tente

pawn Код:
FC:CheckLabels()
{
    for (new p = 0; p < MAX_PLAYERS; p++)
    {
        if(pInfo[p][dAfk] == false)
        {
            switch(pInfo[p][dLAdmin])
            {
                case 0:
                {
                    format(sGlobal, sizeof(sGlobal), "%s", gProfName(p));
                    CreateDynamic3DTextLabel(sGlobal, COR_LARANJA2, 0.0, 0.0, 0.5, 50.0, pInfo[p][LabelAdmin], INVALID_VEHICLE_ID);
                }
                case 1:
                {
                    CreateDynamic3DTextLabel("*Moderador*", COR_LARANJA2, 0.0, 0.0, 0.5, 50.0, pInfo[p][LabelAdmin], INVALID_VEHICLE_ID);
                }
                case 2:
                {
                    CreateDynamic3DTextLabel("*Moderador*", COR_LARANJA2, 0.0, 0.0, 0.5, 50.0, pInfo[p][LabelAdmin], INVALID_VEHICLE_ID);
                }
            }
        }
        if(pInfo[p][dAfk] == true)
        {
            CreateDynamic3DTextLabel("*AFK*", COR_LARANJA2, 0.0, 0.0, 0.5, 50.0, pInfo[p][LabelAdmin], INVALID_VEHICLE_ID);
        }
    }
    return 1;
}
ou use: Attach3DTextLabelToPlayer
Criar um Text3D a cada 1 segundo lol

O modo em que vocк utilizou CreateDynamic3DTextLabel tб errado



Observaзгo "pInfo[playerid][LabelAdmin]" deve estar definido como Text3D, utilizar a include streamer e manter o timer

Exemplo:
pawn Код:
new Text3D:label;
Adicione onde o jogador loga / registra:

pawn Код:
pInfo[playerid][LabelAdmin] = CreateDynamic3DTextLabel("NaN", -1, 0.0, 0.0, 0.0, 50.0, playerid, INVALID_VEHICLE_ID, 0, -1, -1, -1, 50.0);
Destrua o Text3D quando o jogador se desconecta:

pawn Код:
public OnPlayerDisconnect(playerid) {
    if(IsValidDynamic3DTextLabel(pInfo[playerid][LabelAdmin])) DestroyDynamic3DTextLabel(pInfo[playerid][LabelAdmin]);
    return 1;
}
Altere a Callback para:

pawn Код:
CheckLabels(); public CheckLabels() {
    for(new p = 0; p < GetMaxPlayers(); p++) {
        if((IsPlayerConnected(p)) && ([p][dAfk] == false)) {
            switch(pInfo[p][dLAdmin]) {
                case 0: {
                    format(sGlobal, sizeof(sGlobal), "%s", gProfName(p));
                }
                case 1: {
                    format(sGlobal, sizeof(sGlobal), "* Moderador *");
                }
                case 2: {
                    format(sGlobal, sizeof(sGlobal), "* Adminstrador *");
                }
            }
        }
        if(pInfo[p][dAfk] == true) {
            format(sGlobal, sizeof(sGlobal), "* Jogador AFK *");
        }
    }
    if(IsValidDynamic3DTextLabel(pInfo[p][LabelAdmin])) UpdateDynamic3DTextLabelText(pInfo[p][LabelAdmin], COR_LARANJA2, sGlobal);
    return 1;
}
Sirva tudo com a calda de chocolate por cima

* Nгo testei o cуdigo se houver pequenos erros podem ser facilmente contornados


Re: Label Nгo carrega - dPlaYer_ - 24.03.2013

Quote:
Originally Posted by Dwayne-Pheonix
Посмотреть сообщение
Criar um Text3D a cada 1 segundo lol
Nгo obtive resultados com seu cуdigo, apesar de compilar e tudo, ele nгo attacha no player.

pawn Код:
CheckLabels(); public CheckLabels() {
    for(new p = 0; p < GetMaxPlayers(); p++) {
        if((IsPlayerConnected(p)) && (pInfo[p][dAfk] == false)) {
            switch(pInfo[p][dLAdmin]) {
                case 0: {
                    format(sGlobal, sizeof(sGlobal), "%s", gProfName(p));
                }
                case 1: {
                    format(sGlobal, sizeof(sGlobal), "* Moderador *");
                }
                case 2: {
                    format(sGlobal, sizeof(sGlobal), "* Adminstrador *");
                }
            }
        }
        if(pInfo[p][dAfk] == true) {
            format(sGlobal, sizeof(sGlobal), "* Jogador AFK *");
        }
        if(IsValidDynamic3DTextLabel(pInfo[p][LabelTodos])) UpdateDynamic3DTextLabelText(pInfo[p][LabelTodos], COR_LARANJA2, sGlobal);
    }
    return 1;
}



Re: Label Nгo carrega - Crueliz0n - 24.03.2013

tente dessa forma:

pawn Код:
public OnPlayerConnect(playerid)
{
    pInfo[p][LabelAdmin] = Create3DTextLabel(sGlobal, COR_LARANJA2, 0.0, 0.0, 0.0, 15.0, 0, 1);
    Attach3DTextLabelToPlayer(pInfo[p][LabelAdmin], playerid, 0.0, 0.0, 0.5);
    return 1;
}  

public OnPlayerDisconnect(playerid)
{
    Delete3DTextLabel(pInfo[playerid][LabelAdmin]);
    return 1;
   
}

FC:CheckLabels()
{
    for (new p = 0; p < GetMaxPlayers(); p++)
    {
        if(pInfo[p][dAfk] == false)
        {
            if(IsPlayerConnected(p))
            {
                switch(pInfo[p][dLAdmin])
                {
                    case 0:
                    {
                        format(sGlobal,sizeof sGlobal,"%s",gProfName(p));
                        Update3DTextLabelText(pInfo[p][LabelAdmin],0x37FF00FF,sGlobal);
                    }
                    case 1:
                    {
                        Update3DTextLabelText(pInfo[p][LabelAdmin],0x37FF00FF,"* Moderador *");
                    }
                    case 2:
                    {
                        Update3DTextLabelText(pInfo[p][LabelAdmin],0x37FF00FF,"* Adminstrador *");
                    }
                }
            }  
        }
        if(pInfo[p][dAfk] == true)
        {
            Update3DTextLabelText(pInfo[p][LabelAdmin],0x37FF00FF,"* Jogador AFK *");
        }
    }
    return 1;
}



Re: Label Nгo carrega - dPlaYer_ - 25.03.2013

Quote:
Originally Posted by BlackDonelly
Посмотреть сообщение
tente dessa forma:

pawn Код:
public OnPlayerConnect(playerid)
{
    pInfo[p][LabelAdmin] = Create3DTextLabel(sGlobal, COR_LARANJA2, 0.0, 0.0, 0.0, 15.0, 0, 1);
    Attach3DTextLabelToPlayer(pInfo[p][LabelAdmin], playerid, 0.0, 0.0, 0.5);
    return 1;
}  

public OnPlayerDisconnect(playerid)
{
    Delete3DTextLabel(pInfo[playerid][LabelAdmin]);
    return 1;
   
}

FC:CheckLabels()
{
    for (new p = 0; p < GetMaxPlayers(); p++)
    {
        if(pInfo[p][dAfk] == false)
        {
            if(IsPlayerConnected(p))
            {
                switch(pInfo[p][dLAdmin])
                {
                    case 0:
                    {
                        format(sGlobal,sizeof sGlobal,"%s",gProfName(p));
                        Update3DTextLabelText(pInfo[p][LabelAdmin],0x37FF00FF,sGlobal);
                    }
                    case 1:
                    {
                        Update3DTextLabelText(pInfo[p][LabelAdmin],0x37FF00FF,"* Moderador *");
                    }
                    case 2:
                    {
                        Update3DTextLabelText(pInfo[p][LabelAdmin],0x37FF00FF,"* Adminstrador *");
                    }
                }
            }  
        }
        if(pInfo[p][dAfk] == true)
        {
            Update3DTextLabelText(pInfo[p][LabelAdmin],0x37FF00FF,"* Jogador AFK *");
        }
    }
    return 1;
}
Thanks Man.

+rep for all