Data Saving problem
#1

hi guys i use a INC File Saving System to save players data it works fix for 1 day but on the 2nd day it don't save players data please help me.
here is my Load User_data
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("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("WantedLevel",PlayerInfo[playerid][pWantedLevel]);
    INI_Int("Vip",PlayerInfo[playerid][pVip]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    INI_Int("Condoms",PlayerInfo[playerid][pCondoms]);
    INI_Int("Banned",PlayerInfo[playerid][pBanned]);
    INI_Int("Jailed",PlayerInfo[playerid][pJailed]);
    INI_Int("Drugs",PlayerInfo[playerid][pDrug]);
    INI_Int("Nopm",PlayerInfo[playerid][pNopm]);
    INI_Int("Bank",PlayerInfo[playerid][pBank]);
    INI_Int("Sausages",PlayerInfo[playerid][pSausage]);
    INI_Int("PassChange",PlayerInfo[playerid][pPassChange]);
    INI_Int("Mute",PlayerInfo[playerid][pMuted]);
    return 1;
}
Reply
#2

That doesn't explain anything.

1. Show us how you're saving the data.
2. Do you save it under OnPlayerDisconnect and OnGameModeExit ?
3. Do you have 'stock SavePlayer(playerid)' and 'stock ResetPlayer(playerid)' ?
4. Show us your 'INI_ParseFile' line.
Reply
#3

I Am Having Saveplayer(playerid)here is it
Code:
stock SavePlayer(playerid)
{
    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,"WantedLevel",GetPlayerWantedLevel(playerid));
    INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Condoms",PlayerInfo[playerid][pCondoms]);
    INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
    INI_WriteInt(File,"Jailed",PlayerInfo[playerid][pJailed]);
    INI_WriteInt(File,"Drugs",PlayerInfo[playerid][pDrug]);
    INI_WriteInt(File,"Nopm",PlayerInfo[playerid][pNopm]);
    INI_WriteInt(File,"Bank",PlayerInfo[playerid][pBank]);
    INI_WriteInt(File,"Sausages",PlayerInfo[playerid][pSausage]);
    INI_WriteInt(File,"PassChange",PlayerInfo[playerid][pPassChange]);
    INI_WriteInt(File,"Mute",PlayerInfo[playerid][pMuted]);
    INI_Close(File);
}
i think i am saving it under both OnPlayerDisconnect and OnGameModeExit Here is it
onplayerdisconnect
Code:
public OnPlayerDisconnect(playerid, reason)
{
    SendDeathMessage(INVALID_PLAYER_ID,playerid,201);
	new leaveMsg[128], name[MAX_PLAYER_NAME], reasonMsg[8];
	switch(reason)
	{
		case 0: reasonMsg = "Timeout";
		case 1: reasonMsg = "Leaving";
		case 2: reasonMsg = "Kicked";
	}
	GetPlayerName(playerid, name, sizeof(name));
	format(leaveMsg, sizeof(leaveMsg), "4[%d] 03*** %s has left the server. (%s)", playerid, name, reasonMsg);
	IRC_GroupSay(gGroupID, IRC_CHANNEL, leaveMsg);

    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,"WantedLevel",GetPlayerWantedLevel(playerid));
    INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Condoms",PlayerInfo[playerid][pCondoms]);
    INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
    INI_WriteInt(File,"Jailed",PlayerInfo[playerid][pJailed]);
    INI_WriteInt(File,"Drugs",PlayerInfo[playerid][pDrug]);
    INI_WriteInt(File,"Nopm",PlayerInfo[playerid][pNopm]);
    INI_WriteInt(File,"Bank",PlayerInfo[playerid][pBank]);
    INI_WriteInt(File,"Sausages",PlayerInfo[playerid][pSausage]);
    INI_WriteInt(File,"PassChange",PlayerInfo[playerid][pPassChange]);
    INI_WriteInt(File,"Mute",PlayerInfo[playerid][pMuted]);
    INI_Close(File);

    if(ireconnect[playerid] == 1)
    {
            new unbanningip[16], string[128];
            GetPVarString(playerid, "reconnect", unbanningip, 16);
            format(string,sizeof(string),"unbanip %s", unbanningip);
            SendRconCommand(string);
            printf(string);
            SendRconCommand("reloadbans");
            ireconnect[playerid] = 0;
    }
   	TextDrawDestroy(LocationTD[playerid]);
	return 1;
}
OnGameModeExit
Code:
public OnGameModeExit()
{
   	IRC_Quit(gBotID[0], "Bot exiting");
	IRC_Quit(gBotID[1], "Bot exiting");
	IRC_Quit(gBotID[2], "Bot exiting");
	IRC_Quit(gBotID[3], "Bot exiting");
    IRC_Quit(gBotID[4], "Bot exiting");

	IRC_DestroyGroup(gGroupID);

	for(new i=0;i<MAX_PLAYERS;i++)
    {
    new INI:File = INI_Open(UserPath(i));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(i));
    INI_WriteInt(File,"Admin",PlayerInfo[i][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[i][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[i][pDeaths]);
    INI_WriteInt(File,"WantedLevel",GetPlayerWantedLevel(i));
    INI_WriteInt(File,"Vip",PlayerInfo[i][pVip]);
    INI_WriteInt(File,"Score",GetPlayerScore(i));
    INI_WriteInt(File,"Condoms",PlayerInfo[i][pCondoms]);
    INI_WriteInt(File,"Banned",PlayerInfo[i][pBanned]);
    INI_WriteInt(File,"Jailed",PlayerInfo[i][pJailed]);
    INI_WriteInt(File,"Drugs",PlayerInfo[i][pDrug]);
    INI_WriteInt(File,"Nopm",PlayerInfo[i][pNopm]);
    INI_WriteInt(File,"Bank",PlayerInfo[i][pBank]);
    INI_WriteInt(File,"Sausages",PlayerInfo[i][pSausage]);
    INI_WriteInt(File,"PassChange",PlayerInfo[i][pPassChange]);
    INI_WriteInt(File,"Mute",PlayerInfo[i][pMuted]);
    INI_Close(File);
   	TextDrawHideForPlayer(i,WantedLvlTxd[i]);
	TextDrawHideForPlayer(i,DollarTxd);
	TextDrawHideForPlayer(i,DrugTxd[i]);
    }

    TextDrawHideForAll(CopsRules0);
	TextDrawDestroy(CopsRules0);
	TextDrawHideForAll(CopsRules1);
	TextDrawDestroy(CopsRules1);
	TextDrawHideForAll(CopsRules2);
	TextDrawDestroy(CopsRules2);
	TextDrawHideForAll(CopsRules3);
	TextDrawDestroy(CopsRules3);
	TextDrawHideForAll(CopsRules4);
	TextDrawDestroy(CopsRules4);
	return 1;
}
Here is my INI_ParseFile' line.I have Highlighted INI_ParseFile in code
Code:
public OnPlayerConnect(playerid)
{
    Rules(playerid);

   	if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"{FFFF00}Billu Gang {0066FF}C{FFFFFF}N{FF0033}R {FFFF00}Login",""COL_WHITE"{99FF00}This user name appears to be registered.\nIf it's your account type the password below for login.\nIf not then change your user name .","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"{FFFF00}Billu Gang {0066FF}C{FFFFFF}N{FF0033}R {FFFF00}Registration","{99FF00}We have found that this user name is not registered.\nKindly type a password below for registering your account.\nWe promise that your password will remain safe.","Register","Quit");
    }

        new ConnIP[16];
        GetPlayerIp(playerid,ConnIP,16);
        new compare_IP[16];
        new number_IP = 0;
        for(new i=0; i<MAX_PLAYERS; i++) {
                if(IsPlayerConnected(i)) {
                    GetPlayerIp(i,compare_IP,16);
                    if(!strcmp(compare_IP,ConnIP)) number_IP++;
                }
        }
        if((GetTickCount() - Join_Stamp) < Time_Limit)
            exceed=1;
        else
            exceed=0;
        if(strcmp(ban_s, ConnIP, false) == 0 && exceed == 1 )
        {
            Same_IP++;
            if(Same_IP > SAME_IP_CONNECT)
            {
                        Ban(playerid);
                        Same_IP=0;
            }
        }
        else
        {
                Same_IP=0;
        }
        if(number_IP > IP_LIMIT)
        Ban(playerid);
        GetStampIP(playerid);

    new joinMsg[128], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(joinMsg, sizeof(joinMsg), "4[%d] 03*** %s has joined the server.", playerid, name);
	IRC_GroupSay(gGroupID, IRC_CHANNEL, joinMsg);

    TextDrawShowForPlayer(playerid, WantedLvlTxd[playerid]);
    TextDrawShowForPlayer(playerid, DrugTxd[playerid]);
	TextDrawShowForPlayer(playerid, DrugTxd[playerid]);

	LocationTD[playerid] = TextDrawCreate(8.000000, 430.000000, "_");
	TextDrawBackgroundColor(LocationTD[playerid], 255);
	TextDrawFont(LocationTD[playerid], 2);
	TextDrawLetterSize(LocationTD[playerid], 0.400000, 1.000000);
	TextDrawColor(LocationTD[playerid], -1);
	TextDrawSetOutline(LocationTD[playerid], 1);
	TextDrawSetProportional(LocationTD[playerid], 1);
	TextDrawUseBox(LocationTD[playerid], 1);
	TextDrawBoxColor(LocationTD[playerid], 80);
	TextDrawTextSize(LocationTD[playerid], 222.000000, 18.000000);

	XDeaths[playerid] = 0;
    LastDeath[playerid] = 0;
    IsRobbing[playerid] =0;
	IsBankRobbing[playerid] =0;
	IsApRobbing[playerid] =0;
	zoneupdates[playerid] =1;

	DescriptionText[playerid] = TextDrawCreate(320.0, 380.0, " ");
    TextDrawAlignment(DescriptionText[playerid], 2);
    TextDrawFont(DescriptionText[playerid], 1);
    TextDrawLetterSize(DescriptionText[playerid], 0.320000, 1.700000);
    TextDrawSetOutline(DescriptionText[playerid], 1);
    TextDrawHideForPlayer(playerid, DescriptionText[playerid]);

	new string[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    new plrIP[16];
    GetPlayerIp(playerid, plrIP, sizeof(plrIP));
    format(string,sizeof string,"%s has joined the server with the ip %s",pName,plrIP);
    JoinsLog(string);

	for( new i = 0; i <= 50; i ++ ) SendClientMessage(playerid,COLOR_WHITE, "" );
	SendClientMessage(playerid, COLOR_WHITE, "{33FF00}Welcome to {FFFF00}Billu Gang {0066FF}Cops{FFFFFF}&{FF0033}Robbers.{CC00FF}Version 1.1.");
	SendClientMessage(playerid, COLOR_WHITE, "{33CC00}Be sure to check {FF0033}/rules {33CC00}and {FF0033}/cmds.");
    SendClientMessage(playerid, COLOR_WHITE, "{33CC66}Type {FF0033}/help {33CC66}if you need help about the server.Or visit {FF00FF}www.cod8aw.tk {33CC66}for game-info. ");
    SendClientMessage(playerid, COLOR_WHITE, "{FF0000}Warning!{00FFFF} This server contains {FF0000}Explicit Material.");
    for(new i;i<sizeof(Coords);i++) SetPlayerMapIcon(playerid,i,Coords[i][X],Coords[i][Y],Coords[i][Z],Coords[i][ID],0,MAPICON_LOCAL);
	return 1;
}
Reply
#4

1. At OnPlayerDisconnect and OnGameModeExit just use SavePlayer(i); instead of pasting the whole code.

2. Make a stock just like 'SavePlayer', but named 'ResetPlayer' - where you set all variables of the player to 0;

2.1 Have in mind you should use ResetPlayer(playerid); once a player registers and when they leave the server, so their stats wont mix up with other players once they join!

2.2 My example of "ResetPlayer":
Code:
stock ResetPlayer(playerid)
{
    PlayerInfo[playerid][pCash] = 0;
    PlayerInfo[playerid][pAdmin] = 0;
    PlayerInfo[playerid][pKills] = 0;
    PlayerInfo[playerid][pDeaths] = 0;
    PlayerInfo[playerid][pWantedLevel] = 0;
    PlayerInfo[playerid][pVip] = 0;
    PlayerInfo[playerid][pScore] = 0;
    PlayerInfo[playerid][pCondoms] = 0;

    //... add more here and ALWAYS use this AFTER SavePlayer(playerid);
    return 1;
}
3. Replace your INI_ParseFile with this one:
Code:
INI_ParseFile(UserPath(playerid), "LoadUser_user", .bExtra = true, .extra = playerid, .bPassTag = true);
Reply
#5

Don't abuse of stock function. You don't need stock here. Remove it. Check this.
The problem is, it doesn't save or it doesn't load ? You have to be sure where come from the problem.
Reply
#6

Not a big deal, pal.

Code:
ResetPlayer(playerid)
{
    PlayerInfo[playerid][pCash] = 0;
    PlayerInfo[playerid][pAdmin] = 0;
    PlayerInfo[playerid][pKills] = 0;
    PlayerInfo[playerid][pDeaths] = 0;
    PlayerInfo[playerid][pWantedLevel] = 0;
    PlayerInfo[playerid][pVip] = 0;
    PlayerInfo[playerid][pScore] = 0;
    PlayerInfo[playerid][pCondoms] = 0;

    //... add more here and ALWAYS use this AFTER SavePlayer(playerid);
    return 1;
}
Still, it doesn't do any harm, don't take it too serious just because someone created a topic about it, stay cool.
Reply
#7

Ok This i have to add
Reply
#8

Please Connect To My Pc 1nspire
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)