Ask password at OnPlayerSpawn
#1

Hello, I am making an simple admin system, but I want when a player connect before spawn to ask for his/her password.
If it's incorrect to be kicked.
How can I make it with the
pawn Код:
ShowPlayerDialog(playerid,DIALOGID,DIALOG_STYLE_INPUT,"Login Account","Login","Quit");
Can someone give me an example how to use it
Reply
#2

Quote:
Originally Posted by Kostas'
Посмотреть сообщение
Hello, I am making an simple admin system, but I want when a player connect before spawn to ask for his/her password.
If it's incorrect to be kicked.
How can I make it with the
pawn Код:
ShowPlayerDialog(playerid,DIALOGID,DIALOG_STYLE_INPUT,"Login Account","Login","Quit");
Can someone give me an example how to use it
pawn Код:
public OnPlayerConnect(playerid)
{
    ShowPlayerDialog(playerid,DIALOGID,DIALOG_STYLE_INPUT,"Login Account","Login","Quit");
    return 1;
}
Reply
#3

Quote:
Originally Posted by Stigg
Посмотреть сообщение
pawn Код:
public OnPlayerConnect(playerid)
{
    ShowPlayerDialog(playerid,DIALOGID,DIALOG_STYLE_INPUT,"Login Account","Login","Quit");
    return 1;
}
Except this, this I want to say is, how to make it, if the password the player type input is correct to spawn, if it's incorrect to be kicked
Reply
#4

This is an example
pawn Код:
{
    gPlayerLogged[playerid] = 0;
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    {
        if(!dini_Exists(file))
        {
            ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not a member,Input your PW below","Register","Kick Me");
        }
        if(fexist(file))
        {
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your  registered", "Welcome, your a member,Input your PW below","Register","Kick Me");
        }
     }
    return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        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, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not a member,Input your PW below","Register","Kick Me");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Score", PInfo[playerid][pScore]);
        dini_IntSet(file, "Cash", PInfo[playerid][pCash]);
        dini_IntSet(file, "AdminLevel", PInfo[playerid][pAdminLevel]);
        format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, 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);
        if(!response) return Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your  registered,Welcome, your a  member","Input your PW below","Register","Kick Me");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) !=tmp)
        {
            SendClientMessage(playerid, COLOR_RED, "Wrong PW dude");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your  registered", "Welcome, your not  member,Input your PW below","Register","Kick Me");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            SetPlayerScore(playerid, dini_Int(file, "Score"));
           
            SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!");
        }
    }
    return 1;
}
I used this thing in my login and register script.
Reply
#5

what are you using for saving player accounts?
Reply
#6

Quote:
Originally Posted by [Diablo]
Посмотреть сообщение
what are you using for saving player accounts?
I use Dini


Quote:
Originally Posted by nilanjay
Посмотреть сообщение
This is an example
pawn Код:
{
    gPlayerLogged[playerid] = 0;
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    {
        if(!dini_Exists(file))
        {
            ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not a member,Input your PW below","Register","Kick Me");
        }
        if(fexist(file))
        {
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your  registered", "Welcome, your a member,Input your PW below","Register","Kick Me");
        }
     }
    return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        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, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not a member,Input your PW below","Register","Kick Me");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Score", PInfo[playerid][pScore]);
        dini_IntSet(file, "Cash", PInfo[playerid][pCash]);
        dini_IntSet(file, "AdminLevel", PInfo[playerid][pAdminLevel]);
        format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, 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);
        if(!response) return Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your  registered,Welcome, your a  member","Input your PW below","Register","Kick Me");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) !=tmp)
        {
            SendClientMessage(playerid, COLOR_RED, "Wrong PW dude");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your  registered", "Welcome, your not  member,Input your PW below","Register","Kick Me");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            SetPlayerScore(playerid, dini_Int(file, "Score"));
           
            SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!");
        }
    }
    return 1;
}
I used this thing in my login and register script.
Can you explain me, if you have time, how this work to understand it.
Reply
#7

Quote:
Originally Posted by nilanjay
Посмотреть сообщение
This is an example
pawn Код:
{
    gPlayerLogged[playerid] = 0;
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    {
        if(!dini_Exists(file))
        {
            ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not a member,Input your PW below","Register","Kick Me");// This will show if you are not registered.
        }
        if(fexist(file))
        {
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your  registered", "Welcome, your a member,Input your PW below","Register","Kick Me");// This will show if your already registred.
        }
     }
    return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        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);// This is used if the player doesn't respond to any option.
        if(!strlen(inputtext)) return// This is used when the player cleck on any of the option
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not a member,Input your PW below","Register","Kick Me");//
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Score", PInfo[playerid][pScore]);
        dini_IntSet(file, "Cash", PInfo[playerid][pCash]);
        dini_IntSet(file, "AdminLevel", PInfo[playerid][pAdminLevel]);
        format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
        SendClientMessage(playerid, COLOR_LIGHTBLUE, 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);
        if(!response) return Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your  registered,Welcome, your a  member","Input your PW below","Register","Kick Me");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) !=tmp)
        {
            SendClientMessage(playerid, COLOR_RED, "Wrong PW dude");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your  registered", "Welcome, your not  member,Input your PW below","Register","Kick Me");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            SetPlayerScore(playerid, dini_Int(file, "Score"));
           
            SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!");
        }
    }
    return 1;
}
I used this thing in my login and register script.
Done. I think you must understand a littlebit. Just read the codes carefully and you will came to know.
Reply
#8

https://sampforum.blast.hk/showthread.php?tid=101560
will help you
Reply
#9

Quote:
Originally Posted by nilanjay
Посмотреть сообщение
Done. I think you must understand a littlebit. Just read the codes carefully and you will came to know.
Okay, I will
Quote:
Originally Posted by Mr_Scripter
Посмотреть сообщение
Thank you
Reply
#10

just a tip for you . Open a New script and look at the topic i showed you and read carfully and do what it says in the topic you'll learn it :P
Rep if it helped you.. btw, need 1 more for Ad :/
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)