[AJUDA]Sistema de Login com um probleminha...
#1

pawn Код:
#include <DOF2>

#define DIALOG_REGISTER 2011
#define DIALOG_LOGIN 2012

enum pInfo
{
    pKills,
    pDeaths,
    pAdmin
}
new PlayerInfo[MAX_PLAYERS][pInfo];



public OnFilterScriptExit()
{
    DOF2_Exit();
    return 1;
}

public OnPlayerConnect(playerid)
{
    new file[64];
    GetPlayerName(playerid,file,sizeof(file));
    format(file,sizeof(file),DOF2_File(file));
    if(DOF2_FileExists(file))
    {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Bem Vindo!","{FFFFFF}Digite sua senha {FFFFFF}abaixo para logar.","Logar","Sair");
       
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Bem Vindo pela primeira vez","{FFFFFF}Digite sua senha {FFFFFF}abaixo para se Registrar.","Registrar","Sair");


    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(!response) Kick(playerid);
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Bem Vindo pela primeira vez..","{FFFFFF}Digite sua senha {FFFFFF}abaixo para se Registrar","Registrar","Sair");
            if(response)
            {
                new file[64];
                GetPlayerName(playerid,file,sizeof(file));
                format(file,sizeof(file),DOF2_File(file));
                DOF2_CreateFile(file, inputtext);
                DOF2_SetInt(file, "Kills", 0);
                DOF2_SetInt(file, "Deaths", 0);
                DOF2_SetInt(file, "AdminLevel", 0);
                DOF2_SaveFile();
                SendClientMessage(playerid, 0x33FF00FF, "Registrado com sucesso!");
                PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
                SpawnPlayer(playerid);
            }
        }
        case DIALOG_LOGIN:
        {
            if(!response) Kick(playerid);
            if(response)
            {
                new file[64];
                GetPlayerName(playerid,file,sizeof(file));
                format(file,sizeof(file),DOF2_File(file));
                if(DOF2_FileExists(file))
                {
                    if(DOF2_CheckLogin(file,inputtext))
                    {
                        PlayerInfo[playerid][pKills] = DOF2_GetInt(file,"Kills");
                        PlayerInfo[playerid][pDeaths] = DOF2_GetInt(file,"Deaths");
                        PlayerInfo[playerid][pAdmin] = DOF2_GetInt(file,"AdminLevel");
                        SpawnPlayer(playerid);
                        SendClientMessage(playerid, 0x33FF00FF, "Logado com sucesso!");
                        PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
                        return 1;
                    }
                    else
                    {

                        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"{F81414}Senha invбlida!","{FFFFFF}Digite sua {F81414}senha corretamente{FFFFFF} abaixo.","Logar","Sair");
                        return 1;
                    }
                }
            }
        }
    }
    return 1;
}



public OnPlayerDisconnect(playerid, reason)
{
    new file[64];
    GetPlayerName(playerid,file,sizeof(file));
    format(file,sizeof(file),DOF2_File(file));
    DOF2_SetInt(file, "Kills",PlayerInfo[playerid][pKills]);
    DOF2_SetInt(file, "Deaths",PlayerInfo[playerid][pDeaths]);
    DOF2_SetInt(file, "AdminLevel",PlayerInfo[playerid][pAdmin]);
    return 1;
}


public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[killerid][pKills]++;
    PlayerInfo[playerid][pDeaths]++;
    return 1;
}
Alguйm sabe me dizer porque quando eu erro a senha e vou corrigila,quando acerto,o player da spawn e o server da closed connection?
Esse sistema nгo foi criado por mim peguei de um tutorial e editei
Reply
#2

Todo errado esse seu sistema, faзa um novo e ganharб mais.
Reply
#3

Foi de um tutorial daqui do SAMP em DOF2
Reply
#4

Olб fojo_,

isso pode estar ocorrendo devido ao bug da versгo 0.3d, utilize SetSpawnInfo antes do player spawnar que o mesmo se corrigi.

Caso queira outro exemplos de login, dк uma conferida aqui: http://pastebin.com/u/falcon


Atenciosamente,
Falcon.
Reply
#5

Quote:

Olб fojo_,

isso pode estar ocorrendo devido ao bug da versгo 0.3d, utilize SetSpawnInfo antes do player spawnar que o mesmo se corrigi.

Caso queira outro exemplos de login, dк uma conferida aqui: http://pastebin.com/u/falcon


Atenciosamente,
Falcon.
____________

Opa,Falcon,obrigado pela ajuda cara,mas nгo deu muito certo ' Acho que a soluзгo й partir pra outra mesmo...jб que nгo sei criar um sistema de Login sozinho,rsrs
Reply
#6

Mano aperta ctrl + f e procure por "Kick(playerid);" Sу apagar e pronto.
Reply
#7

Creio que DOF2 tem alguns bugs em questгo de criar arquivos com senha e checar a senha depois.
Reply
#8

Mano o problema e so voce adcionar o SetSpawnInfo:
Isso:
PHP код:
SpawnPlayer(playerid); 
Por:
PHP код:
SetSpawnInfo(playeridTIME SKIN POSIЗВOXPOSIЗВOYPOSIЗВOZ,ANGLO00,0,00,0);
SpawnPlayer(playerid); 
Para mais informaзхes : https://sampwiki.blast.hk/wiki/SetSpawnInfo

PS: Da um "+" rep
Reply
#9

Usa esse: https://sampforum.blast.hk/showthread.php?tid=328397
Ou esse:https://sampforum.blast.hk/showthread.php?tid=309257
Ou esse tambйm: https://sampforum.blast.hk/showthread.php?tid=317628
Reply
#10

faзa o sistema de login/registro em mysql, menos trabalho, e й mais rбpido (:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)