SA-MP Forums Archive
Saving/Loading Player's Health - 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: Saving/Loading Player's Health (/showthread.php?tid=561672)



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;
pawn Код:
LvHealth = 100.000000
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);
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?