SA-MP Forums Archive
Saving weapons y_ini - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Saving weapons y_ini (/showthread.php?tid=491754)



Saving weapons y_ini - Cepillado300 - 01.02.2014

Hello, I have an issue on my script, when a player empties his ammo and then disconnects, the weapon ID is still written in his user file, but with 0 ammo, is there a way to save the weapon ID as 0 if the player doesn't have any ammo on that slot?

This is my code

Код:
new arma[13][2];

for (new i = 0; i < 13; i++)
{
    GetPlayerWeaponData(playerid, i, arma[i][0], arma[i][1]);
}

GetPlayerWeaponData(playerid,2,arma[2][0],arma[2][1]);

new pisdata[10];

format(pisdata,sizeof(pisdata),"%d,%d",arma[2][0],arma[2][1]);

   new INI:File= INI_Open(DirARU(playerid));
    INI_SetTag(File,"Armas");
    INI_WriteString(File,"Pistola",pisdata);
    INI_Close(File);
Note: I am aware that this only saves the ammo and the ID of the pistol slot, what I need to know it's why it saves the last weapon in that slot after depleting its ammo, instead of saving it as a 0.


Respuesta: Saving weapons y_ini - Cepillado300 - 02.02.2014

I don't really like bumping threads, but I need an answer, this is the second time I create a post about this issue, the fist one never got a reply.


Re: Saving weapons y_ini - alex9419 - 02.02.2014

A simple check of the "arma[2][1]" to see if the value is greater than 0, if not set "arma[2][0]" to 0.

pawn Код:
arma[2][0] = (arma[2][1] < 1 ? 0 : arma[2][0]);



Respuesta: Saving weapons y_ini - Cepillado300 - 02.02.2014

Thank you very much.