• Pointshop Prop Hunt SMG Grenade
    2 replies, posted
Hey guys! So I have the following basic code to give a player and SMG grenade when they buy it from the pointshop: [CODE]ITEM.Name = 'Nade' ITEM.Price = 100 ITEM.Model = 'models/Items/357ammo.mdl' ITEM.WeaponClass = 'item_ar2_grenade' ITEM.SingleUse = true function ITEM:OnBuy(ply) ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end[/CODE] It's a simple code, I know. It works and gives the player the SMG grenade when they purchase it from the pointshop! However, what I'd like is for the grenade to only be allowed to be bought once per round, and only the Hunters can buy it. Any help is appreciated. Thanks!
Do a check like [code] if ply:Team() == TEAM_NAME then ... [/code] For the second bit. As for the first bit, Fretta has a method of getting round number, if you view round_controller: [code] local roundNum = GetGlobalInt( "RoundNumber" ); [/code] In fact, Prop Hunt itself has a good example for you, in the init.lua file where on pre round start, it checks whether it should swap the team and will do so if it's not the first round One way you could do it, although there may be better methods, is to do something like ply.GrenadesBought = 0 on round start and round end, then set it to 1 when they purchase it, but disallow if ply.GrenadesBought is over 0
Hey Niandra! I figured out the teams part by putting this into the item lua file: [CODE]function ITEM:CanPlayerBuy(ply) return ply:Team() != 2 end[/CODE] Works a treat! Tells prop that they can't buy it. From this I'm now wondering if there can can be a way to use the above piece of code, alongside the [CODE]function ITEM:OnBuy(ply)[/CODE] to tell if the player has already bought the grenade in that round or not, and to allow them to buy it the following round. Thanks!
Sorry, you need to Log In to post a reply to this thread.