Portal SAMP
[Ajuda] Não aparece o valor correto no anuncio - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] Não aparece o valor correto no anuncio (/showthread.php?tid=2469)

Páginas: 1 2


Não aparece o valor correto no anuncio - jnXX - 11/06/2022

Sempre que eu coloco um anúncio de Coins no servidor ele sempre ta aparecendo que estou vendendo 0 moedas e um preço aleatorio.

Código:
    if(dialogid == 598)
    {
        if(!response)
        {
            return 1;
        }
        if(listitem == 0)
        {
            new lol = 1;
            MEGAString[0]=EOS;
            format(string, sizeof(string), "Vendedor\tStatus\tMoedas\tPreço\n");
            strcat(MEGAString, string);
            while (lol < MAX_PLAYERS)
            {
                 new arquivo[64];
                format(arquivo, sizeof(arquivo), Pasta_Anuncio,lol);
                if(DOF2_FileExists(arquivo))
                {
                    new NomeAnuncio[MAX_PLAYER_NAME];
                    new CoinsAnuncio;
                    new PrecoCoins;
                    strmid(NomeAnuncio, DOF2_GetString(arquivo,"Jogador"), 0, strlen(DOF2_GetString(arquivo,"Jogador")), 255);
                    DOF2_CreateFile(arquivo);
                    CoinsAnuncio = DOF2_GetInt(arquivo, "Moedas");
                    PrecoCoins = DOF2_GetInt(arquivo, "Preco");
                    format(string, sizeof(string), "» %s\t%s\t{33ff00}£{FFFFFF}%d\t{33ff00}R${FFFFFF}%d\n", NomeAnuncio,getOnline(NomeAnuncio), CoinsAnuncio, ConvertMoney(PrecoCoins));
                    strcat(MEGAString, string);
                }
                lol++;
            }
            ShowPlayerDialog(playerid, 567, DIALOG_STYLE_TABLIST_HEADERS, "» Anúncio De Moedas", MEGAString, "Comprar","Voltar");
            return 1;
        }



RE: Não aparece o valor correto no anuncio - iAplle - 11/06/2022

Tenta assim:

Código:
if(dialogid == 598)
    {
        if(!response)
        {
            return 1;
        }
        if(listitem == 0)
        {
            new lol = 1;
            MEGAString[0]=EOS;
            format(string, sizeof(string), "Vendedor\tStatus\tMoedas\tPreço\n");
            strcat(MEGAString, string);
            while (lol < MAX_PLAYERS)
            {
                 new arquivo[64];
                format(arquivo, sizeof(arquivo), Pasta_Anuncio,lol);
                if(DOF2_FileExists(arquivo))
                {
                    new NomeAnuncio[MAX_PLAYER_NAME];
                    strmid(NomeAnuncio, DOF2_GetString(arquivo,"Jogador"), 0, strlen(DOF2_GetString(arquivo,"Jogador")), 255);
                    DOF2_CreateFile(arquivo);
                    format(string, sizeof(string), "» %s\t%s\t{33ff00}£{FFFFFF}%d\t{33ff00}R${FFFFFF}%s\n", NomeAnuncio,getOnline(NomeAnuncio), DOF2_GetInt(arquivo, "Moedas"), ConvertMoney(DOF2_GetInt(arquivo, "Preco")));
                    strcat(MEGAString, string);
                }
                lol++;
            }
            ShowPlayerDialog(playerid, 567, DIALOG_STYLE_TABLIST_HEADERS, "» Anúncio De Moedas", MEGAString, "Comprar","Voltar");
            return 1;
        }



RE: Não aparece o valor correto no anuncio - jnXX - 11/06/2022

Continua do mesmo jeito :/


RE: Não aparece o valor correto no anuncio - k2bi_YT - 11/06/2022

Faz assim
Recomendo que mande o codigo de quando o jogador cria o anuncio (comando ou sla), pela leitura do codigo, será pego a informação já existente de anuncio, se não existe anuncio, não existe exibição.
Código PHP:
if(dialogid == 598)
{
    if(!
response) return true;
    if(
listitem == 0)
    {
        new 
lol 1file[64], temanuncio;
        new 
NomeAnuncio[MAX_PLAYER_NAME];
        new 
CoinsAnuncio;
        new 
PrecoCoins;
        
MEGAString[0]=EOS;
        
strcat(MEGAString"Vendedor\tStatus\tMoedas\tPreço\n");;
        while (
lol MAX_PLAYERS)
        {
            
format(filesizeof(file), Pasta_Anuncio,lol);
            if(!
DOF2_FileExists(file)) continue;
            
format(NomeAnuncioMAX_PLAYER_NAMEDOF2_GetString(file"Jogador"));
            
CoinsAnuncio DOF2_GetInt(arquivo"Moedas");
            
PrecoCoins DOF2_GetInt(arquivo"Preco");
            
format(stringsizeof(string), "» %s\t%s\t{33ff00}£{FFFFFF}%d\t{33ff00}R${FFFFFF}%d\n"NomeAnuncio,getOnline(NomeAnuncio), CoinsAnuncioConvertMoney(PrecoCoins));
            
strcat(MEGAStringstring);
            
temanuncio 1;
            
lol++;
        }
        if(!
temanuncio) return SendClientMessage(playerid, -1"Não há nenhum anúncio para ser exibido.");
        
ShowPlayerDialog(playerid567DIALOG_STYLE_TABLIST_HEADERS"» Anúncio De Moedas"MEGAString"Comprar","Voltar");
        return 
1;
    }




RE: Não aparece o valor correto no anuncio - jnXX - 13/06/2022

(11/06/2022 18:13)k2bi_YT Escreveu: Faz assim
Recomendo que mande o codigo de quando o jogador cria o anuncio (comando ou sla), pela leitura do codigo, será pego a informação já existente de anuncio, se não existe anuncio, não existe exibição.
Código PHP:
if(dialogid == 598)
{
    if(!response) return true;
    if(listitem == 0)
    {
        new lol 1file[64], temanuncio;
        new NomeAnuncio[MAX_PLAYER_NAME];
        new CoinsAnuncio;
        new PrecoCoins;
        MEGAString[0]=EOS;
        strcat(MEGAString"Vendedor\tStatus\tMoedas\tPreço\n");;
        while (lol MAX_PLAYERS)
        {
            format(filesizeof(file), Pasta_Anuncio,lol);
            if(!DOF2_FileExists(file)) continue;
            format(NomeAnuncioMAX_PLAYER_NAMEDOF2_GetString(file"Jogador"));
            CoinsAnuncio DOF2_GetInt(arquivo"Moedas");
            PrecoCoins DOF2_GetInt(arquivo"Preco");
            format(stringsizeof(string), "» %s\t%s\t{33ff00}£{FFFFFF}%d\t{33ff00}R${FFFFFF}%d\n"NomeAnuncio,getOnline(NomeAnuncio), CoinsAnuncioConvertMoney(PrecoCoins));
            strcat(MEGAStringstring);
            temanuncio 1;
            lol++;
        }
        if(!temanuncio) return SendClientMessage(playerid, -1"Não há nenhum anúncio para ser exibido.");
        ShowPlayerDialog(playerid567DIALOG_STYLE_TABLIST_HEADERS"» Anúncio De Moedas"MEGAString"Comprar","Voltar");
        return 1;
    }

Deu 26 erros kkk


RE: Não aparece o valor correto no anuncio - xbruno1000x - 13/06/2022

(13/06/2022 15:01)jnXX Escreveu:
(11/06/2022 18:13)k2bi_YT Escreveu: Faz assim
Recomendo que mande o codigo de quando o jogador cria o anuncio (comando ou sla), pela leitura do codigo, será pego a informação já existente de anuncio, se não existe anuncio, não existe exibição.
Código PHP:
if(dialogid == 598)
{
    if(!response) return true;
    if(listitem == 0)
    {
        new lol 1file[64], temanuncio;
        new NomeAnuncio[MAX_PLAYER_NAME];
        new CoinsAnuncio;
        new PrecoCoins;
        MEGAString[0]=EOS;
        strcat(MEGAString"Vendedor\tStatus\tMoedas\tPreço\n");;
        while (lol MAX_PLAYERS)
        {
            format(filesizeof(file), Pasta_Anuncio,lol);
            if(!DOF2_FileExists(file)) continue;
            format(NomeAnuncioMAX_PLAYER_NAMEDOF2_GetString(file"Jogador"));
            CoinsAnuncio DOF2_GetInt(arquivo"Moedas");
            PrecoCoins DOF2_GetInt(arquivo"Preco");
            format(stringsizeof(string), "» %s\t%s\t{33ff00}£{FFFFFF}%d\t{33ff00}R${FFFFFF}%d\n"NomeAnuncio,getOnline(NomeAnuncio), CoinsAnuncioConvertMoney(PrecoCoins));
            strcat(MEGAStringstring);
            temanuncio 1;
            lol++;
        }
        if(!temanuncio) return SendClientMessage(playerid, -1"Não há nenhum anúncio para ser exibido.");
        ShowPlayerDialog(playerid567DIALOG_STYLE_TABLIST_HEADERS"» Anúncio De Moedas"MEGAString"Comprar","Voltar");
        return 1;
    }

Deu 26 erros kkk

Tem um erro de sintaxe no trecho abaixo:
Código:
strcat(MEGAString, "Vendedor\tStatus\tMoedas\tPreço\n");;
Tem um ; a mais. Tente sem ele.


RE: Não aparece o valor correto no anuncio - jnXX - 13/06/2022

error 017: undefined symbol "arquivo" CoinsAnuncio = DOF2_GetInt(arquivo, "Moedas");
error 017: undefined symbol "arquivo" PrecoCoins = DOF2_GetInt(arquivo, "Preco");
loose indentation

deu esses erros


RE: Não aparece o valor correto no anuncio - xbruno1000x - 14/06/2022

(13/06/2022 16:25)jnXX Escreveu: error 017: undefined symbol "arquivo"  CoinsAnuncio = DOF2_GetInt(arquivo, "Moedas");
error 017: undefined symbol "arquivo"  PrecoCoins = DOF2_GetInt(arquivo, "Preco");
loose indentation

deu esses erros

Alguém aqui do tópico renomeou de 'arquivo' para 'file'

Altere o 'arquivo,' para 'file,'
Código:
            CoinsAnuncio = DOF2_GetInt(arquivo, "Moedas");
            PrecoCoins = DOF2_GetInt(arquivo, "Preco");



RE: Não aparece o valor correto no anuncio - jnXX - 14/06/2022

Consegui deixar sem erros mas agora quando aparece a dialog pra mim ele e aperto em Ver Anuncios, ele não mostra a dialog e o servidor fica "congelado" e não consigo fazer mais nada no servidor após isso.


RE: Não aparece o valor correto no anuncio - Maycon_Felipe - 14/06/2022

Seguinte, usar while sem saber é paia..
Basicamente por você está usando "continue;", ele não tá incrementando a variável "lol", e tá entrando em loop infinito.

Altera para isso:
Código PHP:
    while (lol MAX_PLAYERS)
    {
        format(filesizeof(file), Pasta_Anuncio,lol);
        if(DOF2_FileExists(file))
        {
            format(NomeAnuncioMAX_PLAYER_NAMEDOF2_GetString(file"Jogador"));
            CoinsAnuncio DOF2_GetInt(arquivo"Moedas");
            PrecoCoins DOF2_GetInt(arquivo"Preco");
            format(stringsizeof(string), "» %s\t%s\t{33ff00}£{FFFFFF}%d\t{33ff00}R${FFFFFF}%d\n"NomeAnuncio,getOnline(NomeAnuncio), CoinsAnuncioConvertMoney(PrecoCoins));
            strcat(MEGAStringstring);
            temanuncio 1;
        }
        lol++;