#1

where can i go to make a user system with dialog register except for that wiki adminstrator thing because it a cmd thing i want dialog register
Reply
#2

uhm...

1) To make a good user system it's recommended to use SII (Slick's Ini Include)

2) You must include the encrypt function

pawn Code:
encrypt(pass[])
{
    static charset[] = "qwertyaQWERTYUIOPZXCVBNMLKJHGFDSAsdfghzxcvbnuiopjklm1324657809_";
    static css = 63;
    new target[MAX_PASS_SIZE + 1];
    new j = strlen(pass);
    new sum = j;
    new tmpp = 0;
    new i;
    new mod;
    for (i = 0; i < MAX_PASS_SIZE || i < j; i++)
    {
        mod = i % MAX_PASS_SIZE;
        tmpp = (i >= j) ? charset[(7 * i) % css] : pass[i];
        sum = (sum + chrfind(tmpp, charset) + 1)        % css;
        target[mod] = charset[(sum + target[mod])   % css];
    }
    target[MAX_PASS_SIZE] = '\0';
    return target;
}
3)

pawn Code:
#define DIALOG_REGISTER 150
#define DIALOG_LOGIN 151
4) Register dialog

Under public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])

pawn Code:
case DIALOG_REGISTER:
{
  new file[256];
  new name[MAX_PLAYER_NAME];      
  if(response)
  {
    if(IsPlayerRegistered(playerid)) return SendClientMessage(playerid,COLOR_RED,"Already Registered!");
    if(strlen(inputtext) < MIN_PASS_SIZE || strlen(inputtext) > MAX_PASS_SIZE )//define these values
    {
      SendClientMessage(playerid, COLOR_RED, "The mass password size is 16 and min is 4");//change it
      ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Change Me", "Change Me", "Sumbit", ""); //Leave the last "" blank to hide the button
      return 1;
    }
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    format(file,sizeof(file),"Users/%s.user.ini", name);
    INI_Open(file);
    INI_WriteString("Password", encrypt(inputtext));
    //Write the player info with INI_Write String/Int/Float (KEY[],VALUE[]);
    INI_Save();
    INI_Close();
    GivePlayerMoney(playerid,SOLDI_REGISTRAZIONE);
    SendClientMessage(playerid, COLOR_GREEN, "Account registered");
    SetPVarInt(playerid, "Logged", 1);     
  }
  return 1;
}
This will register the player.

Now, let's login him

5) Login Dialog

pawn Code:
case DIALOG_LOGIN:
{
  if(response)
  {
    if(!IsPlayerRegistered(playerid)) return SendClientMessage(playerid,COLOR_RED,"Not Registered!");    
    new read_pass[MAX_PASS_SIZE + 1];
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    format(file,sizeof(file),"Users/%s.user.ini", name);
    INI_Open(file);
    INI_ReadString(read_pass, "Password");
    if((!strcmp(encrypt(inputtext), read_pass, false)))
    {
      SetPVarInt(playerid, "Logged", 1);
      SendClientMessage(playerid, COLOR_GREEN, "Hai eseguito l'accesso.");   
      //read player's info with INI_Read String/Int/Float (DEST, KEY);
    }
    else//If password was false
    {
      SetPVarInt(playerid, "FalseLogins", GetPVarInt(playerid, "FalseLogins") + 1);
      if(GetPVarInt(playerid, "FalseLogins") >= 3)
      {
        new string[180];
        GetPlayerName(playerid,name,MAX_PLAYER_NAME);
        format(string, 180, "%s was kicked for too many false logins.", name);
        SendClientMessageToAll(COLOR_RED, string);
        printf("%s was kicked for wrong password. Last try: \"%s\".", name, inputtext);
        Kick(playerid);
      }
      else
      {
        SendClientMessage( playerid, COLOR_RED, "Wrong password!");      
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Text", "Text", "Sumbit", "");//Re-show the dialog
        printf("%s insert wrong password \"%s\".", name, inputtext);
      }

    }
    INI_Close();
  }
  else
  {
    new string[180];
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    format(string,180,DIALOG_LOGIN_TEXT2, name);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Text", "Text", "Sumbit", "");//Re-show the dialog
  }
  return 1;
}
6) Write the data in OnPlayerUpdate(playerid);

pawn Code:
new name[MAX_PLAYER_NAME];
  new file[256];
  GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  format(file,sizeof(file),"Users/%s.user.ini", name);
  if(!IsPlayerConnected(playerid)) return 1;
  if(!IsPlayerRegistered(playerid)) return 1;
  if(GetPVarInt(playerid, "Logged") != 1) return 1;
  INI_Open(file);
  //Write the strings, ints and floats like in register dialog
  INI_Save();
  INI_Close();
7) Check if player is registered

pawn Code:
stock IsPlayerRegistered(playerid)
{
  new name[MAX_PLAYER_NAME];
  new string[256];
  GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  format(string,sizeof(string),"Users/%s.user.ini",name);
  if(INI_Exist(string)) return true;
  return false;
}
Reply
#3

where to put number 2
Reply
#4

Number 2 and number 7 are functions or stock, they go at the end.

PS: edit the messages because I don't speak english very well
Reply
#5

Quote:
Originally Posted by [GF]Sasino97
View Post
uhm...
1) To make a good user system it's recommended to use SII (Slick's Ini Include)
Recomended by who?
Never heard of it
Reply
#6

I use it since a long time
Reply
#7

That's one recomending it =
Quote:

I recomend ....

Sorry, but I find it rather disturbing when people speak for others.
Reply
#8

OK, I recommend it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)