Saving/Loading Player's Health
#1

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

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

%.000000f
Try it like this
Reply
#4

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

so what is the solution for this?
Reply
#6

Quote:
Originally Posted by danish007
Посмотреть сообщение
so what is the solution for this?
Did you try any of the solution we gave?
Reply
#7

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

please help!
Reply
#9

helppp please//
Reply
#10

bump?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)