09.03.2012, 03:57
I am using YSI to save my accounts, but I am having a problem, ever since I been trying to make it so I can save a gun on log out, the thing is whenever I /q i always log back in about 2 mins before I logged out, I have a timer on a loop going every second that calls the function SaveAccountStats I also have this function under onplayerdisconnect
Here is the code for my function
so my question is is why don't my guns save, and why don't my stats update everysecond considering I have a repeating timer that calls this function every second.
I log out and I am where I was 2 mins before I logged out.
Here is the code for my function
so my question is is why don't my guns save, and why don't my stats update everysecond considering I have a repeating timer that calls this function every second.
I log out and I am where I was 2 mins before I logged out.
pawn Код:
function SaveAccountStats(playerid)
{
if(Logged[playerid] == 1)
{
new
INI:File = INI_Open(UserPath(playerid))
;
INI_SetTag(File,"data");
PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
PlayerInfo[playerid][pCash] = GetPlayerCash(playerid);
PlayerInfo[playerid][pLevel] = GetPlayerScore(playerid);
new
Float:x,
Float:y,
Float:z,
guns[13][2]
;
GetPlayerPos(playerid,x,y,z);
PlayerInfo[playerid][pPos_x] = x;
PlayerInfo[playerid][pPos_y] = y;
PlayerInfo[playerid][pPos_z] = z;
for (new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, guns[i][0], guns[i][1]);
}
PlayerInfo[playerid][pGun2] = guns[2][0];
PlayerInfo[playerid][pGun3] = guns[3][0];
PlayerInfo[playerid][pGun4] = guns[4][0];
PlayerInfo[playerid][pGun5] = guns[5][0];
PlayerInfo[playerid][pGun6] = guns[6][0];
INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash]);
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Sex",PlayerInfo[playerid][pSex]);
INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
INI_WriteFloat(File,"Pos_x",PlayerInfo[playerid][pPos_x]);
INI_WriteFloat(File,"Pos_y",PlayerInfo[playerid][pPos_y]);
INI_WriteFloat(File,"Pos_z",PlayerInfo[playerid][pPos_z]);
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
INI_WriteInt(File,"Accent",PlayerInfo[playerid][pAccent]);
INI_WriteInt(File, "Job",PlayerInfo[playerid][pJob]);
INI_WriteInt(File, "Dlvpkg",PlayerInfo[playerid][pDlvpkg]);
INI_WriteInt(File, "Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File, "Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File, "Dead",PlayerInfo[playerid][pDead]);
INI_WriteInt(File, "Cop",PlayerInfo[playerid][pCop]);
INI_WriteInt(File, "Leader",PlayerInfo[playerid][pLeader]);
INI_WriteInt(File,"GunPermit",PlayerInfo[playerid][pGunPermit]);
INI_WriteInt(File,"Politician",PlayerInfo[playerid][pPolitician]);
INI_WriteInt(File,"Bank",PlayerInfo[playerid][pBank]);
INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
INI_WriteInt(File,"Hours",PlayerInfo[playerid][pHours]);
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
INI_WriteInt(File,"ScrapMetal", PlayerInfo[playerid][pScrapMetal]);
INI_WriteInt(File,"Wtest", PlayerInfo[playerid][pWtest]);
INI_WriteInt(File,"Dtest",PlayerInfo[playerid][pDtest]);
INI_WriteInt(File,"Car", PlayerInfo[playerid][pCar]);
INI_WriteFloat(File,"CarPos_x", PlayerInfo[playerid][pCarPos_x]);
INI_WriteFloat(File,"CarPos_y", PlayerInfo[playerid][pCarPos_y]);
INI_WriteFloat(File,"CarPos_z", PlayerInfo[playerid][pCarPos_z]);
INI_WriteFloat(File,"CarPos_a", PlayerInfo[playerid][pCarPos_a]);
INI_WriteInt(File,"CarID", PlayerInfo[playerid][pCarID]);
INI_WriteInt(File,"RadioFreq", PlayerInfo[playerid][pRadioFreq]);
INI_WriteInt(File,"Radio",PlayerInfo[playerid][pRadio]);
INI_WriteInt(File,"Gun1",PlayerInfo[playerid][pGun1]);
INI_WriteInt(File,"Gun2",PlayerInfo[playerid][pGun2]);
INI_WriteInt(File,"Gun3",PlayerInfo[playerid][pGun3]);
INI_WriteInt(File,"Gun4",PlayerInfo[playerid][pGun4]);
INI_WriteInt(File,"Gun5",PlayerInfo[playerid][pGun5]);
INI_WriteInt(File,"Gun6",PlayerInfo[playerid][pGun6]);
INI_Close(File);
}
return 1;
}