How do i save health in file?
#2

The functions GetPlayerHealth and SetPlayerHealth don't return the values, they store them in the second argument you pass into the function, in this case it is "health" and "armour", so that is what you should be writing to the files.

Also for your information, they are floats, not integers.

Example:

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new Float:health, Float:armour, Name[MAX_PLAYER_NAME], File[256];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(File, sizeof(File), PFile, Name);
    if(PInfo[playerid][Logged] == 1)
    {
        GetPlayerHealth(playerid,health); // Store the players health in the float "health"
        GetPlayerArmour(playerid, armour); // Store the players armour in the float "armour"
        dini_FloatSet(File, "Health", health); // Set the float in the file to the value of the float "health"
        dini_FloatSet(File, "Armour", armour); // Set the float in the file to the value of the float "armour"
        return 1; // Also this return is pointless.
    }
    return 1;
}
Hope that helps.
Reply


Messages In This Thread
How do i save health in file? - by wilko1995 - 03.05.2012, 13:37
Re: How do i save health in file? - by JaTochNietDan - 03.05.2012, 13:40
Re: How do i save health in file? - by wilko1995 - 03.05.2012, 13:47

Forum Jump:


Users browsing this thread: 1 Guest(s)