Ask password at OnPlayerSpawn
#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


Messages In This Thread
Ask password at OnPlayerSpawn - by Kostas' - 17.10.2011, 13:05
Re: Ask password at OnPlayerSpawn - by Stigg - 17.10.2011, 13:09
Re: Ask password at OnPlayerSpawn - by Kostas' - 17.10.2011, 13:10
Re: Ask password at OnPlayerSpawn - by nilanjay - 17.10.2011, 13:11
Re: Ask password at OnPlayerSpawn - by [Diablo] - 17.10.2011, 13:16
Re: Ask password at OnPlayerSpawn - by Kostas' - 17.10.2011, 13:18
Re: Ask password at OnPlayerSpawn - by nilanjay - 17.10.2011, 13:28
Re: Ask password at OnPlayerSpawn - by Mr_Scripter - 17.10.2011, 13:30
Re: Ask password at OnPlayerSpawn - by Kostas' - 17.10.2011, 13:32
Re: Ask password at OnPlayerSpawn - by Mr_Scripter - 17.10.2011, 13:34

Forum Jump:


Users browsing this thread: 3 Guest(s)