YINI help please
#1

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    new 
string[270], strings[270], playername[25];
    
GetPlayerName(playeridplayernameMAX_PLAYER_NAME);
    if(
dialogid == DIALOG_REGISTER)
    {
     if (!
response) return Kick(playerid);
     if(
response)
     {
      if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT""COL_GREEN"Register",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
      new 
INI:File INI_Open(AccountsPath(playerid));
      
INI_SetTag(File,"Player Data");
      
INI_WriteInt(File,"Password",num_hash(inputtext));
      
INI_Close(File);
      
format(stringsizeof string,"%s has registered a new account"playername);
      
SendClientMessageToAll(COLOR_YELLOWstring);
      }
    }
    if(
dialogid == DIALOG_LOGIN)
    {
     if (!
response) return Kick (playerid);
     if(
response)
     {
      if(
num_hash(inputtext) == PlayerInfo[playerid][PlayerPass])
      {
       
INI_ParseFile(AccountsPath(playerid), "LoadPlayer_%s", .bExtra true, .extra playerid);
       
SetPlayerScore(playerid,  PlayerInfo[playerid][PlayerScore]);
      }
      else
      {
       
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_RED"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
      }
      return 
1;
      }
     }
    return 
1;

i created this Login/Register system its making the player registered but when i join game again i entered correct pass but its showing wrong password please help
Reply
#2

what's the value of PlayerInfo[playerid][PlayerPass]? I bet its 0
PHP код:
INI_ParseFile(AccountsPath(playerid), "LoadPlayer_%s", .bExtra true, .extra playerid); 
you had to do that when you show dialog login so PlayerInfo[playerid][PlayerPass] would get loaded.
or just make a new loader just to load that.
Reply
#3

Quote:
Originally Posted by jlalt
Посмотреть сообщение
what's the value of PlayerInfo[playerid][PlayerPass]? I bet its 0
PHP код:
INI_ParseFile(AccountsPath(playerid), "LoadPlayer_%s", .bExtra true, .extra playerid); 
you had to do that when you show dialog login so PlayerInfo[playerid][PlayerPass] would get loaded.
or just make a new loader just to load that.
PHP код:
enum pInfo
{
    
PlayerPass[129],
    
PlayerMoney
}
new 
PlayerInfo[PLAYERS][pInfo];
forward LoadPlayer_data(playerid,name[],value[]);
public 
LoadPlayer_data(playerid,name[],value[])
{
    
INI_Int("password",PlayerInfo[playerid][PlayerPass]);
    return 
1;

now?? still not working
Reply
#4

Quote:
Originally Posted by BulletRaja
Посмотреть сообщение
PHP код:
enum pInfo
{
    
PlayerPass[129],
    
PlayerMoney
}
new 
PlayerInfo[PLAYERS][pInfo];
forward LoadPlayer_data(playerid,name[],value[]);
public 
LoadPlayer_data(playerid,name[],value[])
{
    
INI_Int("password",PlayerInfo[playerid][PlayerPass]);
    return 
1;

now?? still not working
put INI_ParseFile(AccountsPath(playerid), "LoadPlayer_%s", .bExtra = true, .extra = playerid);
before you do ShowPlayerDialog, of login.
Reply
#5

i did its still not working

here the code help pls
PHP код:
enum pInfo
{
    
PlayerPass,
    
PlayerMoney,
    
PlayerLevel,
    
PlayerScore,
    
PlayerKills,
    
PlayerDeaths,
    
PlayerBanned,
    
PlayerIP[16]
}

new 
PlayerInfo[PLAYERS][pInfo];

forward LoadPlayer_data(playerid,name[],value[]);
public 
LoadPlayer_data(playerid,name[],value[])
{
    
INI_Int("password",PlayerInfo[playerid][PlayerPass]);
    
INI_Int("money",PlayerInfo[playerid][PlayerMoney]);
    
INI_Int("adminlevel",PlayerInfo[playerid][PlayerLevel]);
    
INI_Int("scores",PlayerInfo[playerid][PlayerScore]);
    
INI_Int("kills",PlayerInfo[playerid][PlayerKills]);
    
INI_Int("deaths",PlayerInfo[playerid][PlayerDeaths]);
    
INI_Int("playerbanned",PlayerInfo[playerid][PlayerBanned]);
    
INI_String("playerip",PlayerInfo[playerid][PlayerIP], 16);
    return 
1;
}

stock AccountsPath(playerid)
{
    new 
string[128],playername[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,playername,sizeof(playername));
    
format(string,sizeof(string),UserFiles,playername);
    return 
string;
}

stock udb_hash(buf[]) {
    new 
length=strlen(buf);
    new 
s1 1;
    new 
s2 0;
    new 
n;
    for (
n=0n<lengthn++)
    {
       
s1 = (s1 buf[n]) % 65521;
       
s2 = (s2 s1)     % 65521;
    }
    return (
s2 << 16) + s1;
}

//OnplayerConnect
new str[270];
    if (
isconnected[playerid] == 0)
    {
        
isconnected[playerid] = 1;
        
SetPlayerColor(playeridCOLOR_PLAYER);
        
SetPlayerVirtualWorld(playerid1);
        new 
playername[MAX_PLAYER_NAME];
        
GetPlayerName(playeridplayernameMAX_PLAYER_NAME);

        if(
fexist(AccountsPath(playerid)))
        {
            
INI_ParseFile(AccountsPath(playerid), "LoadPlayer_%s", .bExtra true, .extra playerid);
            
format(strsizeof(str), "Welcome to {00FFF3}%s.\n\n{FFFF00}Account:{FFFFFF} %s\n\nPlease enter your password below:"SV_NAMERPN(playerid));
            
ShowPlayerDialog2(playeridDIALOG_LOGINDIALOG_STYLE_INPUT""COL_RED"Login"str"Login""Cancel");
            
SendPlayerFormattedText(playeridCOLOR_LBLUE"Welcome back %s to {FF33CC}"SV_NAME"{FFFFFF}."playername"");
            
playerlogged[playerid] = 1;
        }
        else
        {
            
format(strsizeof(str), "Welcome to {FFB900}%s.\n\n{FFFF00}Account:{FFFFFF} %s\n\nRegister an account to play.\n\nPlease put the password below:"SV_NAMERPN(playerid));
            
ShowPlayerDialog2(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT""COL_GREEN"Register"str"Continue""Cancel");
            
SendPlayerFormattedText(playeridCOLOR_WHITE"Welcome %s to {FF33CC}"SV_NAME"{FFFFFF}."playername"");
            
playerlogged[playerid] = 1;
        }
        return 
0;
    }
    
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    new 
string[270], strings[270], playername[25];
    
GetPlayerName(playeridplayernameMAX_PLAYER_NAME);
    if(
dialogid == DIALOG_REGISTER)
    {
     if (!
response) return SendClientMessage(playeridCOLOR_GREY,"[Server]: You must register/login to spawn.");
     if(
response)
     {
      if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT""COL_GREEN"Register",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Cancel");
      new 
pIP[16];
      
GetPlayerIp(playeridpIPsizeof(pIP));
      new 
INI:File INI_Open(AccountsPath(playerid));
      
INI_SetTag(File,"Player Data");
      
INI_WriteInt(File,"password",udb_hash(inputtext));
      
INI_WriteInt(File,"money"REGISTER_MONEY);
      
INI_WriteInt(File,"adminlevel",0);
      
INI_WriteInt(File,"scores"REGISTER_SCORE);
      
INI_WriteInt(File,"kills",0);
      
INI_WriteInt(File,"deaths",0);
      
INI_WriteInt(File,"playerbanned",0);
      
INI_WriteString(File"playerip"pIP);
      
INI_Close(File);
      
GivePlayerMoney(playeridREGISTER_MONEY);
      
GivePlayerScore(playeridREGISTER_SCORE);
      
playerlogged[playerid] = 1;

      
format(stringsizeof string,"%s has registered a new account"playername);
      
SendClientMessageToAll(COLOR_YELLOWstring);
      
format(stringssizeof strings,"%s Welcome in "SV_NAME", /rules and /help"playername);
      
SendClientMessageToAll(COLOR_YELLOWstrings);
      }
    }

    if(
dialogid == DIALOG_LOGIN)
    {
     if(!
response) return SendClientMessage(playeridCOLOR_GREY,"[Server]: You must register/login to spawn.");
     if(
response)
     {
      if(
num_hash(inputtext) == PlayerInfo[playerid][PlayerPass])
      {
       
//INI_ParseFile(AccountsPath(playerid), "LoadPlayer_%s", .bExtra = true, .extra = playerid);
       
SetPlayerScore(playerid,  PlayerInfo[playerid][PlayerScore]);
       
GivePlayerMoney(playeridPlayerInfo[playerid][PlayerMoney]);

       
playerlogged[playerid] = 1;
       
SendClientMessage(playeridCOLOR_GREEN,"You have successfully logged in");

      }
      else
      {
       
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""COL_RED"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Cancel");
      }
      return 
1;
      }
     }
    return 
1;

Reply
#6

using udb_hash to has the password on register and using num_hash to hash the input and compare on login.
that won't work.
Код:
if(num_hash(inputtext) == PlayerInfo[playerid][PlayerPass])
Код:
INI_WriteInt(File,"password",udb_hash(inputtext));
maybe change num_hash(inputtext) to udb_hash(inputtext) ?
Reply
#7

Quote:
Originally Posted by jlalt
Посмотреть сообщение
using udb_hash to has the password on register and using num_hash to hash the input and compare on login.
that won't work.
Код:
if(num_hash(inputtext) == PlayerInfo[playerid][PlayerPass])
Код:
INI_WriteInt(File,"password",udb_hash(inputtext));
maybe change num_hash(inputtext) to udb_hash(inputtext) ?
still not working
Reply
#8

bro its fixed by using this
Код:
INI_ParseFile(AccountsPath(playerid), "LoadPlayer_data", .bExtra = true, .extra = playerid);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)