Editing into a Dialog please read!
#1

Hello evryone
I had my old register system and i managed to create a dialog login and register and it worked perfectly
Altho that system had a bug in stats save
So i had to code a new one
So can anyone tell me how to turn this strcmp into dialog
I have tried it
I tried making login and yes it appeared but it doesent login me
LOGIN
pawn Код:
if(strcmp(cmd, "/login", true) == 0)
    {
      tmp = strtok(cmdtext, idx);
      if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_GREY, " USAGE: /login [password]");
        new name[MAX_PLAYER_NAME];
        if(IsLogged[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR_RED, "You are already logged in.");
            return 1;
        }
        else
        {
            GetPlayerName(playerid, name, sizeof(name));
            format(file,sizeof(file),"Users/%s.ini",name);
            if(fexist(file))
            {
            tmp2 = dini_Get(file, "Password");
                if(udb_hash(tmp) != strval(tmp2))
                {
                  SendClientMessage(playerid, COLOR_RED, "This password does not match any account in the database.");
                }
                else
                {
                    IsLogged[playerid] = 1;
                    PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "Admin Level");
                    PlayerInfo[playerid][pVIPMember] = dini_Int(file, "VIP Member");
          PlayerInfo[playerid][pArmy] = dini_Int(file, "Army Rank");
                    SetPlayerMoney(playerid, dini_Int(file, "Cash"));
          PlayerInfo[playerid][pBans] = dini_Int(file, "Bans");
          PlayerInfo[playerid][pKicks] = dini_Int(file, "Kicks");
          PlayerInfo[playerid][pWarns] = dini_Int(file, "Warns");
          PlayerInfo[playerid][pMuted] = dini_Int(file, "Muted");
                    SendClientMessage(playerid, COLOR_WHITE, "You have successfully logged into your account.");
                    PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
                    TogglePlayerControllable(playerid, 1);
                }
            }
        }
        return 1;
    }
REGISTER
pawn Код:
if(strcmp(cmd, "/register", true) == 0)
    {
      new name[MAX_PLAYER_NAME];
      tmp = strtok(cmdtext, idx);
      GetPlayerName(playerid, name, sizeof(name));
      if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_GREY, " USAGE: /register [password]");
      format(file,sizeof(file),"Users/%s.ini",name);
      if(!fexist(file))
        {
            dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(tmp));
          dini_IntSet(file,"Admin Level", 0);
          dini_IntSet(file,"VIP Member", 0);
      dini_IntSet(file,"Army Rank", 0);
            dini_IntSet(file,"Cash", 0);
      dini_IntSet(file,"Bank", 0);
      dini_IntSet(file,"Bans", 0);
      dini_IntSet(file,"Kicks", 0);
      dini_IntSet(file,"Warns", 0);
      dini_IntSet(file,"Muted", 0);
            SendClientMessage(playerid, COLOR_WHITE, "You have successfully registered a account, you can now login by typing /login.");
      PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "This account is already in the database.");
        }
        return 1;
    }
And please dont tell me to search because tbh i tried and didnt find anything
Reply
#2

it is really hard to get an answer on this. I was asking this too a little while ago. I think this just cost to much time for good scripters.
I still don't know how to fix this. I was trying some variables but failed. Good luck anyway
Reply
#3

Well im not that good and my previous version ( had a problem with saving stats i didnt add some thing on disconnect)
Was ok
I mean the dialog it all worked
Reply
#4

Try that:

pawn Код:
// When you call the dialog:
new pname[24];
new pfile[128];
GetPlayerName(playerid, pname, sizeof(pname));
format(pfile,sizeof(pfile),"Users/%s.ini",pname);
if(fexist(pfile))
{
  ShowPlayerDialog(playerid,1515,DIALOG_STYLE_INPUT,"Login to play","Password","Login","Exit");
}else{
  ShowPlayerDialog(playerid,1515,DIALOG_STYLE_INPUT,"Register to play","Password","Login","Exit");
}

// And the response:
public OnDialogResponse(...){
  if(dialogid == 1515){
    if(!response){
      kick(playerid);
      return true;
    }
    new pname[24];
     new pfile[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(pfile,sizeof(pfile),"Users/%s.ini",pname);
    if(fexist(pfile))
    {
      if(!strlen(inputtext)) return ShowPlayerDialog(playerid,dialogid,DIALOG_STYLE_INPUT,"ENTER your password","Password","Login","Exit");
      if(!strcmp(udb_hash(inputtext),dini_Get(pfile, "Password"),false)){
        IsLogged[playerid] = 1;
        PlayerInfo[playerid][pAdminLevel] = dini_Int(pfile, "Admin Level");
        PlayerInfo[playerid][pVIPMember] = dini_Int(pfile, "VIP Member");
        PlayerInfo[playerid][pArmy] = dini_Int(pfile, "Army Rank");
        SetPlayerMoney(playerid, dini_Int(pfile, "Cash"));
        PlayerInfo[playerid][pBans] = dini_Int(pfile, "Bans");
        PlayerInfo[playerid][pKicks] = dini_Int(pfile, "Kicks");
        PlayerInfo[playerid][pWarns] = dini_Int(pfile, "Warns");
        PlayerInfo[playerid][pMuted] = dini_Int(pfile, "Muted");
        SendClientMessage(playerid, COLOR_WHITE, "You have successfully logged into your account.");
        PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        TogglePlayerControllable(playerid, 1);
      }else{
        return ShowPlayerDialog(playerid,dialogid,DIALOG_STYLE_INPUT,"Bad password","Try again","Login","Exit");
      }
    }else{
      // Create Account:
      format(pfile,sizeof(pfile),"Users/%s.ini",name);
      dini_Create(pfile);
      dini_IntSet(pfile, "Password", udb_hash(inputtext));
        dini_IntSet(pfile,"Admin Level", 0);
        dini_IntSet(pfile,"VIP Member", 0);
      dini_IntSet(pfile,"Army Rank", 0);
      dini_IntSet(pfile,"Cash", 0);
      dini_IntSet(pfile,"Bank", 0);
      dini_IntSet(pfile,"Bans", 0);
      dini_IntSet(pfile,"Kicks", 0);
      dini_IntSet(pfile,"Warns", 0);
      dini_IntSet(pfile,"Muted", 0);
      // Login player:
      IsLogged[playerid] = 1;
      PlayerInfo[playerid][pAdminLevel] = dini_Int(pfile, "Admin Level");
      PlayerInfo[playerid][pVIPMember] = dini_Int(pfile, "VIP Member");
      PlayerInfo[playerid][pArmy] = dini_Int(pfile, "Army Rank");
      SetPlayerMoney(playerid, dini_Int(pfile, "Cash"));
      PlayerInfo[playerid][pBans] = dini_Int(pfile, "Bans");
      PlayerInfo[playerid][pKicks] = dini_Int(pfile, "Kicks");
      PlayerInfo[playerid][pWarns] = dini_Int(pfile, "Warns");
      PlayerInfo[playerid][pMuted] = dini_Int(pfile, "Muted");
      TogglePlayerControllable(playerid, 1);
      SendClientMessage(playerid, COLOR_WHITE, "You have successfully registered a account. Enjoy the server!");
      PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
    }
  }
  return true;
}
Reply
#5

Quote:
Originally Posted by wafffllesss
Try that:

pawn Код:
// When you call the dialog:
new pname[24];
new pfile[128];
GetPlayerName(playerid, pname, sizeof(pname));
format(pfile,sizeof(pfile),"Users/%s.ini",pname);
if(fexist(pfile))
{
  ShowPlayerDialog(playerid,1515,DIALOG_STYLE_INPUT,"Login to play","Password","Login","Exit");
}else{
  ShowPlayerDialog(playerid,1515,DIALOG_STYLE_INPUT,"Register to play","Password","Login","Exit");
}

// And the response:
public OnDialogResponse(...){
  if(dialogid == 1515){
    if(!response){
      kick(playerid);
      return true;
    }
    new pname[24];
    new pfile[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(pfile,sizeof(pfile),"Users/%s.ini",pname);
    if(fexist(pfile))
    {
      if(!strlen(inputtext)) return ShowPlayerDialog(playerid,dialogid,DIALOG_STYLE_INPUT,"ENTER your password","Password","Login","Exit");
      if(!strcmp(udb_hash(inputtext),dini_Get(pfile, "Password"),false)){
        IsLogged[playerid] = 1;
        PlayerInfo[playerid][pAdminLevel] = dini_Int(pfile, "Admin Level");
        PlayerInfo[playerid][pVIPMember] = dini_Int(pfile, "VIP Member");
        PlayerInfo[playerid][pArmy] = dini_Int(pfile, "Army Rank");
        SetPlayerMoney(playerid, dini_Int(pfile, "Cash"));
        PlayerInfo[playerid][pBans] = dini_Int(pfile, "Bans");
        PlayerInfo[playerid][pKicks] = dini_Int(pfile, "Kicks");
        PlayerInfo[playerid][pWarns] = dini_Int(pfile, "Warns");
        PlayerInfo[playerid][pMuted] = dini_Int(pfile, "Muted");
        SendClientMessage(playerid, COLOR_WHITE, "You have successfully logged into your account.");
        PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        TogglePlayerControllable(playerid, 1);
      }else{
        return ShowPlayerDialog(playerid,dialogid,DIALOG_STYLE_INPUT,"Bad password","Try again","Login","Exit");
      }
    }else{
      // Create Account:
      format(pfile,sizeof(pfile),"Users/%s.ini",name);
      dini_Create(pfile);
      dini_IntSet(pfile, "Password", udb_hash(inputtext));
       dini_IntSet(pfile,"Admin Level", 0);
       dini_IntSet(pfile,"VIP Member", 0);
      dini_IntSet(pfile,"Army Rank", 0);
      dini_IntSet(pfile,"Cash", 0);
      dini_IntSet(pfile,"Bank", 0);
      dini_IntSet(pfile,"Bans", 0);
      dini_IntSet(pfile,"Kicks", 0);
      dini_IntSet(pfile,"Warns", 0);
      dini_IntSet(pfile,"Muted", 0);
      // Login player:
      IsLogged[playerid] = 1;
      PlayerInfo[playerid][pAdminLevel] = dini_Int(pfile, "Admin Level");
      PlayerInfo[playerid][pVIPMember] = dini_Int(pfile, "VIP Member");
      PlayerInfo[playerid][pArmy] = dini_Int(pfile, "Army Rank");
      SetPlayerMoney(playerid, dini_Int(pfile, "Cash"));
      PlayerInfo[playerid][pBans] = dini_Int(pfile, "Bans");
      PlayerInfo[playerid][pKicks] = dini_Int(pfile, "Kicks");
      PlayerInfo[playerid][pWarns] = dini_Int(pfile, "Warns");
      PlayerInfo[playerid][pMuted] = dini_Int(pfile, "Muted");
      TogglePlayerControllable(playerid, 1);
      SendClientMessage(playerid, COLOR_WHITE, "You have successfully registered a account. Enjoy the server!");
      PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
    }
  }
  return true;
}
Error:
Код:
C:\Users\Adi\Desktop\admin3.pwn(1759) : error 035: argument type mismatch (argument 1)
My line 1759 is if(!strcmp(udb_hash(inputtext),dini_Get(pfile, "Password"),false)){
Reply
#6

It failed.. the dialog
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)