08.10.2014, 17:21
Hi guys..
My ammo for each weapon doubles everytime I re-connect. Any ideas?
All my code:
My ammo for each weapon doubles everytime I re-connect. Any ideas?
All my code:
pawn Код:
public OnPlayerSpawn(playerid)
{
// Other misc stuff
LoadPlayerSpawnData(playerid);
return 1;
}
public LoadPlayerSpawnData(playerid)
{
// Other misc stuff
LoadPlayerWeapons(playerid);
}
public LoadPlayerWeapons(playerid)
{
RemoveWeapons(playerid);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon1], PlayerInfo[playerid][pAmmo1]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon2], PlayerInfo[playerid][pAmmo2]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon3], PlayerInfo[playerid][pAmmo3]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon4], PlayerInfo[playerid][pAmmo4]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon5], PlayerInfo[playerid][pAmmo5]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon6], PlayerInfo[playerid][pAmmo6]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon7], PlayerInfo[playerid][pAmmo7]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon8], PlayerInfo[playerid][pAmmo8]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon9], PlayerInfo[playerid][pAmmo9]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon10], PlayerInfo[playerid][pAmmo10]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon11], PlayerInfo[playerid][pAmmo11]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon12], PlayerInfo[playerid][pAmmo12]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon13], PlayerInfo[playerid][pAmmo13]);
GivePlayerWeapon(playerid, PlayerInfo[playerid][pWeapon14], PlayerInfo[playerid][pAmmo14]);
}
public OnPlayerDisconnect(playerid, reason)
{
// other misc stuff
OnPlayerDataSave(playerid);
return 1;
}
public OnPlayerDataSave(playerid)
{
if(PlayerLogged[playerid] == true)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
GetPlayerWeaponData(playerid, 0, PlayerInfo[playerid][pWeapon1], PlayerInfo[playerid][pAmmo1]);
GetPlayerWeaponData(playerid, 1, PlayerInfo[playerid][pWeapon2], PlayerInfo[playerid][pAmmo2]);
GetPlayerWeaponData(playerid, 2, PlayerInfo[playerid][pWeapon3], PlayerInfo[playerid][pAmmo3]);
GetPlayerWeaponData(playerid, 3, PlayerInfo[playerid][pWeapon4], PlayerInfo[playerid][pAmmo4]);
GetPlayerWeaponData(playerid, 4, PlayerInfo[playerid][pWeapon5], PlayerInfo[playerid][pAmmo5]);
GetPlayerWeaponData(playerid, 5, PlayerInfo[playerid][pWeapon6], PlayerInfo[playerid][pAmmo6]);
GetPlayerWeaponData(playerid, 6, PlayerInfo[playerid][pWeapon7], PlayerInfo[playerid][pAmmo7]);
GetPlayerWeaponData(playerid, 7, PlayerInfo[playerid][pWeapon8], PlayerInfo[playerid][pAmmo8]);
GetPlayerWeaponData(playerid, 8, PlayerInfo[playerid][pWeapon9], PlayerInfo[playerid][pAmmo9]);
GetPlayerWeaponData(playerid, 9, PlayerInfo[playerid][pWeapon10], PlayerInfo[playerid][pAmmo10]);
GetPlayerWeaponData(playerid, 10, PlayerInfo[playerid][pWeapon11], PlayerInfo[playerid][pAmmo11]);
GetPlayerWeaponData(playerid, 11, PlayerInfo[playerid][pWeapon12], PlayerInfo[playerid][pAmmo12]);
GetPlayerWeaponData(playerid, 12, PlayerInfo[playerid][pWeapon13], PlayerInfo[playerid][pAmmo13]);
GetPlayerWeaponData(playerid, 13, PlayerInfo[playerid][pWeapon14], PlayerInfo[playerid][pAmmo14]);
INI_WriteInt(File, "Weapon1",PlayerInfo[playerid][pWeapon1]);
INI_WriteInt(File, "Weapon2",PlayerInfo[playerid][pWeapon2]);
INI_WriteInt(File, "Weapon3",PlayerInfo[playerid][pWeapon3]);
INI_WriteInt(File, "Weapon4",PlayerInfo[playerid][pWeapon4]);
INI_WriteInt(File, "Weapon5",PlayerInfo[playerid][pWeapon5]);
INI_WriteInt(File, "Weapon6",PlayerInfo[playerid][pWeapon6]);
INI_WriteInt(File, "Weapon7",PlayerInfo[playerid][pWeapon7]);
INI_WriteInt(File, "Weapon8",PlayerInfo[playerid][pWeapon8]);
INI_WriteInt(File, "Weapon9",PlayerInfo[playerid][pWeapon9]);
INI_WriteInt(File, "Weapon10",PlayerInfo[playerid][pWeapon10]);
INI_WriteInt(File, "Weapon11",PlayerInfo[playerid][pWeapon11]);
INI_WriteInt(File, "Weapon12",PlayerInfo[playerid][pWeapon12]);
INI_WriteInt(File, "Weapon13",PlayerInfo[playerid][pWeapon13]);
INI_WriteInt(File, "Weapon14",PlayerInfo[playerid][pWeapon14]);
INI_WriteInt(File, "Ammo1",PlayerInfo[playerid][pAmmo1]);
INI_WriteInt(File, "Ammo2",PlayerInfo[playerid][pAmmo2]);
INI_WriteInt(File, "Ammo3",PlayerInfo[playerid][pAmmo3]);
INI_WriteInt(File, "Ammo4",PlayerInfo[playerid][pAmmo4]);
INI_WriteInt(File, "Ammo5",PlayerInfo[playerid][pAmmo5]);
INI_WriteInt(File, "Ammo6",PlayerInfo[playerid][pAmmo6]);
INI_WriteInt(File, "Ammo7",PlayerInfo[playerid][pAmmo7]);
INI_WriteInt(File, "Ammo8",PlayerInfo[playerid][pAmmo8]);
INI_WriteInt(File, "Ammo9",PlayerInfo[playerid][pAmmo9]);
INI_WriteInt(File, "Ammo10",PlayerInfo[playerid][pAmmo10]);
INI_WriteInt(File, "Ammo11",PlayerInfo[playerid][pAmmo11]);
INI_WriteInt(File, "Ammo12",PlayerInfo[playerid][pAmmo12]);
INI_WriteInt(File, "Ammo13",PlayerInfo[playerid][pAmmo13]);
INI_WriteInt(File, "Ammo14",PlayerInfo[playerid][pAmmo14]);
INI_Close(File);
}
return 1;
}