help admin system
#1

i make new system admin and i have big problem when i join the server and make my self admin lvl 5 (/setlevel 0 5)
anyone after ill register server auto set him lvl 5 , idk please help guys and tell me what is the probelm ? ,thanks .
Reply
#2

Hard to tell when we have to guess the code..
Reply
#3

this is command /setlevel :

Код:
CMD:setlevel(playerid, params[])
{
	new targetid, level, string[100];
	if(PlayerInfo[playerid][pAdmin] < 5 && !IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, "[ERROR] You are not authorised to use this command");
	if(sscanf(params, "ud", targetid, level)) return SCM(playerid, COLOR_RED, "[USAGE] /setlevel <playerid/part of name> <level>");
    if(!IsPlayerConnected(targetid)) return SCM(playerid, COLOR_RED, "Player is not connected");
    PlayerInfo[targetid][pAdmin] = level;
    format(string, sizeof(string), "Admin %s has set your admin level to %d", GetName(playerid), level);
    SCM(targetid, COLOR_GREEN, string);
    format(string, sizeof(string), "You have successfully set %s's level to %d", GetName(targetid), level);
    SCM(playerid, COLOR_GREEN, string);
    return 1;
Код:
enum pInfo
{
    pPass,
    pScore,
    pCash,
    pKills,
    pDeaths,
    pAdmin,
    pMute
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward ClearMute();
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("AdminLevel",PlayerInfo[playerid][pAdmin]);
    return 1;
}
and OnDialogResponse:

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Score",0);
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_WriteInt(File,"AdminLevel",0);
                INI_Close(File);

                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Welcome to  Knights Of Glory-TDM server\nEnjoy your stay and have Fun , our Website: {FFFFFF}www.KoG.Xobor.de","Ok","");
                        }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    new targetid;
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid,  PlayerInfo[playerid][pScore]);
                    PlayerInfo[targetid][pAdmin] = PlayerInfo[playerid][pAdmin];
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                 }
                return 1;
            }
        }
    }
    return 1;
}
Reply
#4

pawn Код:
PlayerInfo[targetid][pAdmin] = PlayerInfo[playerid][pAdmin];
pawn Код:
INI_WriteInt(File,"AdminLevel",0);
Reply
#5

not work
Reply
#6

Reset the variable PlayerInfo[playerid][pAdmin] on OnPlayerConnect:

Like that:
pawn Код:
//OnPlayerConnect

PlayerInfo[playerid][pAdmin] = 0;

// You may also reset other variables so they do not occur problem in future.
Then their data (or values 0, 1, or any) are loaded using INI_ParseFile(...) and your LoadUser_data forward.
Reply
#7

Yeah done ; Thank you so mush SyntaxQ
come to our server i will give you lvl there 176.31.103.65:7840
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)