Weapons Ammo -
Dragony92 - 10.09.2011
pawn Code:
new weaponid,ammo;
for (new i=0; i<12; i++)
{
GetPlayerWeaponData(playerid, c, weaponid, ammo);
}
How to summ all ammo data?
Re: Weapons Ammo -
Sasino97 - 10.09.2011
All ammunition of all current weapons?
Re: Weapons Ammo -
Dragony92 - 10.09.2011
I want to summ all ammo data, ammo from slot 1, slot2.....
edit:
Quote:
Originally Posted by [GF]Sasino97
All ammunition of all current weapons?
|
Yes
Re: Weapons Ammo -
Tigerkiller - 10.09.2011
create new verriable and sumary it ?
like var+=ammo;
Re: Weapons Ammo -
Wesley221 - 10.09.2011
pawn Code:
new weaponid[12], ammo[12];
for (new i=0; i<12; i++)
{
GetPlayerWeaponData(playerid, i, weaponid[i], ammo[i]);
}
Something like this you mean?
Re: Weapons Ammo -
Tigerkiller - 10.09.2011
no! create a new var llike new var;
and after GetWeaponData use var+=ammo;
Re: Weapons Ammo -
Wesley221 - 10.09.2011
He wanted the ammo, with that code i posted should give him all the ammo of every weapon in the variables. If you want to give the weapons, just use GivePlayerWeapon(); with the variables
Re: Weapons Ammo -
Dragony92 - 10.09.2011
@Wesley221 I want to summ ammo from all weapons in one variable.
Re: Weapons Ammo -
Tigerkiller - 10.09.2011
look my post i said you how to sumary
Re: Weapons Ammo -
Wesley221 - 10.09.2011
What do you mean with 'summ', i dont really get that. And it isnt possible to store EVERY ammo data in ONE variable. Store it like i did, then you can do "GivePlayerWeapon(playerid, weaponid[4], ammo[4]);"
That will give him the weapon that was in his 4th slot, and give him the ammo he had in the 4th slot.
Re: Weapons Ammo -
Dragony92 - 10.09.2011
I want to know how many ammo someone have, form all of his weapons....
M4A1 = 30
Grenade = 10
allammo = 30+10 = 40
Re: Weapons Ammo -
Wesley221 - 10.09.2011
Then use the piece i posted to get the data, and then do:
pawn Code:
new Totalammo[MAX_PLAYERS]; // global variable
Totalammo[playerid] = (ammo[playerid][0] + ammo[playerid][1] + ammo[playerid][2] ...... +ammo[playerid][12]);
printf("%s has %i ammo. ", GetName(playerid), TotalAmmo[playerid]);
Also dont forget to make the 'ammo' variable player-bounded (add [MAX_PLAYERS] to it), otherwise it will just get playerid's 0 ammo.
Re: Weapons Ammo -
Tigerkiller - 10.09.2011
look my post on page 1 i said how
and westley you can!
Re: Weapons Ammo -
Wesley221 - 10.09.2011
But you still need the ammo[MAX_PLAYERS][12], to store each ammo amounts of each weapons.
Re: Weapons Ammo -
Dragony92 - 10.09.2011
@Tigerkiller && @Wesley221 tnx a lot

+rep
@Wesley221 i dont need to store them, i just need to know how many ammos player have, i'm making AC....
Re: Weapons Ammo -
andrew4699 - 10.09.2011
Instead of that you can use
Code:
new ammototal[MAX_PLAYERS];
for(new i = 0; i < 12; i++) ammototal[playerid]+=ammo[playerid][i];