SA-MP Forums Archive
[Ajuda] - 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] (/showthread.php?tid=254148)



[Ajuda] - Carl_Thuse - 09.05.2011

Olб,
Bom queria saber se tem soluзгo pra alguns problemas que ando tendo aqui.
Comando [/Radio] (Nгo й RP/RPG, nгo liguem pro comando, sу tentem achar algum erro)
pawn Код:
if (strcmp("/radio", cmdtext, true, 10) == 0 || strcmp("/r", cmdtext, true, 10) == 0)
    {
        if(TemRadio[playerid] == 1 && PlayerInfo[playerid][pClass] > 1)
        {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_GRAD, "USE: (/R)adio [texto]");
                return 1;
            }
            format(string, sizeof(string), "Admin %s: %s", sendername, result);
            SendRadioMessage(0xFF6400FF,string);
        }
        return 1;
    }
Quando o player digita o comando, sai USE: (/R)..
Mas quando ele digita algo (/R eita!)
Fala Comando Invalido. Acho que й algum problema com a strlen. Alguem sabe??
************************************************** ***************
Outro problema que ando tendo й com Registro.
Bom galera, passei muito tempo procurando algum exemplo, porem nгo achei um.
Fiz um Dialog Para se registrarem com FIni, mas nгo dб certo!
Nгo cria o arquivo com o nome da pessoa. Comando:
pawn Код:
//OnDialogResponse..
if(dialogid==DIALOG_REGISTER) {
        if(response) {
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT, "Registrar","Digite uma senha para obter um registro\n ( Digite uma senha vбlida por favor ):","Confirmar","Sair");
            Logado[playerid]=true;
            dini_Create(ReturnFileUser(playerid));
            dini_Set(ReturnFileUser(playerid),"Senha",inputtext);
// Deletei variaveis para n ficar muito grande.
        }
        else {
            new pName[MAX_PLAYER_NAME],lString[256];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(lString,256," Vocк foi kickado por nгo se registrar.",pName,playerid);
            SendClientMessage(playerid,COLOR_GRAD,lString);
            Kick(playerid);
        }
        return 1;
    }
Peguei este com dini para ver se o problema era com a FINI, mas mesmo assim continua nгo
criando o .txt com a conta da pessoa ._. Algum milagreiro ai tem a resposta??


Re: [Ajuda] - Josma_cmd - 09.05.2011

Seu erro pode ter cido na linha do comando, colocou cmdtext pra um comando um pouco mais complexo onde o recomendбvel й usar cmd.
pawn Код:
if(strcmp(cmd, "/radio", true) == 0 || strcmp(cmd, "/r", true) == 0)
    {
        if(TemRadio[playerid] == 1 && PlayerInfo[playerid][pClass] > 1)
        {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result)) return SendClientMessage(playerid, COLOR_GRAD, "USE: (/R)adio [texto]");
            format(string, sizeof(string), "Admin %s: %s", sendername, result);
            SendRadioMessage(0xFF6400FF,string);
        }
        return 1;
    }



Re: [Ajuda] - Carl_Thuse - 09.05.2011

Muitissimo Grato Josma, Mas nгo vi o erro! Poderia me mostrar para que eu saiba arruma-lo sozinho?
Grato


Re: [Ajuda] - Josma_cmd - 09.05.2011

pawn Код:
if (strcmp("/radio", cmdtext, true, 10) == 0 || strcmp("/r", cmdtext, true, 10) == 0) //para comandos simples
if(strcmp(cmd, "/radio", true) == 0 || strcmp(cmd, "/r", true) == 0) //Para comandos complexos
Sobre o sistema de registro, tб faltando coisas ai no cуdigo que mandou.

tipo:
pawn Код:
if(!dini_Exists(arquivo))
    {
        new pNome[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pNome, sizeof(pNome));
        format(arquivo, sizeof(arquivo), "%s.ini",pNome);
        dini_Create(arquivo);
    }
Outra coisa: Fini salva em .txt Dini salva em .ini se nгo me engano.


Re: [Ajuda] - Carl_Thuse - 09.05.2011

Pois este nгo й o erro '-'
Olhe:
pawn Код:
#define FileUsers      "%s.txt"
stock ReturnFileUser(playerid)
{
    new File[256],Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,Name,sizeof(Name));
    format(File,sizeof(File),FileUsers,Name);
    return File;
}
Onde estб o ReturnFileUser no dialog lб, й isto que me falou.


Re: [Ajuda] - Josma_cmd - 09.05.2011

pawn Код:
#define FileUsers      "%s.txt"
dini salva em .ini
pawn Код:
#define FileUsers      "%s.ini"



Re: [Ajuda] - Carl_Thuse - 09.05.2011

Pois continua '-'

Queria lhe perguntar outra coisa.
Tem como eu fazer um randomico para Max_players?
Exemplo, de todos os players conectados, eu selecione 2 ou 3 randomicos?
Obg


Re: [Ajuda] - Macintosh - 09.05.2011

O erro estava aqui no result, deveria ser tmp ou algo do tipo. define no topo do OnPlayerCommandText new tmp[256];


pawn Код:
if (strcmp("/radio", cmdtext, true, 10) == 0 || strcmp("/r", cmdtext, true, 10) == 0)
    {
        if(TemRadio[playerid] == 1 && PlayerInfo[playerid][pClass] > 1)
        {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(tmp)) // O erro estava aqui no result, deveria ser tmp ou algo do tipo. define no topo do OnPlayerCommandText new tmp[256];
            {
                SendClientMessage(playerid, COLOR_GRAD, "USE: (/R)adio [texto]");
                return 1;
            }
            format(string, sizeof(string), "Admin %s: %s", sendername, result);
            SendRadioMessage(0xFF6400FF,string);
        }
        return 1;
    }



Re: [Ajuda] - Carl_Thuse - 09.05.2011

Obrigado Shick jб entendi.
Quote:

Queria lhe perguntar outra coisa.
Tem como eu fazer um randomico para Max_players?
Exemplo, de todos os players conectados, eu selecione 2 ou 3 randomicos?
Obg

Sabe algo?


Re: [Ajuda] - Macintosh - 09.05.2011

Tem sim, O que deseja fazer? Poderб ser de outra forma tambйm (: