how to save health/armour? -
tommzy09 - 10.11.2014
Hey guys, i've been having trouble trying to save players health and armour when they quit and rejoin.
i haven't had any luck, it just keeps saving as 1.00000 in dini.
can anyone give me an example of health/armour saving using dini? thanks
Re: how to save health/armour? -
Toxik - 10.11.2014
http://lmgtfy.com/?q=samp+dini+health%2Farmour+save&l=1
Re: how to save health/armour? -
tommzy09 - 10.11.2014
i'll have you know, none of them methods worked for me :/
Re: how to save health/armour? -
Banana_Ghost - 10.11.2014
do something like
pawn Код:
new Float:health;
GetPlayerHealth(playerid,health);
dini_FloatSet(path, "health", pInfo[playerid][health]);
You should be able to sort the rest of the variables out yourself with dini.
But I do recommend, if using an ini account system, upgrade to y_ini, it's way faster and efficient.
Re: how to save health/armour? -
Sabur - 10.11.2014
use GetPlayerHealth(playerid, variable) above the data file and then use the variable in the writefloat.
EXAMPLE: I use Y_INI.
Код:
stock SaveUser_data(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
GetPlayerPos(playerid, PlayerInfo[playerid][posX], PlayerInfo[playerid][posY], PlayerInfo[playerid][posZ]);
GetPlayerFacingAngle(playerid, PlayerInfo[playerid][posA]);
GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
GetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
INI_SetTag(File,"data");
INI_WriteInt(File,"Skin", GetPlayerSkin(playerid));
INI_WriteInt(File,"Ban", PlayerInfo[playerid][pBan]);
INI_WriteInt(File,"Money", GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin", PlayerInfo[playerid][pAdmin]);
INI_WriteString(File,"IP", PlayerInfo[playerid][pIP]);
INI_WriteInt(File,"Interior", GetPlayerInterior(playerid));
INI_WriteInt(File,"VirtualWorld", GetPlayerVirtualWorld(playerid));
INI_WriteFloat(File,"Health", PlayerInfo[playerid][pHealth]);
INI_WriteFloat(File,"Armour", PlayerInfo[playerid][pArmour]);
INI_WriteFloat(File,"PositionX", PlayerInfo[playerid][posX]);
INI_WriteFloat(File,"PositionY", PlayerInfo[playerid][posY]);
INI_WriteFloat(File,"PositionZ", PlayerInfo[playerid][posZ]);
INI_WriteFloat(File,"PositionA", PlayerInfo[playerid][posA]);
INI_Close(File);
return 1;
}
Re: how to save health/armour? -
HY - 10.11.2014
pawn Код:
#include <a_samp>
enum pInfo
{
Health
}
new PlayerInfo[MAX_PLAYERS][pInfo];
public OnPlayerDisconnect(playerid, reason)
{
new file[256];
new Float:Health;
GetPlayerHealth(playerid, Health);
dini_FloatSet(file, "Health", PlayerInfo[playerid][Health]);
return 1;
}
public OnPlayerConnect(playerid)
{
SetPlayerHealth(playerid, PlayerInfo[playerid][Health]);
return 1;
}
stock GetPlayerHealthForPlayer(playerid)
{
new Float:Health;
GetPlayerHealth(playerid, Health);
return 1;
}