SA-MP Forums Archive
[Ajuda] Comando retornando invбlido - 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] Comando retornando invбlido (/showthread.php?tid=412752)



Comando retornando invбlido - Maklister - 03.02.2013

Enfim, mesmo eu tendo meu nome no arquivo do veнculo como dono, estб retornando que eu nгo tenho set

pawn Код:
CMD:meuset(playerid, params[])
{
    new msg[80];
    new result;
    for(new car = 0; car < MAX_CARROS; car++)
    {
        new string[80];
        format(string,sizeof(string),"Carros/carro%d.ini", car);
        if(strcmp(DOF2_GetString(string,"Dono"), nome(playerid), true) == 0)
        {
            format(msg, sizeof(msg), "» {FFFFFF}Set Modelo: %d  {FF0000}»  {FFFFFF}Set ID: %d", DOF2_GetInt(string, "Modelo"), car);
            SendClientMessage(playerid, VERMELHO_ESCURO, msg);
            PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
            DOF2_SaveFile();
            result = 1;
            return 1;
        }
        if(result == 0)
        {
            SendClientMessage(playerid, VERMELHO_ESCURO, "[ x ] Vocк nгo possui nenhum set.");
            return 1;
        }
    }
    return 1;
}



Re: Comando retornando invбlido - DrAke$ - 03.02.2013

Retire o return em baixo das funзхes e teste.


Re: Comando retornando invбlido - Maklister - 03.02.2013

se eu tirar fica flodando a msg atй o id 99 ( que й o maximo de veнculo )


Re: Comando retornando invбlido - ForT - 03.02.2013

pawn Код:
if(result == 0)
        {
            SendClientMessage(playerid, VERMELHO_ESCURO, "[ x ] Vocк nгo possui nenhum set.");
            return 1;
        }
Esta parte deve ficar fora do loop.


Re: Comando retornando invбlido - Dwayne-Pheonix - 03.02.2013

pawn Код:
CMD:meuset(playerid, params[]) {
    new bool:result = false;
    for(new car = 0; car < MAX_CARROS; car++) {
        new string[80]; format(string,sizeof(string),"Carros/carro%d.ini", car);
        if(!strcmp(DOF2_GetString(string,"Dono"), nome(playerid), true)) {
            new msg[80]; format(msg, sizeof(msg), "» {FFFFFF}Set Modelo: %d  {FF0000}»  {FFFFFF}Set ID: %d", DOF2_GetInt(string, "Modelo"), car);
            SendClientMessage(playerid, VERMELHO_ESCURO, msg);
            PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
            DOF2_SaveFile();
            result = true;
            break;
        }
    }
    if(result == false) return SendClientMessage(playerid, VERMELHO_ESCURO, "[ x ] Vocк nгo possui nenhum set.");
    return 1;
}
Teste se irб funcionar

OFF: Qual o motivo do uso de DOF2_SaveFile();


Re: Comando retornando invбlido - Maklister - 03.02.2013

Quote:
Originally Posted by Dwayne-Pheonix
Посмотреть сообщение
pawn Код:
CMD:meuset(playerid, params[]) {
    new bool:result = false;
    for(new car = 0; car < MAX_CARROS; car++) {
        new string[80]; format(string,sizeof(string),"Carros/carro%d.ini", car);
        if(!strcmp(DOF2_GetString(string,"Dono"), nome(playerid), true)) {
            new msg[80]; format(msg, sizeof(msg), "» {FFFFFF}Set Modelo: %d  {FF0000}»  {FFFFFF}Set ID: %d", DOF2_GetInt(string, "Modelo"), car);
            SendClientMessage(playerid, VERMELHO_ESCURO, msg);
            PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
            DOF2_SaveFile();
            result = true;
            break;
        }
    }
    if(result == false) return SendClientMessage(playerid, VERMELHO_ESCURO, "[ x ] Vocк nгo possui nenhum set.");
    return 1;
}
Teste se irб funcionar

OFF: Qual o motivo do uso de DOF2_SaveFile();
Smp que uso as funзхes do DOF2 no final coloco DOF2_SaveFile(); :P

Assim, estб returnando apenas o Set ID 0 logo apуs dando o break, no caso se eu tiver mais de um set nгo ira retornar.


Re: Comando retornando invбlido - DrAke$ - 03.02.2013

Vejo que a loop estб buscando arquivos inexistentes:

pawn Код:
CMD:meuset(playerid, params[]){
    new bool:result = false;
    for(new car = 0; car < MAX_CARROS; car++){
        new string[80];
        format(string,sizeof(string),"Carros/carro%d.ini", car);
        if(strcmp(DOF2_GetString(string,"Dono"), nome(playerid), true) == 0){
            new msg[80]; format(msg, sizeof(msg), "» {FFFFFF}Set Modelo: %d  {FF0000}»  {FFFFFF}Set ID: %d", DOF2_GetInt(string, "Modelo"), car);
            SendClientMessage(playerid, VERMELHO_ESCURO, msg);
            PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
            result = true;
        }
    }
    if(result == false){
        SendClientMessage(playerid, VERMELHO_ESCURO, "[ x ] Vocк nгo possui nenhum set.");
    }
    return 1;
}



Re: Comando retornando invбlido - Maklister - 03.02.2013

Quote:
Originally Posted by DrAke$
Посмотреть сообщение
Vejo que a loop estб buscando arquivos inexistentes:

pawn Код:
CMD:meuset(playerid, params[]){
    new bool:result = false;
    for(new car = 0; car < MAX_CARROS; car++){
        new string[80];
        format(string,sizeof(string),"Carros/carro%d.ini", car);
        if(strcmp(DOF2_GetString(string,"Dono"), nome(playerid), true) == 0){
            new msg[80]; format(msg, sizeof(msg), "» {FFFFFF}Set Modelo: %d  {FF0000}»  {FFFFFF}Set ID: %d", DOF2_GetInt(string, "Modelo"), car);
            SendClientMessage(playerid, VERMELHO_ESCURO, msg);
            PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
            result = true;
        }
    }
    if(result == false){
        SendClientMessage(playerid, VERMELHO_ESCURO, "[ x ] Vocк nгo possui nenhum set.");
    }
    return 1;
}
Na verdade pensando aqui, falto apenas um
pawn Код:
DOF2_FileExists
Pois assim estava returnando do 0 ao 99 mesmo nгo tendo o arquivo criado e buscando neles mesmo assim,

Mesmo assim obrigado ai manolos


Re: Comando retornando invбlido - zSuYaNw - 03.02.2013

pawn Код:
CMD:meuset(playerid){
   
    static
        string[128],
        bool: Achou,
        Interador
    ;
   
   
    string[0] = '\0';
    Achou     = false;
    Interador = 0;
   
   
    for( ; Interador != MAX_CARROS; ++Interador){
   
        format(string, 128, "Carros/carro%d.ini", Interador);
       
        if(fexist(string)){
               
             if(!strcmp(DOF2_GetString(string,"Dono"), nome(playerid), true)){
             
                format(string, sizeof(string), "» {FFFFFF}Set Modelo: %d  {FF0000}»  {FFFFFF}Set ID: %d", DOF2_GetInt(string, "Modelo"), Interador);
                SendClientMessage(playerid, VERMELHO_ESCURO, string);
                PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
             
                Achou = true;
             }
       
        }
    }
   
   
    if(!Achou){
        return SendClientMessage(playerid, VERMELHO_ESCURO, "[ x ] Vocк nгo possui nenhum set."),0;
    }

    return true;
}



Re: Comando retornando invбlido - @LucasVinicius - 03.02.2013

@OFF TOPIC: string[0] = '\0'; quer dizer que й o final da string ?