Saving/Loading Player's Health -
danish007 - 04.02.2015
Hello, i've made a saving/loading health for my server but it does load 100 hp! even i checked there is no any function added in my server which loadfs full hp or setplayerhealth(playerid, 100);
so doest not save porperly and loadproperly...
its saving is;
saving code;
pawn Код:
new string[128];
GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
format(string, sizeof(string), "%.0f",PlayerInfo[playerid][pHealth]);
PlayerInfo[playerid][pHealth] = strval(string);
new INI:File = INI_Open(UserPath(playerid));
INI_WriteFloat(File, "LvHealth",PlayerInfo[playerid][pHealth]);
INI_Close(File);
Loading code;
pawn Код:
INI_Float("LvHealth",PlayerInfo[playerid][pHealth]);
setting saved health..... used under onplayerspawn
pawn Код:
SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
it does not load saved health it just load full hp!
Re: Saving/Loading Player's Health -
ATGOggy - 04.02.2015
Try this:
pawn Код:
GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
new INI:File = INI_Open(UserPath(playerid));
INI_WriteFloat(File, "LvHealth",PlayerInfo[playerid][pHealth]);
INI_Close(File);
Re: Saving/Loading Player's Health -
MarcGonzales - 04.02.2015
%.000000f
Try it like this
Re: Saving/Loading Player's Health -
Vince - 04.02.2015
I'm assuming that this is in OnPlayerDisconnect. However GetPlayer(Pos/Health/Ip/...) functions do not work in OnPlayerDisconnect because those functions request information from the client, which is already disconnected at that point so there is nothing to get.
Also .. uhm:
pawn Код:
format(string, sizeof(string), "%.0f",PlayerInfo[playerid][pHealth]);
PlayerInfo[playerid][pHealth] = strval(string);
![Huh?](images/smilies/confused.gif)
What the hell is this?
Re: Saving/Loading Player's Health -
danish007 - 04.02.2015
so what is the solution for this?
Re: Saving/Loading Player's Health -
ATGOggy - 04.02.2015
Quote:
Originally Posted by danish007
so what is the solution for this?
|
Did you try any of the solution we gave?
Re: Saving/Loading Player's Health -
danish007 - 04.02.2015
your solution save save correct. but it load full health even i type half health in .ini file.
and i checked there is no any function used in my script setting player's health = 100
Re: Saving/Loading Player's Health -
danish007 - 04.02.2015
please help!
Re: Saving/Loading Player's Health -
danish007 - 04.02.2015
helppp please//
Re: Saving/Loading Player's Health -
danish007 - 05.02.2015
bump?