help quick
#1

Im making a score save system with Dini, when I log in and get score then log out it saves, but when I log in again it doesnt load the score... whats the code to do this, This is my OnPlayerConnect
Код:
public OnPlayerConnect(playerid)
{
	new string[128];
	new plname[MAX_PLAYER_NAME];
	GetPlayerName(playerid, plname, sizeof(plname));
	PlayerInfo[playerid][Level] = 0;
	PlayerInfo[playerid][Money] = 0;
	PlayerInfo[playerid][Vip] = 0;
	PlayerInfo[playerid][Admin] = 0;
	PlayerInfo[playerid][Spawn] = 0;
	PlayerInfo[playerid][Score] = 0;
	format(string, sizeof(string), "/accounts/%s.ini", plname);
	if(dini_Exists(string))
	{
		gPlayerAccount[playerid] = 1;

	}
	else

	{
		gPlayerAccount[playerid] = 0;

	}
	return 1;
}
OnPlayerDisconnect
Код:
public OnPlayerDisconnect(playerid, reason)
{
	new file[128];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(file,sizeof(file),"/accounts/%s.ini",name);
	if(dini_Exists(file))

	{
		dini_IntSet(file, "Password",PlayerInfo[playerid][Pass]);
		dini_IntSet(file, "Level",PlayerInfo[playerid][Level]);
		dini_IntSet(file, "Money",PlayerInfo[playerid][Money]);
		dini_IntSet(file, "Admin",PlayerInfo[playerid][Admin]);
		dini_IntSet(file, "Vip",PlayerInfo[playerid][Vip]);
		dini_IntSet(file, "Spawn",PlayerInfo[playerid][Spawn]);
		dini_IntSet(file, "Score", GetPlayerScore(playerid));

	}
	gPlayerLogged[playerid] = 0;
	return 1;
}
Reply
#2

You set the score to be 0 without checking if the player is unregistered first.

pawn Код:
public OnPlayerConnect(playerid)
{
    new string[128];
    new plname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, plname, sizeof(plname));
    format(string, sizeof(string), "/accounts/%s.ini", plname);
    if(dini_Exists(string))
    {
        gPlayerAccount[playerid] = 1;

    }
    else

    {
        gPlayerAccount[playerid] = 0;
        PlayerInfo[playerid][Level] = 0;
        PlayerInfo[playerid][Money] = 0;
        PlayerInfo[playerid][Vip] = 0;
        PlayerInfo[playerid][Admin] = 0;
        PlayerInfo[playerid][Spawn] = 0;
        PlayerInfo[playerid][Score] = 0;
    }
    return 1;
}
Try this ^
Reply
#3

Dsnt work, when I got some score then logged out, this is what my .ini file looked like...
Код:
Password=257753960
Money=0
Admin=10
Vip=0
Spawn=0
Level=0
Score=15
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)