need help with my login system
#1

Ok im making a dm server but when ever i set my admin rank it saves until the user leaves the server and reconnect the user is no longer an admin. And only the admin level will reset, all other statistics or saved, but admin level keep resetting when ever the player leaves the server. For example i set my self to level 7 serverowner and when i reconnect to the server and check /admins command or try to use an admin command it says im not allowed, And when i check /admins my name not on list.
pawn Код:
//onplayerdisconnect
public OnPlayerDisconnect(playerid, reason)
{
    new INI:ACCOUNT = INI_Open(UserPath(playerid));
    INI_SetTag(ACCOUNT,"data");
    INI_WriteInt(ACCOUNT,"Level",pInfo[playerid][aAdmin]);
    INI_WriteInt(ACCOUNT,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(ACCOUNT,"Kills",pInfo[playerid][Kills]);
    INI_WriteInt(ACCOUNT,"Deaths",pInfo[playerid][Deaths]);
    INI_WriteInt(ACCOUNT, "Banned",pInfo[playerid][Banned]);
    INI_WriteInt(ACCOUNT, "Donator",pInfo[playerid][Donator]);
    INI_WriteInt(ACCOUNT, "Score", pInfo[playerid][Score]);
    INI_WriteInt(ACCOUNT, "Skin", pInfo[playerid][Skin]);
    INI_WriteInt(ACCOUNT, "Muted",pInfo[playerid][Muted]);
    INI_Close(ACCOUNT);

    return 1;
}
pawn Код:
//onplayerdialogresponse
//my login dialog
 case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == pInfo[playerid][Pass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in to your Account!","Ok","");
                    SetPlayerScore(playerid, pInfo[playerid][Score]);
                    GivePlayerMoney(playerid, pInfo[playerid][Cash]);
                }
                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");

                    pInfo[playerid][LoginAttempts]++;
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Account Login error",astring, "Login", "Quit");
                    if(pInfo[playerid][LoginAttempts] >= MAX_LOGIN_ATTEMPTS)
                    {
                        format(astring, sizeof(astring),"%s has been automatically kicked | Reason: 'Incorrect password login attempts [3/3]'", GetName(playerid));
                        SendToAdmins(orange,astring);
                        ShowPlayerDialog(playerid,ACCKICK, DIALOG_STYLE_MSGBOX, "Kicked","You have been automatically kicked | Reason: 'Incorrect password login attempts [3/3]. \n Take a screen shot of this message and post on our forums if you think this in a mistake.\nOur forums: ******.com'", "Ok", "");
                        SetTimerEx("KickPlayer",100,false,"d",playerid);
                        return 1;
                    }
                    format(astring, sizeof(astring),"Account \"%s\"\nEnter your password to login\n{FF0000}*Incorrect password", GetName(playerid));
                    }
                }
            return 1;
            }
        }
    return 1;
}
pawn Код:
//my register dialog
 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:ACCOUNT = INI_Open(UserPath(playerid));
                INI_SetTag(ACCOUNT,"data");
                INI_WriteInt(ACCOUNT,"Password",udb_hash(inputtext));
                INI_WriteInt(ACCOUNT, "Level", 0);
                INI_WriteInt(ACCOUNT, "Banned", 0);
                INI_WriteInt(ACCOUNT, "Donator", 0);
                INI_WriteInt(ACCOUNT, "Score", SCORE);
                INI_WriteInt(ACCOUNT, "Cash", CASH);
                INI_WriteInt(ACCOUNT, "Kills", 0);
                INI_WriteInt(ACCOUNT, "Deaths", 0);
                INI_WriteInt(ACCOUNT, "Skin", 0);
                INI_WriteInt(ACCOUNT, "Muted", 0);
                INI_Close(ACCOUNT);

                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Account has been Successfully Created in our Database. Enjoy your stay","Ok","");
            }
        }
N.B i taught the problem was with my resetvarieble code but i have move the admin level from it and it still giving an issue can someone help me please.

by the way i used this tutorial to make my login system all the time ,which this is a first im getting this problem

tutorial link: https://sampforum.blast.hk/showthread.php?tid=273088
Reply
#2

I'm always so happy to see when people try and make things by themselves or try to through a tutorial or something, way to go!

Can you show the function in which the user data is loaded into the variables? There might be missing something there. Also, can you verify that inside the .ini file, the value is actually set to something other than 0? So, set your admin level and log out, then open the ini file and check if the value is 0 or something else. That could rule out the possibility of an error in the saving function of the script.
Reply
#3

You mean it work perfectly, but it only save when someone disconnect?
Try to put this under the command to give level, its to load players account.
Код HTML:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
But remember to adapt the variable playerid to the player wich get the level, not to the player wich use the command.
Reply
#4

Quote:
Originally Posted by karoliko
Посмотреть сообщение
You mean it work perfectly, but it only save when someone disconnect?
From what I understand, his admin level is either not saved, or not loaded. When he sets his admin level, he doesn't get it back after logging out and then logging in again.

Also, why would he want to put that code there in the command? If he has variables that are not saved yet, he will simply overwrite them, and that will cause even more issues.. :\
Reply
#5

Post here the command to give admin level....
Reply
#6

Quote:
Originally Posted by karoliko
Посмотреть сообщение
Post here the command to give admin level....
pawn Код:
CMD:setlevel(playerid,params[])
{
   if(IsPlayerAdmin(playerid) || pInfo[playerid][aAdmin] >= 7)
   {
        new id,lvl,year,month,day,hour,minute,second;
        if(sscanf(params, "ui", id, lvl)) return
        SendClientMessage(playerid, 0xFFFF00C8, "Usage: /Setlevel <PlayerID> <Level>") ;
        if(lvl < 0) return SendClientMessage(playerid,red,"Invalid level(level must be greater than -1)");
        if(IsPlayerConnected(id))
        {
           if(lvl == pInfo[id][aAdmin])
           return SendClientMessage(playerid,red,"Player is already in this level!");
           if(lvl > 7)
           {
                format(astring,sizeof(astring),"Error: Maximum admin level is 7"); return SendClientMessage(playerid,red,astring);
           }
           CommandToAdmins(playerid,"setlevel");
           getdate(year, month, day);
           gettime(hour,minute,second);
           switch(lvl)
           {
              case 0: AdminRank ="Trial Administrator";
              case 1: AdminRank = "Moderator";
              case 2: AdminRank = "Junior Administrator";
              case 3: AdminRank = "Senior Administrator";
              case 4: AdminRank = "Head Administrator";
              case 5: AdminRank = "Master Administrator";
              default: AdminRank = "Head Of Staff/Server Owner";
           }
           format(astring,sizeof(astring),"You have given %s level: %d (%s) , Date: %d/%d/%d at %d:%d:%d",GetName(id), lvl, AdminRank, day, month, year ,hour, minute, second);
           SendClientMessage(playerid,blue,astring);
           if(lvl > pInfo[id][aAdmin])
           {
               format(astring,sizeof(astring),"Administrator %s has given you Administrator level: %d (%s) <Promoted on %d/%d/%d at %d:%d:%d>",GetName(playerid), lvl, AdminRank ,day, month, year,hour, minute, second),GameTextForPlayerEx(id,"~B~congratulations!~N~~G~Promoted", 2000, 3);
               SendClientMessage(id,yellow,astring);
               format(astring,sizeof(astring),"[PROMOTED] %s has changed %s's level from %d to %d (%s)",GetName(playerid),GetName(id),pInfo[id][aAdmin], lvl, AdminRank);
           }
           else
           {
           format(astring,sizeof(astring),"Administrator %s has set you level: %d <Demoted on %d/%d/%d at %d:%d:%d>",GetName(playerid), lvl,day, month, year,hour, minute, second),GameTextForPlayerEx(id,"~R~Demoted", 2000, 3);
           SendClientMessage(id,red,astring);
           format(astring,sizeof(astring),"[DEMOTED] %s has changed %s's level from %d to %d (%s)",GetName(playerid),GetName(id),pInfo[id][aAdmin], lvl, AdminRank);
           }
           pInfo[id][aAdmin] = lvl;
           return 1;
        }
        else return ShowMessage(playerid, red, 2);
   }
   else return ShowMessage(playerid, red, 1);
}
Reply
#7

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
I'm always so happy to see when people try and make things by themselves or try to through a tutorial or something, way to go!

Can you show the function in which the user data is loaded into the variables? There might be missing something there. Also, can you verify that inside the .ini file, the value is actually set to something other than 0? So, set your admin level and log out, then open the ini file and check if the value is 0 or something else. That could rule out the possibility of an error in the saving function of the script.
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",pInfo[playerid][Pass]);
    INI_Int("Cash",pInfo[playerid][Cash]);
    INI_Int("Admin",pInfo[playerid][aAdmin]);
    INI_Int("Kills",pInfo[playerid][Kills]);
    INI_Int("Deaths",pInfo[playerid][Deaths]);
    INI_Int("Muted", pInfo[playerid][Muted]);
    INI_Int("Score", pInfo[playerid][Score]);
    INI_Int("Banned", pInfo[playerid][Banned]);
    INI_Int("Donator", pInfo[playerid][Donator]);
    INI_Int("Skin", pInfo[playerid][Skin]);
    INI_String("LastLoggedIP", pInfo[playerid][IP], 16);
    INI_Int("TotalSeconds", pInfo[playerid][TotalSecs]);
    return 1;
}
Reply
#8

Код:
INI_Int("Admin",pInfo[playerid][aAdmin]);
In the saving code, you used "Level" instead of "Admin".
You did this:
Код:
INI_WriteInt(ACCOUNT,"Level",pInfo[playerid][aAdmin]);
Try changing the loading code for the admin value to
Код:
INI_Int("Level",pInfo[playerid][aAdmin]);
To clarify, it would now look like this

Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
	INI_Int("Password",pInfo[playerid][Pass]);
	INI_Int("Cash",pInfo[playerid][Cash]);
	INI_Int("Level",pInfo[playerid][aAdmin]); // <- changed that to "Level" just like the saving code
	INI_Int("Kills",pInfo[playerid][Kills]);
    INI_Int("Deaths",pInfo[playerid][Deaths]);
    INI_Int("Muted", pInfo[playerid][Muted]);
    INI_Int("Score", pInfo[playerid][Score]);
    INI_Int("Banned", pInfo[playerid][Banned]);
    INI_Int("Donator", pInfo[playerid][Donator]);
    INI_Int("Skin", pInfo[playerid][Skin]);
    INI_String("LastLoggedIP", pInfo[playerid][IP], 16);
    INI_Int("TotalSeconds", pInfo[playerid][TotalSecs]);
    return 1;
}
Reply
#9

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
Код:
INI_Int("Admin",pInfo[playerid][aAdmin]);
In the saving code, you used "Level" instead of "Admin".
You did this:
Код:
INI_WriteInt(ACCOUNT,"Level",pInfo[playerid][aAdmin]);
Try changing the loading code for the admin value to
Код:
INI_Int("Level",pInfo[playerid][aAdmin]);
To clarify, it would now look like this

Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
	INI_Int("Password",pInfo[playerid][Pass]);
	INI_Int("Cash",pInfo[playerid][Cash]);
	INI_Int("Level",pInfo[playerid][aAdmin]); // <- changed that to "Level" just like the saving code
	INI_Int("Kills",pInfo[playerid][Kills]);
    INI_Int("Deaths",pInfo[playerid][Deaths]);
    INI_Int("Muted", pInfo[playerid][Muted]);
    INI_Int("Score", pInfo[playerid][Score]);
    INI_Int("Banned", pInfo[playerid][Banned]);
    INI_Int("Donator", pInfo[playerid][Donator]);
    INI_Int("Skin", pInfo[playerid][Skin]);
    INI_String("LastLoggedIP", pInfo[playerid][IP], 16);
    INI_Int("TotalSeconds", pInfo[playerid][TotalSecs]);
    return 1;
}
Thank you very much for your help buddy rep+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)