PDA

View Full Version : Health and Armour? (Y_INI)


Reklez
04/04/2012, 05:13 AM
when i saving players health and armour i keep getting these


1.00000
1.00000


code


enum PlayerInfo
{
Float:Health,
Float:Armour
};
new pInfo[MAX_PLAYERS][pInfo];

new Float:hp, Float:armour;
pInfo[playerid][Health] = GetPlayerHealth(playerid, hp);
pInfo[playerid][Armour] = GetPlayerArmour(playerid, armour);
INI_WriteFloat(iFile, "Health", pInfo[playerid][Health]);
INI_WriteFloat(iFile, "Armour", pInfo[playerid][Armour]);


and one question should this work?


//OnPlayerSpawn

SetPlayerHealth(playerid, pInfo[playerid][Health]);
SetPlayerArmour(playerid, pInfo[playerid][Armour]);

eesh
04/04/2012, 05:20 AM
enum PlayerInfo
{
Float:Health,
Float:Armour
};
new pInfo[MAX_PLAYERS][pInfo];

new Float:hp, Float:armour;
GetPlayerHealth(playerid, hp)
pInfo[playerid][Health] = hp;
GetPlayerArmour(playerid, armour);
pInfo[playerid][Armour] = armour;
INI_WriteFloat(iFile, "Health", pInfo[playerid][Health]);
INI_WriteFloat(iFile, "Armour", pInfo[playerid][Armour]);

Reklez
04/04/2012, 05:25 AM
now here is the result


11.000000


is this normal or not? and why when i spawn i died (Seriously i don't know what i'm doing with my Health and Armour Saving func)

eesh
04/04/2012, 05:45 AM
I guess thats because your health was 0 since it wasnt saved. Change the value to 100 in the save data

Reklez
04/04/2012, 06:05 AM
well actually i did 100.0000 but still it keeps repeating onplayerspawn

Harish
04/04/2012, 07:38 AM
dude you made mistake


enum PlayerInfo
{
Float:Health,
Float:Armour
};
new pInfo[MAX_PLAYERS][PlayerInfo];//check this line you placed as "new pInfo[MAX_PLAYERS][pInfo];"

Reklez
04/04/2012, 07:43 AM
Totally i just type the code with my hands instead of copying and pasting here.

the original one is


new pInfo[MAX_PLAYERS][PlayerInfo];


its just a typo

Harish
04/04/2012, 07:50 AM
try finding the solution by placing


//OnPlayerDisconnect

printf("Player Health :%f",GetPlayerHealth(playerid));
printf("Saved Health :%f",pInfo[playerid][Health]);

[ABK]Antonio
04/04/2012, 07:50 AM
enum PlayerInfo
{
Float:Health,
Float:Armour
};
new pInfo[MAX_PLAYERS][pInfo];

new Float:hp, Float:armour;
GetPlayerHealth(playerid, hp)
pInfo[playerid][Health] = hp;
GetPlayerArmour(playerid, armour);
pInfo[playerid][Armour] = armour;
INI_WriteFloat(iFile, "Health", pInfo[playerid][Health]);
INI_WriteFloat(iFile, "Armour", pInfo[playerid][Armour]);



GetPlayerHealth(playerid, pInfo[playerid][Health]); //don't know why both of you created useless vars...
GetPlayerArmour(playerid, pInfo[playerid][Armour]);
INI_WriteFloat(iFile, "Health", pInfo[playerid][Health]);
INI_WriteFloat(iFile, "Armour", pInfo[playerid][Armour]);

Harish
04/04/2012, 07:55 AM
and here is the another way

new Float:health;
GetPlayerHealth(playerid,health)
new hp = floatround(health);
INI_Int("health", hp);

Reklez
04/04/2012, 09:53 AM
Never mind i saw the problem i forgot to put INI_Float

inside the userload which load with INI_Parse

Hayden_Almeida
04/11/2015, 01:42 AM
enum PlayerInfo
{
Float:Health,
Float:Armour
};
new pInfo[MAX_PLAYERS][pInfo];

new Float:hp, Float:armour;
GetPlayerHealth(playerid, hp)
pInfo[playerid][Health] = hp;
GetPlayerArmour(playerid, armour);
pInfo[playerid][Armour] = armour;
INI_WriteFloat(iFile, "Health", pInfo[playerid][Health]);
INI_WriteFloat(iFile, "Armour", pInfo[playerid][Armour]);


It works for me! Thanks :D