Y_Ini Not Saving Data..
#1

Hello,
I made Register And login System Today, It was going nice untill i saw scriptfiles....
i made myself administrator with makeadmin command (which was also made by myself) it worked fine but when i saw the file in scriptfiles it was something like admin = 0 password blah....
here is the actual code.
Code:
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Model",PlayerInfo[playerid][pModel]);
    INI_Int("Muted",PlayerInfo[playerid][pMuted]);
    INI_Int("Locked",PlayerInfo[playerid][pLocked]);
    INI_Int("Warns",PlayerInfo[playerid][pWarns]);
    INI_Int("Tester",PlayerInfo[playerid][pTester]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}
OnPlayerConnect Stuff.
Code:
if(fexist(UserPath(playerid)))
    {
    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Welcome To [DU]",""COL_WHITE"Type your password below to login.","Login","Quit");
    }
    else
    {
    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_WHITE"Welcome To [DU]",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
    }
OnPlayerDisconnect Stuff.
Code:
new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Locked",PlayerInfo[playerid][pLocked]);
    INI_WriteInt(File,"Warns",PlayerInfo[playerid][pWarns]);
    INI_Close(File);
OnDialogResponce..
Code:
switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Welcome To [DU]",""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,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                SCM(playerid, COLOR_GREEN, "You've Successfully Registered! And Has Been Auto-Matically Logged In!");
                        }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SCM(playerid, COLOR_GREEN, "You Have Successfully Logged In!!");
					SetSpawnInfo(playerid,0,164,-2380.1345,-578.2792,132.1117,123.4686,0,0,0,0,0,0);
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Welcome To [DU]",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
And here is the makeadmin command..
Code:
CMD:makeadmin(playerid, params[])
{
    new pID, value;
    if(PlayerInfo[playerid][pAdmin] < 5 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command.");
    else if (sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /makeadmin [playerid/partofname] [level 1-5].");
    else if (value < 0 || value > 5) return SendClientMessage(playerid, COLOR_RED, "Unknown level! Only 0 to 1338.");
    else if(pID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_RED,"Invalid player id.");
    else {
        new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(pID, tName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "You Have Promoted %s To Admin Level %i", tName, value);
        SCM(playerid, COLOR_GREEN, string);
        format(string, sizeof(string), "You Have Been Promoted To Admin Level %i By %s", value, pName);
        SCM(pID, COLOR_GREEN, string);
        PlayerInfo[pID][pAdmin] = value;
	}
    return 1;
}
Whats Wrong??
Reply
#2

Hello,
I mean the data is not being saved, for example, i'll go IG and type /makeadmin myself 5, after restart when i take a look at scriptfiles it's something like this.
Code:
[data]
Password = 313918402
Cash = 0
Admin = 0
Kills = 0
Deaths = 0
Locked = 0
Warns = 0
Even when i already made myself highest level administrator....
Reply
#3

Hello,
Yes, I've been logged in many times without any problem but can you please sort it out. And tell me what actually is wrong?
Reply
#4

Quote:
Originally Posted by Littlehelper[MDZ]
View Post
Hello,
I mean the data is not being saved, for example, i'll go IG and type /makeadmin myself 5, after restart when i take a look at scriptfiles it's something like this.
Code:
[data]
Password = 313918402
Cash = 0
Admin = 0
Kills = 0
Deaths = 0
Locked = 0
Warns = 0
Even when i already made myself highest level administrator....
Wait.. Do you mean relog by restart? Because if you're restarting the whole server, data won't save.
Reply
#5

Hello,
Okai.
[EXPLAINED]
Whenever i go IG and type /makeadmin id 5 it Says: you made %s level %i administrator, and i cannot even type any administration command, and when i take a look on scriptfiles its like admin = 0?
why is this happening?
Reply
#6

Did you disconnect to see the Data on the .ini file because if you didn't then it will not save it.
Also, if you close the samp-server.exe you will lost the data.
pawn Code:
public OnGameModeExit( )
{
    for( new i = 0; i < MAX_PLAYERS; i ++ ) OnPlayerDisconnect( i, 1 );
    return 1;
}
Reply
#7

Yes, data only gets saved on player disconnect. Don't expect it to be saved right after you use the command. The command only sets the variables.
Reply
#8

Hello,
But whenever i type /makeadmin myid any level it says you have been promoted to level 5, but when i check the data, level is the same as it was before...?
so what am i doing wrong? is there something wrong with register login system? (ofc its my first try..) or is it makeadmin command?
Reply
#9

Quote:
Originally Posted by ******
View Post
If you can't use any commands after using that command then you're not setting some variables correctly, so they're still 0 and thus saved as 0.
right and thats why i showed my whole code....
Reply
#10

I cannot use any other administration commands, only makeadmin since it needs rcon to work....
and here is the other command.
Code:
CMD:sethp(playerid, params[])
{
    new id, hp, sendername[MAX_PLAYER_NAME], string[128];
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED,"You are not authorized to use this command.");
    else if(sscanf(params,"ui", id, hp)) return SCM(playerid, COLOR_GREY,"USAGE: /sethp [playerid/partofname] [ammount]");
    else if(!IsPlayerConnected(id)) return SCM(playerid, COLOR_RED,"Invalid player ID.");
    else {
        SetPlayerHealth(id, hp);
        format(string, sizeof(string),"Your Health Has Been Set To %i By Administrator %s", hp, sendername);
        SendClientMessage(id, COLOR_GREEN, string);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)