15.07.2013, 10:58
So, I'm trying to get to know the ysi y_ini include. It saves your money, skin and other info perfectly. But I can't get it to load the player position. I check the .ini file and it has coordinates saved in it, but it doesn't load properly.
Here's the code I used
Here's the code I used
Код:
enum pInfo
{
pPass,
pCash,
pAdmin,
pSkin,
Float:pX,
Float:pY,
Float:pZ
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_Data(playerid,name[],value[]);
public LoadUser_Data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash", PlayerInfo[playerid][pCash]);
INI_Int("Admin", PlayerInfo[playerid][pAdmin]);
INI_Int("Skin", PlayerInfo[playerid][pSkin]);
INI_Float("X",PlayerInfo[playerid][pX]);
INI_Float("Y",PlayerInfo[playerid][pY]);
INI_Float("Z",PlayerInfo[playerid][pZ]);
return 1;
}
stock UserPath(playerid)
{
new string[128], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
INI_WriteFloat(File,"X", x );
INI_WriteFloat(File,"Y",y );
INI_WriteFloat(File,"Z", z );
INI_Close(File);
return 1;
}
public OnPlayerSpawn(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
SetPlayerPos(playerid,PlayerInfo[playerid][pX],PlayerInfo[playerid][pY],PlayerInfo[playerid][pZ]);
return 1;
}


