SA-MP Forums Archive
Health and Armour Save Problem - 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: Health and Armour Save Problem (/showthread.php?tid=424821)



Health and Armour Save Problem - Kinto99 - 23.03.2013

Hi!

I have a small problem with my health and armour save system. The saved file looks like this:

Код:
HealthSave = 1
ArmourSave = 1
Even if I don't wear a armour on the server. (Armour = 1)

My save code:

Код:
new
    HealthSave[ MAX_PLAYERS ],
    ArmourSave[ MAX_PLAYERS ]
;
Load:

Код:
public load_user_position( playerid, name[], value[] )
{
    INI_Float( "PositionX", PosX[ playerid ] );
    INI_Float( "PositionY", PosY[ playerid ] );
    INI_Float( "PositionZ", PosZ[ playerid ] );
    INI_Float( "Angle", Angle[ playerid ] );
    INI_Int( "Interior", Interior[ playerid ] );
    INI_Int( "VirtualWorld", VirtualWorld[ playerid ] );
    INI_Int( "Skin", Skin[ playerid ] );
    INI_Int( "HealthSave", HealthSave[ playerid ] );
    INI_Int( "ArmourSave", ArmourSave[ playerid ] );
    return ( 1 );
}
Disconnect:

Код:
GetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
GetPlayerFacingAngle( playerid, Angle[ playerid ] );
GetPlayerHealth(playerid,hp);
GetPlayerArmour(playerid,arm);

new INI:File = INI_Open( user_ini_file( playerid ) );
INI_SetTag( File, "position" );
INI_WriteFloat( File, "PositionX", PosX[ playerid ] );
INI_WriteFloat( File, "PositionY", PosY[ playerid ] );
INI_WriteFloat( File, "PositionZ", PosZ[ playerid ] );
INI_WriteFloat( File, "Angle", Angle[ playerid ] );
INI_WriteInt( File, "Interior", GetPlayerInterior( playerid ) );
INI_WriteInt( File, "VirtualWorld", GetPlayerVirtualWorld( playerid ) );
INI_WriteInt( File, "Skin", GetPlayerSkin( playerid ) );
INI_WriteInt( File, "HealthSave", GetPlayerHealth(playerid,hp) );
INI_WriteInt( File, "ArmourSave", GetPlayerArmour(playerid, arm) );
INI_Close( File );
Read:

Код:
if ( PosX[ playerid ] != 0 && PosY[ playerid ] != 0 && PosZ[ playerid ] != 0 && Angle[ playerid ] != 0 )
    {
    SetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
    SetPlayerFacingAngle( playerid, Angle[ playerid ] );
    SetPlayerInterior( playerid, Interior[ playerid ] );
    SetPlayerVirtualWorld( playerid, VirtualWorld[ playerid ] );
    SetPlayerSkin( playerid, Skin[ playerid ] );
    if(HealthSave[ playerid ] > 5)
	{
    SetPlayerHealth( playerid, HealthSave[ playerid ] );
    }
    else
    {
    SetPlayerHealth(playerid, 65);
    }
    SetPlayerArmour( playerid, ArmourSave[ playerid ] );
    }
What am I doing wrong?


Re: Health and Armour Save Problem - Kinto99 - 24.03.2013

Refresh - F5


Re: Health and Armour Save Problem - JhnzRep - 24.03.2013

pawn Код:
INI_WriteFloat( File, "HealthSave", GetPlayerHealth(playerid,hp) );
INI_WriteFloat( File, "ArmourSave", GetPlayerArmour(playerid, arm)
pawn Код:
new
    Float:HealthSave[ MAX_PLAYERS ],
    Float:ArmourSave[ MAX_PLAYERS ]
;
pawn Код:
public load_user_position( playerid, name[], value[] )
{
    INI_Float( "PositionX", PosX[ playerid ] );
    INI_Float( "PositionY", PosY[ playerid ] );
    INI_Float( "PositionZ", PosZ[ playerid ] );
    INI_Float( "Angle", Angle[ playerid ] );
    INI_Int( "Interior", Interior[ playerid ] );
    INI_Int( "VirtualWorld", VirtualWorld[ playerid ] );
    INI_Int( "Skin", Skin[ playerid ] );
    INI_Float( "HealthSave", HealthSave[ playerid ] );
    INI_Float( "ArmourSave", ArmourSave[ playerid ] );
    return ( 1 );
}
Health and armour are floats, I think this could fix it.


Re: Health and Armour Save Problem - Kinto99 - 25.03.2013

Now:

Код:
HealthSave = 1.000000
ArmourSave = 1.000000



Re: Health and Armour Save Problem - Kinto99 - 26.03.2013

f5 - refresh


Re: Health and Armour Save Problem - Riddick94 - 26.03.2013

pawn Код:
INI_WriteFloat( File, "HealthSave", GetPlayerHealth(playerid,hp) );
INI_WriteFloat( File, "ArmourSave", GetPlayerArmour(playerid, arm)
These are wrong.

pawn Код:
new Float:hp, Float:arm;
GetPlayerHealth(playerid, hp);
GetPlayerArmour(playerid, arm);

INI_WriteFloat( File, "HealthSave", hp );
INI_WriteFloat( File, "ArmourSave", arm );



Re: Health and Armour Save Problem - Kinto99 - 27.03.2013

PL: Hmm.. nie wiedziałem, że wartość hp należy pobrać przed przypisaniem. Skiny i światy działają prawidłowo no, ale cуż... Dzięki wielkie

+Rep
Problem solved.