Saving weapons y_ini
#1

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.
Reply
#2

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.
Reply
#3

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]);
Reply
#4

Thank you very much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)