Posts: 1,648
Threads: 482
Joined: Jun 2010
pawn Код:
for(new w = 0; w < 13; w++)
{
new id = PlayerWeapons[playerid][w];
printf("WeaponID: %d", id);
if(WepAmmo[id] > 0)
{
GivePlayerWeapon(playerid,WepModel[id],WepAmmo[id]);
printf("Weapon: %d, Ammo: %d", WepModel[id], WepAmmo[id]);
}
}
The PlayerWeapons[playerid][w] is the WeaponSQLID.
It's already loaded into this variable.
PlayerWeapons[playerid][13] is the amount.
I want it to give the weapon and ammo once, but it gives 12 times.
Posts: 79
Threads: 8
Joined: Mar 2010
Reputation:
0
Can you show the code that storing data in PlayerWeapons ?
Posts: 1,648
Threads: 482
Joined: Jun 2010
pawn Код:
for(new w=0; w < 13; w++)
{
new string[12];
format(string, sizeof(string), "Weapon%d", w);
mysql_get_field(string, QueryString);
PlayerWeapons[playerid][w] = strval(QueryString);
}
Posts: 1,648
Threads: 482
Joined: Jun 2010
Posts: 1,648
Threads: 482
Joined: Jun 2010
pawn Код:
[18:49:43] Weapon: 22, Ammo: 250
[18:49:43] WeaponID: 0
[18:49:43] Weapon: 22, Ammo: 250
[18:49:43] WeaponID: 1
[18:49:43] WeaponID: 0
[18:49:43] Weapon: 22, Ammo: 250
[18:49:43] WeaponID: 0
[18:49:43] Weapon: 22, Ammo: 250
[18:49:43] WeaponID: 0
[18:49:43] Weapon: 22, Ammo: 250
[18:49:43] WeaponID: 0
[18:49:43] Weapon: 22, Ammo: 250
[18:49:43] WeaponID: 0
[18:49:43] Weapon: 22, Ammo: 250
[18:49:43] WeaponID: 0
[18:49:43] Weapon: 22, Ammo: 250
[18:49:43] WeaponID: 0
[18:49:43] Weapon: 22, Ammo: 250
[18:49:43] WeaponID: 0
[18:49:44] Weapon: 22, Ammo: 250
[18:49:44] WeaponID: 0
[18:49:44] Weapon: 22, Ammo: 250
[18:49:44] WeaponID: 0
[18:49:44] Weapon: 22, Ammo: 250
The weapon ID should be 1.
Posts: 691
Threads: 96
Joined: Jan 2012
Reputation:
0
The loop is set to give the gun less than 13 times, which gives it 12 times. Don't use the loop.
Posts: 1,648
Threads: 482
Joined: Jun 2010
They are loaded from MySQL.