• TTT - Buy ammo - Not working
    3 replies, posted
[CODE]ITEM.Name = 'Pistol Ammo' ITEM.Price = 2 ITEM.Model = 'models/props_junk/GlassBottle01a.mdl' ITEM.SingleUse = true function ITEM:OnBuy(player) player:GiveAmmo(10, "item_ammo_pistol_ttt") end[/CODE] Player:GiveAmmo(number amount, string type[, boolean displayPopup = false]) ^ Function
you haven't shown us an error....
Not very descriptive but meh, [LUA] function SWEP:WasBought(buyer) if IsValid(buyer) then -- probably already self.Owner buyer:GiveAmmo( 20, "Pistol" ) end end [/LUA] As long as you have SWEP.LimitedStock = false then this should work. Reply if it doesn't.
Sorry about the no information, it was about 4 in the morning and I just wasn't thinking. So - I just want the players to be able to buy ammo from the pointshop. The code you gave me crashes the server because of: [CODE][ERROR] lua/items/powerups/pistolammo.lua:1: attempt to index global 'SWEP' (a nil value) 1. unknown - lua/items/powerups/pistolammo.lua:1 2. include - [C]:-1 3. LoadItems - lua/sh_pointshop.lua:105 4. unknown - lua/autorun/pointshop.lua:35[/CODE]
Sorry, you need to Log In to post a reply to this thread.