Register/Login dialog problem
#1

I have tried to make this dialog system and there is one problem, if i am registered, it will show me the dialog menu, "you are not registered, please register an account."
heres the code:
OnPlayerConnect:
pawn Код:
new user[MAX_PLAYER_NAME];
    GetPlayerName(playerid, user, MAX_PLAYER_NAME);
    format(user, sizeof(user), "NewAdmin/Users/%s.txt", user);
    if(dini_Exists(user))
    {
        Regged[playerid] = 1;
        Logged[playerid] = 0;
        ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome, You are registered", "Please Enter your password below", "Accept", "Cancel");
        if(dini_Int(user,"Banned") == 1) return SendClientMessage(playerid,BLUE,"You are banned!");

    }
    if(!dini_Exists(user))
    {
        ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Welcome, You are not registered", "Enter a password below", "Accept", "Cancel");
        return 1;
    }
Surely right there!! it should determine which menu i get, yes my file exists in the folder but it doesnt give me the correct menu now what the hell is going on!

pawn Код:
if(dialogid == Login)
{
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome, You are registered", "Enter a password below", "Accept", "Cancel");
        if (!response) return ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome, You are registered", "Enter a password below", "Accept", "Cancel");
        new file[256],name[MAX_PLAYER_NAME], string2[256];
        GetPlayerName(playerid,name,sizeof(name));
        format(file,sizeof(file),"NewAdmin/Users/%s.txt",name);
        string2= dini_Get(file,"Password");
        if(strcmp(inputtext,string2,false) != 0)
        {
            SendClientMessage(playerid,0x33CCFFAA,"You entered an invalid password!");
            ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome, You are registered", "Please enter a password below", "Accept", "Cancel");
            return 1;
        }
        GetPlayerName(playerid,name,sizeof(name));
        format(file,sizeof(file),"NewAdmin/Users/%s.txt",name);
        Logged[playerid] = 1;
        dini_IntSet(file,"Logged",1);
        PlayerInfo[playerid][Owner] = dini_Int(file,"Owner");
        PlayerInfo[playerid][Level] = dini_Int(file,"Level");
        PlayerInfo[playerid][Kills] = dini_Int(file,"Kills");
        PlayerInfo[playerid][Deaths] = dini_Int(file,"Deaths");
        PlayerInfo[playerid][Kicked] = dini_Int(file,"TimesKicked");
        PlayerInfo[playerid][Banned] = dini_Int(file,"Banned");
        PlayerInfo[playerid][PLevel] = dini_Int(file,"PLevel");
        PlayerInfo[playerid][Points] = dini_Int(file,"Points");
        PlayerInfo[playerid][Money] = dini_Int(file,"Money");
        SendClientMessage(playerid,0x33CCFFAA,"You have now Logged in");
    }
return 1;
}
pawn Код:
if(dialogid == Register)
{

        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Welcome, You are not registered", "Please Enter a password below", "Accept", "Cancel");
        if (!response) return ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Welcome, You are not registered", "Please Enter a password below", "Accept", "Cancel");
        new ip[128];
        new file[256], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid,name,sizeof(name));
        format(file,sizeof(file),"NewAdmin/Users/%s.txt",name);
        if(dini_Int(file,"Registered") == 1) return ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "Welcome, You are registered", "Enter a password below", "Accept", "Cancel");

        dini_Create(file);
        dini_Set(file,"Password",inputtext);
        dini_IntSet(file,"Registered",1);
        dini_IntSet(file,"Logged",0);
        dini_IntSet(file,"Level",1);
        dini_IntSet(file,"Owner",0);
        dini_IntSet(file,"Banned",0);
        dini_IntSet(file,"PLevel",1);
        GetPlayerIp(playerid,ip,sizeof(ip));
        dini_Set(file,"IP",ip);
        dini_IntSet(file,"Kills",0);
        dini_IntSet(file,"Deaths",0);
        dini_IntSet(file,"Points",0);
        dini_IntSet(file,"Money",15000);
        Regged[playerid] = 1;
        Logged[playerid] = 1;
        PlayerInfo[playerid][PLevel] = 1;
        SendClientMessage(playerid,LIMEGREEN,"You have succesfully registered and have automatically been logged in!");
        return 1;

}
if somebody could help me out on this i would be very happy thanks
Reply
#2

Look here -> https://sampwiki.blast.hk/wiki/Fexist

Could also try changing new user[MAX_PLAYER_NAME]; -> new user[54];

Btw: Here's and useful function that fetches a players name.

pawn Код:
stock PlayerName(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
return Name;
}

Example: printf("%s", PlayerName(playerid));
Reply
#3

bump bump bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)