Well, I made a function called "SaveUserData(playerid);" which is called in the "OnPlayerDisconnect" callback.
pawn Код:
public SaveUserData(playerid)
{
new name[MAX_PLAYER_NAME], file[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), UserFile, name);
if(gPlayerLogged[playerid] == 1)
{
if(fexist(file))
{
PlayerInfo[playerid][pActivity] = GetPlayerScore(playerid);
PlayerInfo[playerid][pVirtualWorld] = GetPlayerVirtualWorld(playerid);
PlayerInfo[playerid][pInterior] = GetPlayerInterior(playerid);
GetPlayerWeaponData(playerid, 1, PlayerInfo[playerid][pWeapon1], PlayerInfo[playerid][pAmmo1]);
GetPlayerWeaponData(playerid, 2, PlayerInfo[playerid][pWeapon2], PlayerInfo[playerid][pAmmo2]);
GetPlayerWeaponData(playerid, 3, PlayerInfo[playerid][pWeapon3], PlayerInfo[playerid][pAmmo3]);
GetPlayerWeaponData(playerid, 4, PlayerInfo[playerid][pWeapon4], PlayerInfo[playerid][pAmmo4]);
GetPlayerWeaponData(playerid, 5, PlayerInfo[playerid][pWeapon5], PlayerInfo[playerid][pAmmo5]);
GetPlayerWeaponData(playerid, 6, PlayerInfo[playerid][pWeapon6], PlayerInfo[playerid][pAmmo6]);
GetPlayerWeaponData(playerid, 7, PlayerInfo[playerid][pWeapon7], PlayerInfo[playerid][pAmmo7]);
GetPlayerWeaponData(playerid, 8, PlayerInfo[playerid][pWeapon8], PlayerInfo[playerid][pAmmo8]);
GetPlayerWeaponData(playerid, 9, PlayerInfo[playerid][pWeapon9], PlayerInfo[playerid][pAmmo9]);
GetPlayerWeaponData(playerid, 10, PlayerInfo[playerid][pWeapon10], PlayerInfo[playerid][pAmmo10]);
GetPlayerWeaponData(playerid, 11, PlayerInfo[playerid][pWeapon11], PlayerInfo[playerid][pAmmo11]);
GetPlayerWeaponData(playerid, 12, PlayerInfo[playerid][pWeapon12], PlayerInfo[playerid][pAmmo12]);
djSetInt(file, "Money", PlayerInfo[playerid][pMoney]);
new Float:Health;
GetPlayerHealth(playerid, Health);
djSetFloat(file, "Health", floatround(Health));
new Float:Armour;
GetPlayerArmour(playerid, Armour);
djSetFloat(file, "Armour", floatround(Armour));
djSetInt(file, "Activity", PlayerInfo[playerid][pActivity]);
djSetInt(file, "Job", PlayerInfo[playerid][pJob]);
djSetInt(file, "Duty", PlayerInfo[playerid][pDuty]);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
djSetFloat(file, "PosX", (x));
djSetFloat(file, "PosY", (y));
djSetFloat(file, "PosZ", (z));
djSetInt(file, "VirtualWorld", PlayerInfo[playerid][pVirtualWorld]);
djSetInt(file, "Interior", PlayerInfo[playerid][pInterior]);
djSetInt(file, "Weapon1", PlayerInfo[playerid][pWeapon1]);
djSetInt(file, "Weapon2", PlayerInfo[playerid][pWeapon2]);
djSetInt(file, "Weapon3", PlayerInfo[playerid][pWeapon3]);
djSetInt(file, "Weapon4", PlayerInfo[playerid][pWeapon4]);
djSetInt(file, "Weapon5", PlayerInfo[playerid][pWeapon5]);
djSetInt(file, "Weapon6", PlayerInfo[playerid][pWeapon6]);
djSetInt(file, "Weapon7", PlayerInfo[playerid][pWeapon7]);
djSetInt(file, "Weapon8", PlayerInfo[playerid][pWeapon8]);
djSetInt(file, "Weapon9", PlayerInfo[playerid][pWeapon9]);
djSetInt(file, "Weapon10", PlayerInfo[playerid][pWeapon10]);
djSetInt(file, "Weapon11", PlayerInfo[playerid][pWeapon11]);
djSetInt(file, "Weapon12", PlayerInfo[playerid][pWeapon12]);
djSetInt(file, "Ammo1", PlayerInfo[playerid][pAmmo1]);
djSetInt(file, "Ammo2", PlayerInfo[playerid][pAmmo2]);
djSetInt(file, "Ammo3", PlayerInfo[playerid][pAmmo3]);
djSetInt(file, "Ammo4", PlayerInfo[playerid][pAmmo4]);
djSetInt(file, "Ammo5", PlayerInfo[playerid][pAmmo5]);
djSetInt(file, "Ammo6", PlayerInfo[playerid][pAmmo6]);
djSetInt(file, "Ammo7", PlayerInfo[playerid][pAmmo7]);
djSetInt(file, "Ammo8", PlayerInfo[playerid][pAmmo8]);
djSetInt(file, "Ammo9", PlayerInfo[playerid][pAmmo9]);
djSetInt(file, "Ammo10", PlayerInfo[playerid][pAmmo10]);
djSetInt(file, "Ammo11", PlayerInfo[playerid][pAmmo11]);
djSetInt(file, "Ammo12", PlayerInfo[playerid][pAmmo12]);
}
}
return 1;
}
Hope you can help me. Thank you.