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
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
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
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(playerid, name, sizeof(name));
format(path, sizeof(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
PHP Code:
new name[24], path[29];
GetPlayerName(playerid, name, sizeof(name));
format(path, sizeof(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
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