SA-MP Forums Archive
Health/Armour saving issue - 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/Armour saving issue (/showthread.php?tid=655132)



Health/Armour saving issue - Mike861 - 13.06.2018

So every time i join the server i keep on dying per every spawn.What could be the issue?
Under enum
Code:
Float:pHealth,
Float:pArmor
Under load user callback
Code:
INI_Float("Health",PlayerInfo[playerid][pHealth]);
INI_Float("Armour",PlayerInfo[playerid][pArmor]);
Under OnPlayerDisconnect
Code:
new Float:health = PlayerInfo[playerid][pHealth],Float:armor = PlayerInfo[playerid][pArmor];
GetPlayerHealth(playerid,health);
GetPlayerArmour(playerid,armor);
INI_WriteFloat(File,"Health", PlayerInfo[playerid][pHealth]);
INI_WriteFloat(File,"Armour", PlayerInfo[playerid][pArmor]);
Under OnPlayerSpawn for already registered players
Code:
SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
SetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);



Re: Health/Armour saving issue - Lokii - 13.06.2018

did u add INI_ParseFile??


Re: Health/Armour saving issue - xMoBi - 13.06.2018

print those values before you set them.


Re: Health/Armour saving issue - Mike861 - 13.06.2018

Quote:
Originally Posted by Lokii
View Post
did u add INI_ParseFile??
Nope


Re: Health/Armour saving issue - Lokii - 13.06.2018

thats why you die you dont load the data and the health enum = 0

add INI_ParseFile on top of OnPlayerSpawn


Re: Health/Armour saving issue - Mike861 - 13.06.2018

Quote:
Originally Posted by Lokii
View Post
thats why you die you dont load the data and the health enum = 0

add INI_ParseFile on top of OnPlayerSpawn
I did it this way but its still the same
Code:
INI_ParseFile("%s.ini", "LoadUser_Data", .bPassTag = true);



Re: Health/Armour saving issue - Lokii - 13.06.2018

Quote:
Originally Posted by Mike861
View Post
I did it this way but its still the same
Code:
INI_ParseFile("%s.ini", "LoadUser_Data", .bPassTag = true);
PHP Code:
new name[24], path[29];
GetPlayerName(playeridnamesizeof(name));
format(pathsizeof(path), "%s.ini"name);
INI_ParseFile(path"LoadUser_Data_%s", .bExtra true, .extra playerid); 



Re: Health/Armour saving issue - Mike861 - 14.06.2018

Quote:
Originally Posted by Lokii
View Post
PHP Code:
new name[24], path[29];
GetPlayerName(playeridnamesizeof(name));
format(pathsizeof(path), "%s.ini"name);
INI_ParseFile(path"LoadUser_Data_%s", .bExtra true, .extra playerid); 
Still the same


Re: Health/Armour saving issue - Exhibit - 14.06.2018

INI_ParseFile should be added on OnPlayerConnect considering you are also loading the password?

Are the values saving?


Re: Health/Armour saving issue - Akeem - 14.06.2018

First you have to set this values to 0 under OnPlayerDisconnect: PlayerInfo[playerid][pHealth], PlayerInfo[playerid][pArmour] and on player connect equal then to what is in there file. Then you can setplayerhp and so on.


Re: Health/Armour saving issue - Mike861 - 14.06.2018

Quote:
Originally Posted by Exhibit
View Post
INI_ParseFile should be added on OnPlayerConnect considering you are also loading the password?

Are the values saving?
I do have INI_ParseFile in OnPlayerConnect callback, but the values for both are 0.000000.


Re: Health/Armour saving issue - Mike861 - 14.06.2018

I've tried this
Code:
INI_WriteFloat(File,"Health", GetPlayerHealth(playerid,Float:health));
INI_WriteFloat(File,"Armour", GetPlayerArmour(playerid,Float:armor);
and now once i login and spawn values are 1.000000