PDA

View Full Version : Little problem saving strings.


Cepillado300
19/01/2014, 09:12 PM
Hello, I'm trying to save some weapon data as an string in order to save the weapon ID and the ammunition at the same time, in the same line.

Heres 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]);

if (strlen(arma[2][0]) < 2) return format(pisdata,sizeof(pisdata),"0,0");


The strlen part it's the part with the problem. I made this line because when I disconnect after emptying a gun, the ammo saves as 0, but the weapon ID saves as the last weapon that I used in that slot.

After adding the strlen line, nothing saves.

So, Is there a way to save the weapon ID as 0 after it's been depleted and not as the weapon ID?

(NOTE: I've also tried to turn arma[2][0] as a string with sscanf, and then getting the length, value, and comparing to 0, nothing works.)