SA-MP Forums Archive
[Ajuda] Verificar se nome da string existe. - 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] Verificar se nome da string existe. (/showthread.php?tid=576902)



Verificar se nome da string existe. - Duk - 07.06.2015

Pessoal to querendo verificar se o nome da string existe

exemplo:

Conta 1 nгo existe dai vai criar um nome dentro do arquivo do ip com o nome da conta
exemplo: Conta1: DanielPicaGrossa.
Se caso existir o nome dentro do arquivo irб criar outro nome dentro do arquivo tipo
Conta2: DanielRolaGostosa e assim por diante mais nгo consigo

To registrando quantas contas o jogador criou no mesmo IP

pawn Код:
new STG[64], PegarIP[16];
    GetPlayerIp(playerid, PegarIP, 16);
    format(STG, 64, "InfoJogadores/IPs/%s.ini", PegarIP);

    if(!DOF2_FileExists(STG))
    {
        DOF2_CreateFile(STG);
        DOF2_SetString(STG, "Conta", Nome_Conta(playerid));
        DOF2_SaveFile();
    }
    else if(!DOF2_FileExists(DOF2_GetString(String, "Conta1")))
    {
        DOF2_SetString(STG, "Conta1", Nome_Conta(playerid));
        DOF2_SaveFile();       
    }
    else if(!DOF2_FileExists(DOF2_GetString(String, "Conta2")))
    {
        DOF2_SetString(STG, "Conta2", Nome_Conta(playerid));
        DOF2_SaveFile();       
    }
    else if(!DOF2_FileExists(DOF2_GetString(String, "Conta3")))
    {
        DOF2_SetString(STG, "Conta3", Nome_Conta(playerid));
        DOF2_SaveFile();       
    }

Eu fis esse codigo mais tipo quando eu crio uma nova conta no mesmo IP
Nгo aparece o nome Conta1 ou conta 2 dentro do arquivo ini do ip.


Re: Verificar se nome da string existe. - ipsLuan - 07.06.2015

Use a nativa do SA-MP.
https://sampwiki.blast.hk/wiki/File_Functions.


Re: Verificar se nome da string existe. - Duk - 07.06.2015

Quote:
Originally Posted by ipsLuan
Посмотреть сообщение
Cara, nem sei como usar isso.

quero usar com dof2


Re: Verificar se nome da string existe. - ipsLuan - 07.06.2015

Os exemplos estгo lб.
Com DOF2 vai ser um pouco mais complicado...


Re: Verificar se nome da string existe. - Duk - 07.06.2015

Quote:
Originally Posted by ipsLuan
Посмотреть сообщение
Os exemplos estгo lб.
Com DOF2 vai ser um pouco mais complicado...
Faz uma base pra min de acordo com meu code?


Re: Verificar se nome da string existe. - Duk - 07.06.2015

Fiz deste jeito aqui mais sу salva a Conta e a conta 1, eu queria acrescentar a conta2, conta 3 dentro do arquivo do ip.

pawn Код:
new STG[64], PegarIP[16];
    GetPlayerIp(playerid, PegarIP, 16);
    format(STG, 64, "InfoJogadores/IPs/%s.ini", PegarIP);

    if(!DOF2_FileExists(STG))
    {
        DOF2_CreateFile(STG);
        DOF2_SetString(STG, "Conta", Nome_Conta(playerid));
        DOF2_SaveFile();
    }
    else
    {
        DOF2_SetString(STG, "Conta1", Nome_Conta(playerid));
        DOF2_SaveFile();       
    }



Re: Verificar se nome da string existe. - ipsLuan - 07.06.2015

Jб falei nй...
Quote:
Originally Posted by ipsLuan
Посмотреть сообщение



Re: Verificar se nome da string existe. - Duk - 07.06.2015

Quote:
Originally Posted by ipsLuan
Посмотреть сообщение
Jб falei nй...
Fбcil pra vc que tem conhecimento.


Re: Verificar se nome da string existe. - PT - 07.06.2015

Quote:
Originally Posted by Duk
Посмотреть сообщение
Fбcil pra vc que tem conhecimento.
Se estudares em vez de andares a procura que te faзam o trabalho na mao, tambem se torna simples pra vc.


Re: Verificar se nome da string existe. - Duk - 07.06.2015

Quote:
Originally Posted by PT
Посмотреть сообщение
Se estudares em vez de andares a procura que te faзam o trabalho na mao, tambem se torna simples pra vc.
Fiz deste jeito mais nгo vai cara, nгo funfa. o nome da nova conta nгo aparece no arquivo do ip

pawn Код:
new STG[64], PegarIP[16], string[64];
    new File:Nconta = fopen("InfoJogadores/IPs/%s.ini", io_read);
    GetPlayerIp(playerid, PegarIP, 16);
    format(STG, 64, "InfoJogadores/IPs/%s.ini", PegarIP);
   

    if(!DOF2_FileExists(STG))
    {
        DOF2_CreateFile(STG);
        DOF2_SetString(STG, "Conta", Nome_Conta(playerid));
        DOF2_SaveFile();
    }
    else if(Nconta)
    {
        while(fread(Nconta, string))
        {
            if(strfind(string, "conta1") != -1)
            {
                DOF2_CreateFile(STG);
                DOF2_SetString(STG, "Conta1", Nome_Conta(playerid));
                break;
            }
            else if(strfind(string, "Conta2") != -1)
            {
                DOF2_CreateFile(STG);
                DOF2_SetString(STG, "Conta2", Nome_Conta(playerid));
                break;
            }
                else if(strfind(string, "Conta3") != -1)
            {
                DOF2_CreateFile(STG);
                DOF2_SetString(STG, "Conta3", Nome_Conta(playerid));
                break;
            }                      
        }  
    }