PDA

View Full Version : Get grenade ammo



Earliboy
8th February 2013, 19:08
Hello,
i found a error message from my shop about the grenades:

Unknown weaponslot name frag_grenade_american_mp. Valid weaponslots are "primary" and "primaryb": (file 'maps/mp/gametypes/_shopping.gsc', line 781)
nades = self getWeaponSlotClipAmmo(grenadetype);

Currently it can't work cause i dind't changed the grenades max ammo to unlimited. But still i need to get the ammo of grenades.



giveGrenades(count)
{
self takeweapon("frag_grenade_american_mp");
self takeweapon("frag_grenade_german_mp");

if(self.pers["team"] == "allies")
grenadetype = "frag_grenade_american_mp";
else
grenadetype = "frag_grenade_german_mp";

nades = self getWeaponSlotClipAmmo(grenadetype);
count = count + nades;

self giveWeapon(grenadetype);
self setWeaponClipAmmo(grenadetype, count);
}


Any idea?

IzNoGoD
8th February 2013, 20:22
[player] getammocount("frag_grenade_german_mp");

Tally
8th February 2013, 20:29
You can't use the getWeaponSlotClipAmmo() function to find grenade ammo. It only works on the "primary" and "primaryb" weapon slots. Hence why you are getting the error that it must be one of those slots to check. The only way to check ammo for grenades in COD2 is via the getAmmoCount() function.

However, the setWeaponClipAmmo() function DOES work with grenades, and so you set your grenade items using this function.

It's a bit confusing, but once you know what function works with which weapon, it's relatively easy to set all types of ammo for any weapon.

Earliboy
8th February 2013, 21:00
Ye, thats why i forgot about the getAmmoCount ^^
Thx :)