Health and Armour? (Y_INI)
#1

when i saving players health and armour i keep getting these

pawn Код:
1.00000
1.00000
code

pawn Код:
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?

pawn Код:
//OnPlayerSpawn

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

pawn Код:
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]);
Reply
#3

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

I guess thats because your health was 0 since it wasnt saved. Change the value to 100 in the save data
Reply
#5

well actually i did 100.0000 but still it keeps repeating onplayerspawn
Reply
#6

dude you made mistake

pawn Код:
enum PlayerInfo
{
      Float:Health,
      Float:Armour
};
new pInfo[MAX_PLAYERS][PlayerInfo];//check this line you placed as "new pInfo[MAX_PLAYERS][pInfo];"
Reply
#7

Totally i just type the code with my hands instead of copying and pasting here.

the original one is

pawn Код:
new pInfo[MAX_PLAYERS][PlayerInfo];
its just a typo
Reply
#8

try finding the solution by placing

pawn Код:
//OnPlayerDisconnect

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

Quote:
Originally Posted by eesh
Посмотреть сообщение
pawn Код:
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]);
pawn Код:
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]);
Reply
#10

Quote:
Originally Posted by eesh
Посмотреть сообщение
pawn Код:
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)