Getplayerhealth + armour - tag mismatch? -
[GTA] - 01.12.2010
new Float:PlayersHealth;
GetPlayerHealth(playerid, PlayersHealth);
PlayerInfo[playerid][pHealth] = PlayersHealth; warning 213: tag mismatch
format(var, 32, "Health=%d\n",PlayerInfo[playerid][pHealth]);fwrite(hFile, var);
new Float:PlayersArmour;
GetPlayerArmour(playerid, PlayersArmour);
PlayerInfo[playerid][pArmour] = PlayersArmour; warning 213: tag mismatch
format(var, 32, "Armour=%d\n",PlayerInfo[playerid][pArmour]);fwrite(hFile, var);
Can anyone see why i'm getting this?
Re: Getplayerhealth + armour - tag mismatch? -
iggy1 - 01.12.2010
I'm guessing PlayerInfo[playerid][pHealth] isn't a float. Same with the armour one. Also whern your formating the string you used %d which is a placeholder for integer values (%f for floats). You would need to use "floatround" to round it to an integer.
Re: Getplayerhealth + armour - tag mismatch? -
Shadow™ - 01.12.2010
Armour is a float not a number. The correct usage of it would be
pawn Код:
format(var, 32, "Health=%f\n",PlayerInfo[playerid][pHealth]);fwrite(hFile, var)
format(var, 32, "Armour=%f\n",PlayerInfo[playerid][pArmour]);fwrite(hFile, var);
And you're best off using Dini, it's faster and easier.
Dini Version:
pawn Код:
dini_Float(string, "Health", PlayerInfo[playerid][pHealth]);
dini_Float(string, "Armour", PlayerInfo[playerid][pArmour]);
Re: Getplayerhealth + armour - tag mismatch? -
[GTA] - 01.12.2010
Okay i've changed it around a bit:
Код:
new PlayersHealth;
GetPlayerHealth(playerid, PlayersHealth);
PlayerInfo[playerid][pHealth] = PlayersHealth;
format(var, 32, "Health=%f\n",PlayerInfo[playerid][pHealth]);fwrite(hFile, var);
new PlayersArmour;
GetPlayerArmour(playerid, PlayersArmour);
PlayerInfo[playerid][pArmour] = PlayersArmour;
format(var, 32, "Armour=%f\n",PlayerInfo[playerid][pArmour]);fwrite(hFile, var);
There is still tag mismatches on the GetPlayerHealth & GetPlayerArmour lines..?
Re: Getplayerhealth + armour - tag mismatch? -
Shadow™ - 01.12.2010
pawn Код:
PlayerInfo[playerid][pHealth] = GetPlayerHealth(playerid,PlayersHealth);
PlayerInfo[playerid][pArmour] = GetPlayerArmour(playerid,PlayersArmour);
Re: Getplayerhealth + armour - tag mismatch? -
[GTA] - 01.12.2010
Quote:
Originally Posted by Shadow™
pawn Код:
PlayerInfo[playerid][pHealth] = GetPlayerHealth(playerid,PlayersHealth); PlayerInfo[playerid][pArmour] = GetPlayerArmour(playerid,PlayersArmour);
|
Код:
new PlayersHealth;
PlayerInfo[playerid][pHealth] = GetPlayerHealth(playerid,PlayersHealth);
format(var, 32, "Health=%f\n",PlayerInfo[playerid][pHealth]);fwrite(hFile, var);
new PlayersArmour;
PlayerInfo[playerid][pArmour] = GetPlayerArmour(playerid,PlayersArmour);
format(var, 32, "Armour=%f\n",PlayerInfo[playerid][pArmour]);fwrite(hFile, var);
tag mismatch on:
Код:
PlayerInfo[playerid][pHealth] = GetPlayerHealth(playerid,PlayersHealth);
PlayerInfo[playerid][pArmour] = GetPlayerArmour(playerid,PlayersArmour);
Re: Getplayerhealth + armour - tag mismatch? -
iggy1 - 01.12.2010
pawn Код:
GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
format(var, 32, "Health=%d\n",floatround(PlayerInfo[playerid][pHealth]));fwrite(hFile, var);
GetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
format(var, 32, "Armour=%d\n",floatround(PlayerInfo[playerid][pArmour]));fwrite(hFile, var);
Just to clarify "PlayerInfo[playerid][pHealth]" is a float? It must be. Show the code where you declare this variable.
GetPlayerHealth and Armour set the amount of armour into the variable that is passed to them.
pawn Код:
PlayerInfo[playerid][pHealth] = GetPlayerHealth(playerid,PlayersHealth);
Is pointless.
Re: Getplayerhealth + armour - tag mismatch? -
Shadow™ - 01.12.2010
pawn Код:
enum pInfo
{
Float:pHealth,
Float:pArmour
}
new PlayerInfo[MAX_PLAYERS][pInfo];
new Float:PlayersHealth, var[56], File:hFile;
PlayerInfo[playerid][pHealth] = GetPlayerHealth(playerid,PlayersHealth);
format(var, 32, "Health=%f\n",PlayerInfo[playerid][pHealth]);
fwrite(hFile, var);
new Float:PlayersArmour;
PlayerInfo[playerid][pArmour] = GetPlayerArmour(playerid,PlayersArmour);
format(var, 32, "Armour=%f\n",PlayerInfo[playerid][pArmour]);
fwrite(hFile, var);
Quote:
Originally Posted by ******
That is completely wrong - dini can not possibly be faster than custom writes, in fact it is one of the slowest file systems there are.
|
And I was under the impression that Dini was faster?
Re: Getplayerhealth + armour - tag mismatch? -
[GTA] - 01.12.2010
Quote:
Originally Posted by Shadow™
pawn Код:
enum pInfo { Float:pHealth, Float:pArmour } new PlayerInfo[MAX_PLAYERS][pInfo];
new Float:PlayersHealth, var[56], File:hFile; PlayerInfo[playerid][pHealth] = GetPlayerHealth(playerid,PlayersHealth); format(var, 32, "Health=%f\n",PlayerInfo[playerid][pHealth]); fwrite(hFile, var);
new Float:PlayersArmour; PlayerInfo[playerid][pArmour] = GetPlayerArmour(playerid,PlayersArmour); format(var, 32, "Armour=%f\n",PlayerInfo[playerid][pArmour]); fwrite(hFile, var);
|
Thanks a lot guys!
Quote:
Originally Posted by iggy1
LOL put it in OnPlayerDisconect. Why on earth put that in OnPlayerUpdate when theres a callback specificaly called when a player disconnects?
This forum requires that you wait 120 seconds between posts. Please try again in 34 seconds.
|
Код:
public OnPlayerDisconnect(playerid, reason)
{
OnPlayerUpdate(playerid);
return 1;
}
Re: Getplayerhealth + armour - tag mismatch? -
iggy1 - 01.12.2010
Yes but even though you call it in OnPlayerDisconnect, the actual callback is still called serveral times per second for each player. (executing your code inside that callback unless you have a conditional statement) Meaning you format a string for each player 100s of times per second.