Getplayerhealth + armour - tag mismatch?
#1

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?
Reply
#2

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.
Reply
#3

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]);
Reply
#4

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..?
Reply
#5

pawn Код:
PlayerInfo[playerid][pHealth] = GetPlayerHealth(playerid,PlayersHealth);
PlayerInfo[playerid][pArmour] = GetPlayerArmour(playerid,PlayersArmour);
Reply
#6

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);
Reply
#7

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.
Reply
#8

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?
Reply
#9

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;
}
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)