Tag mismatch, why?
#1

Why am I getting 2 tag mismatch warnings for this code? I need to save player score and cash but it saves as 0 In the file. The warnings are the lines SetPlayerScore(playerid, dini_Float(file, "score"));
GivePlayerMoney(playerid, dini_Float(file, "money")-GetPlayerMoney(playerid));


Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[128], pname[MAX_PLAYER_NAME];
  	GetPlayerName(playerid, pname, sizeof(pname));
  	format(file, sizeof(file), "/StatSave/%s.ini", pname);
	
	new Float:money; GetPlayerMoney(playerid);
	dini_FloatSet(file,"money", money);
	
	new Float:score; GetPlayerScore(playerid);
	dini_FloatSet(file,"score", score);
	
	return 1;
}

public OnPlayerSpawn(playerid)
{
    new file[128], pname[MAX_PLAYER_NAME];
  	GetPlayerName(playerid, pname, sizeof(pname));
  	format(file, sizeof(file), "/StatSave/%s.ini", pname);
    if(dini_Exists(file))
  	{
  	    SetPlayerScore(playerid, dini_Float(file, "score"));
    	    GivePlayerMoney(playerid, dini_Float(file, "money")-GetPlayerMoney(playerid));
	    return 1;
	}
    return 1;
}
Reply
#2

Because score and money are no floats. Use dini_Int.
Reply
#3

pawn Код:
new Float:money; GetPlayerMoney(playerid);
dini_FloatSet(file,"money", money);
   
new Float:score; GetPlayerScore(playerid);
dini_FloatSet(file,"score", score);
to

pawn Код:
new money; GetPlayerMoney(playerid);
dini_IntSet(file,"money", money);
   
new score; GetPlayerScore(playerid);
dini_IntSet(file,"score", score);
----------------

pawn Код:
SetPlayerScore(playerid, dini_Float(file, "score"));
GivePlayerMoney(playerid, dini_Float(file, "money")-GetPlayerMoney(playerid));
to

pawn Код:
SetPlayerScore(playerid, dini_Int(file, "score"));
GivePlayerMoney(playerid, dini_Int(file, "money")-GetPlayerMoney(playerid));
Reply
#4

I had them set to Int before but it saves to the file 0 every time, not sure why.
Reply
#5

Show me your OnPlayerDisconnect
Reply
#6

Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[128], pname[MAX_PLAYER_NAME];
  	GetPlayerName(playerid, pname, sizeof(pname));
  	format(file, sizeof(file), "/StatSave/%s.ini", pname);
	
	new money; GetPlayerMoney(playerid);
	dini_IntSet(file,"money", money);

	new score; GetPlayerScore(playerid);
	dini_IntSet(file,"score", score);
        return 1;
}
Reply
#7

Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[128], pname[MAX_PLAYER_NAME];
  	GetPlayerName(playerid, pname, sizeof(pname));
  	format(file, sizeof(file), "/StatSave/%s.ini", pname);
	
	new money = GetPlayerMoney(playerid);
	dini_IntSet(file,"money", money);

	new score = GetPlayerScore(playerid);
	dini_IntSet(file,"score", score);
        return 1;
}
Reply
#8

Thanks DiDok! I always get things as simple as that mixed up
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)