Tag mismatch, why? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Tag mismatch, why? (
/showthread.php?tid=353981)
Tag mismatch, why? -
V1ceC1ty - 25.06.2012
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;
}
Re: Tag mismatch, why? -
Grand_Micha - 25.06.2012
Because score and money are no floats. Use dini_Int.
Re: Tag mismatch, why? -
JaKe Elite - 25.06.2012
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));
Re: Tag mismatch, why? -
V1ceC1ty - 25.06.2012
I had them set to Int before but it saves to the file 0 every time, not sure why.
Re: Tag mismatch, why? -
newbienoob - 25.06.2012
Show me your OnPlayerDisconnect
Re: Tag mismatch, why? -
V1ceC1ty - 25.06.2012
Код:
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;
}
Re: Tag mismatch, why? -
DiDok - 25.06.2012
Код:
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;
}
Re: Tag mismatch, why? -
V1ceC1ty - 25.06.2012
Thanks DiDok! I always get things as simple as that mixed up