Login Code Fail/
#1

Hey,

I seem to have an Issue with my login Code,

If I just press enter and not do anything it just goes to the OnPlayerClass Selection Screen.

heres my code:

pawn Код:
public OnPlayerConnect(playerid)
{
   SetPlayerCameraPos(playerid,2138.1683,1211.5165,110.0624);
   SetPlayerCameraLookAt(playerid,2062.7012,1348.5763,10.6719);
   gPlayerLogged[playerid] = 0;
   new name[MAX_PLAYER_NAME], file[256],string[128];
   GetPlayerName(playerid, name, sizeof(name));
   format(file, sizeof(file), SERVER_USER_FILE, name);
   if (!dini_Exists(file))
   {
        format(string,sizeof(string),"Welcome {FF0000}%s\n\r{0000FF}Enter a Password Below",name);
        ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "{33AA33}Las Vegas Real Life - Registration", string, "Register", "Leave");
   }
   if(fexist(file))
   {
      format(string,sizeof(string),"Welcome Back{FF0000}%s\n\rEnter Your Password Below to login",name);
      ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "{33AA33}Las Vegas Real Life - Login", string, "Login", "Leave");
   }
   return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == Register)
   {
        new name[MAX_PLAYER_NAME], file[256], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
        dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 500);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
        format(string, 128, "[SYSTEM]: You succesfully registered the Username %s with password %s, you have been auto logged in.", name, inputtext);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        gPlayerLogged[playerid] = 1;
   }
    if (dialogid == 2)
   {
      new name[MAX_PLAYER_NAME], file[256],string[128];
      GetPlayerName(playerid, name, sizeof(name));
      format(file, sizeof(file), SERVER_USER_FILE, name);
      format(string,sizeof(string),"Welcome Back{FF0000}%s\n\rEnter Your Password Below to login",name);
      if(!response) return Kick(playerid);
      if (!strlen(inputtext)) return ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "{33AA33}Las Vegas Real Life - Login", string, "Login", "Leave");
      new tmp;
      tmp = dini_Int(file, "Password");
      if(udb_hash(inputtext) != tmp) {
      SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: Incorrect Password Entered Attempt 2/3");
      ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT, "{33AA33}Las Vegas Real Life - Login", string, "Login", "Leave");
   }
      else
   {
      gPlayerLogged[playerid] = 1;
      PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
      SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
      GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
      SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!");
   }
   }
    return 1;
}
Reply
#2

It's because when you didnt enter something you create the file.

So here

pawn Код:
if (dialogid == Register)
   {
        new name[MAX_PLAYER_NAME], file[256], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
        ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "{33AA33}Las Vegas Real Life - Registration", string, "Register", "Leave");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
        dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 500);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
        format(string, 128, "[SYSTEM]: You succesfully registered the Username %s with password %s, you have been auto logged in.", name, inputtext);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        gPlayerLogged[playerid] = 1;
   }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)