Admin Override
#1

Ok, i'm having huge problems here. I'm trying to make an admin override for my script (because my ftp fucks me over, and fucks my account up when i try to give it admin). But i don't know how to do it, i know how to do the first part:

if(strcmp(cmd, "/adminoverride", true) == 0)

But like, when i do the cmd, i want a dialog box to come up, asking for the override pass. And if the pass is right, for it to do ABroadCast, saying like "%s has used Admin Override to make themself Admin!", and if pass failed "%s has attempted to hack Admin!".

But the problem is, i don't know how to make it ask for a pass, i'm just completely confused, and this is my first time really scripting something huge like this. If someone can give me some guidance as to how to do it, that'd be sooo great.
Reply
#2

You'll have to use
ShowPlayerDialog(playerid, blablabla);
OnDialogResponse(playerid, blablabla);
and then you'll have to create a variable like:

Код:
new adminpassword[30] = "My Cool Admin Password"

//OnDialogResponse you use
if(inputext == adminpassword[30]){do the thing you want to happen here}
else{
SendClientMessageToAll(-1, "Someone failed at logging into the admin section");
}
Hope it helped
Reply
#3

pawn Код:
#include <a_samp>

#define MYDIALOG 1000
#define PASSWORD "thisismypassword"

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/adminoverride", true) == 0)
    {
        if(AdminVariable[playerid] == 1) //If they aren't an admin
        {
            ShowPlayerDialog(playerid, MYDIALOG, DIALOG_STYLE_PASSWORD, "Admin Password", "Please Enter The Admin Password.", "Submit", "Cancel");
            return 1;
        }
        else return SendClientMessage(playerid, 0xFF0000FF, "You Are Already An Administrator.");
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == MYDIALOG)
    {
        if(response)
        {
            new string[80], name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, MAX_PLAYER_NAME);
            if(strcmp(inputtext, PASSWORD, true) == 0)
            {
                AdminVariable[playerid] = 1; //Set them Admin
                format(string,sizeof(string),"%s Has Used Admin Override To Make Themself An Admin.",name);
                SendClientMessageToAll(-1, string);
            }
            else
            {
                format(string,sizeof(string),"%s Has Attempted To Hack The Admin Override!",name);
                SendClientMessageToAll(-1, string);
                //Kick(playerid);
            }
        }
        return 1;
    }
    return 0;
}
Reply
#4

Thanks sooooo much, i'll be sure to give you both rep+. I have one problem though, the compilers telling me there's an error with it, but when i go to where it says, it looks perfectly normal for me. Here's the errors.

C:\Users\Jay\Desktop\New Nation Roleplay\gamemodes\NNRP.pwn(1811 : error 001: expected token: ";", but found ")"
C:\Users\Jay\Desktop\New Nation Roleplay\gamemodes\NNRP.pwn(1811 : error 029: invalid expression, assumed zero


C:\Users\Jay\Desktop\New Nation Roleplay\gamemodes\NNRP.pwn(1811 : error 029: invalid expression, assumed zero

Now here's the script along with line 18118, you'll even see there's no error there, so i don't even know what to do, normally i'm good with fixing errors, but this ones just a huge problem.

Код:
	if(strcmp(cmd, "/adminoverride", true) == 0)
	{
	    ShowPlayerDialog(playerid, ADMINOVERRIDE, DIALOG_STYLE_PASSWORD, "Admin Password", "Please Enter the Override Password!", "Submit", "Cancel");
	    return 1;
	}
If you can tell me how to fix it, that'd be great.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)