SA-MP Forums Archive
admin password - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: admin password (/showthread.php?tid=208360)



admin password - xir - 08.01.2011

hello, i need help with admin password

i tried to get it from the pocket admin made by zezombia, but i want to make it in dialog because i hate /login etc
after a normal player logs in they only need to type their password and they enter, but when an admin enter they need to write their own password and the admin password, in dialog.....

i tried to make one here is my ondialogrespone but is very very hard
also do i need to make the dialogs onplayerconnect??

pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == 1)
    {
        new name[MAX_PLAYER_NAME], file[256];
        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, "Register your account", "Enter a password", "Register", "Quit");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
        gPlayerLogged[playerid] = 1;
    }
    if (dialogid == 2)
    {
        new name[MAX_PLAYER_NAME], file[256];
        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, "Login to your account", "Enter your password", "Login", "Quit");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp) {
           ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login to your account", "Wrong password ! \nEnter your password", "Login", "Quit");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            SendClientMessage(playerid,Green, "Successfully logged in");
    }
    if (dialogid == 3)
    {
        if(PlayerInfo[playerid][pAdminLevel] >=1)
        new tmp;
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login to your account", "Enter your password", "Login", "Quit");
        if(strval(tmp) == AdminPassword)
        {
        SendClientMessage(playerid, Green, "Welcome Admin");
        return PLVL[playerid] = 1;
        }
        else
        {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login to your account", "Wrong password ! \nEnter your password", "Login", "Quit");
        }
    }
    return 1;
}



Re: admin password - xir - 08.01.2011

help please, still trying to fix


Re: admin password - Mike Garber - 08.01.2011

You don't tell us what is wrong with it, what does NOT happen that SHOULD happen?


Re: admin password - xir - 08.01.2011

i get alot of errors

pawn Code:
E:\GTA San Andreas\Server\gamemodes\AdminPass.pwn(122) : warning 217: loose indentation
E:\GTA San Andreas\Server\gamemodes\AdminPass.pwn(125) : error 003: declaration of a local variable must appear in a compound block
E:\GTA San Andreas\Server\gamemodes\AdminPass.pwn(125) : warning 215: expression has no effect
E:\GTA San Andreas\Server\gamemodes\AdminPass.pwn(127) : error 035: argument type mismatch (argument 1)
E:\GTA San Andreas\Server\gamemodes\AdminPass.pwn(140) : error 030: compound statement not closed at the end of file (started at line 91)
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
but i think the code is wrong


Re: admin password - xir - 08.01.2011

someone please help


Re: admin password - xir - 09.01.2011

i attempted to do it again ,but i cant figure it out pls help me


Re: admin password - MadeMan - 09.01.2011

Show the lines you have errors.


Re: admin password - GiS - 09.01.2011

We can easily help you if you show us each line with each error you got there


Re: admin password - xir - 09.01.2011

i put the admin pass in a fs and make it before i put in the gamemode, so here is pastebin and i think sometihng is missing

http://pastebin.com/PfsR2G5Z

pawn Code:
E:\GTA San Andreas\Server\gamemodes\AdminPass.pwn(122) : warning 217: loose indentation
E:\GTA San Andreas\Server\gamemodes\AdminPass.pwn(125) : error 003: declaration of a local variable must appear in a compound block
E:\GTA San Andreas\Server\gamemodes\AdminPass.pwn(125) : warning 215: expression has no effect
E:\GTA San Andreas\Server\gamemodes\AdminPass.pwn(127) : error 035: argument type mismatch (argument 1)
E:\GTA San Andreas\Server\gamemodes\AdminPass.pwn(140) : error 030: compound statement not closed at the end of file (started at line 91)
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
i think i can fix the indention problem , but i tried so hard to do the other errors i hope you guys can help


Re: admin password - MadeMan - 09.01.2011

pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == 1)
    {
        new name[MAX_PLAYER_NAME], file[256];
        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, "Register your account", "Enter a password", "Register", "Quit");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
        gPlayerLogged[playerid] = 1;
    }
    if (dialogid == 2)
    {
        new name[MAX_PLAYER_NAME], file[256];
        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, "Login to your account", "Enter your password", "Login", "Quit");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp)
        {
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login to your account", "Wrong password ! \nEnter your password", "Login", "Quit");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            SendClientMessage(playerid,Green, "Successfully logged in");
        }
    }
    if (dialogid == 3)
    {
        if(PlayerInfo[playerid][pAdminLevel] >=1) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login to your account", "Enter your password", "Login", "Quit");
        if(strval(inputtext) == AdminPassword)
        {
            SendClientMessage(playerid, Green, "Welcome Admin");
            PLVL[playerid] = 1;
        }
        else
        {
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login to your account", "Wrong password ! \nEnter your password", "Login", "Quit");
        }
    }
    return 1;
}