for (new i = 0; i < 13; i ++) if (playerData[playerid][gun][i] != 0 && playerData[playerid][ammo][i] != 0){
format(wep_str, sizeof(wep_str), "gun%d", i);
INI_WriteInt(File, wep_str, playerData[playerid][gun][i]);
format(wep_str, sizeof(wep_str), "ammo%d", i);
INI_WriteInt(File, wep_str, playerData[playerid][ammo][i]);
}
ResetPlayerWeapons(playerid);
for (new i = 0; i < 13; i ++) {
playerData[playerid][gun][i] = 0;
playerData[playerid][ammo][i] = 0;
}
SetTimerEx("LoadUserSpawn_data", 500, false, "i", playerid);
forward LoadUserSpawn_data(playerid);
public LoadUserSpawn_data(playerid)
{
new str[124];
// --------------------------
GivePlayerMoney(playerid, playerData[playerid][cash]);
SetPlayerHealth(playerid, playerData[playerid][health]);
SetPlayerArmour(playerid, playerData[playerid][armour]);
// --------------------------
format(str, sizeof(str), "Health: %.1f Armour: %.1f\n%s [%i]", ReturnHealth(playerid), ReturnArmour(playerid), ReturnName(playerid, 0), playerid);
NameTag[playerid] = CreateDynamic3DTextLabel(str, COLOR_GRAY, 0.0, 0.0, 0.2, 8.0, playerid, INVALID_VEHICLE_ID, 0, -1, -1, -1, 8.0);
Attach3DTextLabelToPlayer(NameTag[playerid], playerid, 0.0, 0.0, 0.2);
// --------------------------
SetWeapons(playerid);
// --------------------------
playerSpawned[playerid] = true;
return 1;
}
SetWeapons(playerid)
{
for (new i = 0; i < 13; i++) {
GivePlayerWeapon(playerid, playerData[playerid][gun][i], playerData[playerid][ammo][i]);
}
return 1;
}
Did you check the ini file after the save function was called to see if it actually saves double ammo in the file?
|
So the problem is somewhere with the loading function.
Let's debug it. SetWeapons(playerid) { for (new i = 0; i < 13; i++) { GivePlayerWeapon(playerid, playerData[playerid][gun][i], playerData[playerid][ammo][i]); } print("SetWeapons called!"); return 1; } Now please compile. Clear your server log before joining. Join the server and then exit. Post the logs here afterwards. |
[16:08:27] SetWeapons called! [16:08:27] SetWeapons called!