Health/Armour saving issue
#1

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

did u add INI_ParseFile??
Reply
#3

print those values before you set them.
Reply
#4

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

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

add INI_ParseFile on top of OnPlayerSpawn
Reply
#6

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

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

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

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

Are the values saving?
Reply
#10

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.
Reply
#11

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.
Reply
#12

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)