Is there a way to give ALL ammo types to a player?
4 replies, posted
So I am creating an addon one of the features would be give all ammo types. With the command ply:GiveAmmo( 200, "Name", false ). For name how would I put that to get all the ammo types in one, is that even possible or would I have to do add it one by one?
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/game/BuildAmmoTypes]game.BuildAmmoTypes[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GiveAmmo]Player:GiveAmmo[/url]
Loop through the ammo table and give them each type.
game.BuildAmmoTypes doesn't return the default ammo types, so you'll have to manually add [URL="http://wiki.garrysmod.com/page/Default_Ammo_Types"]these[/URL] to your table if you want to give the player the default ones as well.
You guys are silly
[code]
FindMetaTable ("Player").Restock = function (self)
tblWeapons = self:GetWeapons ()
for id = 1, #tblWeapons do
wep = tblWeapons[id]
self:GiveAmmo (wep:GetMaxClip1 () - wep:Clip1 () wep:GetPrimaryAmmoType ())
self:GiveAmmo (wep:GetMaxClip2 () - wep:Clip2 (), wep:GetSecondaryAmmoType ())
end
end
[/code]
[QUOTE=Potatofactory;51291347]You guys are silly
[code]
FindMetaTable ("Player").Restock = function (self)
tblWeapons = self:GetWeapons ()
for id = 1, #tblWeapons do
wep = tblWeapons[id]
self:GiveAmmo (wep:GetMaxClip1 () - wep:Clip1 () wep:GetPrimaryAmmoType ())
self:GiveAmmo (wep:GetMaxClip2 () - wep:Clip2 (), wep:GetSecondaryAmmoType ())
end
end
[/code][/QUOTE]
That's only for weapons the player is holding, though, not all ammo types.
Sorry, you need to Log In to post a reply to this thread.