Weapons Ammo
#1

pawn Code:
new weaponid,ammo;
for (new i=0; i<12; i++)
{
    GetPlayerWeaponData(playerid, c, weaponid, ammo);
}
How to summ all ammo data?
Reply
#2

All ammunition of all current weapons?
Reply
#3

I want to summ all ammo data, ammo from slot 1, slot2.....

edit:

Quote:
Originally Posted by [GF]Sasino97
View Post
All ammunition of all current weapons?
Yes
Reply
#4

create new verriable and sumary it ?
like var+=ammo;
Reply
#5

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?
Reply
#6

no! create a new var llike new var;
and after GetWeaponData use var+=ammo;
Reply
#7

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
Reply
#8

@Wesley221 I want to summ ammo from all weapons in one variable.
Reply
#9

look my post i said you how to sumary
Reply
#10

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

I want to know how many ammo someone have, form all of his weapons....
M4A1 = 30
Grenade = 10
allammo = 30+10 = 40
Reply
#12

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

look my post on page 1 i said how

and westley you can!
Reply
#14

But you still need the ammo[MAX_PLAYERS][12], to store each ammo amounts of each weapons.
Reply
#15

@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....
Reply
#16

Instead of that you can use

Code:
new ammototal[MAX_PLAYERS];

for(new i = 0; i < 12; i++) ammototal[playerid]+=ammo[playerid][i];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)