[HELP] weapons saving with Dini -
MatanD - 12.10.2011
Hey.
I use this code:
pawn Код:
forward SavePlayerWeapons(playerid);
public SavePlayerWeapons(playerid)
{
new
playerFile[68],
weapons[13][2],
playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
format(playerFile, sizeof(playerFile), "Weapons/%s", playerName);
for (new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
}
dini_IntSet(playerFile, "weaponSlot0", weapons[0][0]);
dini_IntSet(playerFile, "weaponSlot0Ammo", weapons[0][1]);
dini_IntSet(playerFile, "weaponSlot1", weapons[1][0]);
dini_IntSet(playerFile, "weaponSlot1Ammo", weapons[1][1]);
dini_IntSet(playerFile, "weaponSlot2", weapons[2][0]);
dini_IntSet(playerFile, "weaponSlot2Ammo", weapons[2][1]);
dini_IntSet(playerFile, "weaponSlot3", weapons[3][0]);
dini_IntSet(playerFile, "weaponSlot3Ammo", weapons[3][1]);
dini_IntSet(playerFile, "weaponSlot4", weapons[4][0]);
dini_IntSet(playerFile, "weaponSlot4Ammo", weapons[4][1]);
dini_IntSet(playerFile, "weaponSlot5", weapons[5][0]);
dini_IntSet(playerFile, "weaponSlot5Ammo", weapons[5][1]);
dini_IntSet(playerFile, "weaponSlot6", weapons[6][0]);
dini_IntSet(playerFile, "weaponSlot6Ammo", weapons[6][1]);
dini_IntSet(playerFile, "weaponSlot7", weapons[7][0]);
dini_IntSet(playerFile, "weaponSlot7Ammo", weapons[7][1]);
dini_IntSet(playerFile, "weaponSlot8", weapons[8][0]);
dini_IntSet(playerFile, "weaponSlot8Ammo", weapons[8][1]);
dini_IntSet(playerFile, "weaponSlot9", weapons[9][0]);
dini_IntSet(playerFile, "weaponSlot8Ammo", weapons[9][1]);
dini_IntSet(playerFile, "weaponSlot10", weapons[10][0]);
dini_IntSet(playerFile, "weaponSlot10Ammo", weapons[10][1]);
dini_IntSet(playerFile, "weaponSlot11", weapons[11][0]);
dini_IntSet(playerFile, "weaponSlot11Ammo", weapons[11][1]);
dini_IntSet(playerFile, "weaponSlot12", weapons[12][0]);
dini_IntSet(playerFile, "weaponSlot12Ammo", weapons[12][1]);
return 1;
}
But I have some problems, the weapons do not save at the first time.
Let me give you an example, if I do /givegun [myid] 24 50, at the first time it doesn't save, when I do another /givegun [myid] 24 50, I have deagle with 100 ammo in-game and in the file there is only 50 ammo.
Do you guys have an idea why does it happen?
Thank you in advance!
Re: [HELP] saving with Dini -
[MG]Dimi - 12.10.2011
Its doesnt load instantly? Try switching weapons before checking it...
Re: [HELP] saving with Dini -
MatanD - 12.10.2011
I didn't try to load them, yet.
But, anyways it won't work (loading) well because the file is not updated well.
I also tried to switch them.
P.S, I forgot to tell that I add the saving function under "OnPlayerKeyChange"(I think) - "KEY_FIRE" and when I shot it saves everything well enough, but I need them to save anytime I use the function..
Re: [HELP] saving with Dini -
MatanD - 12.10.2011
Anyone?
Re: [HELP] saving with Dini -
[MG]Dimi - 13.10.2011
I dont understand why are you doing it? Call SavePlayerWeapons only under OnPlayerDisconnect. While he is ingame manage it with variables