• Pointshop - Team restriction problems (lua codding)
    4 replies, posted
Hello. I am working on a new stalker server for Garry's mod. I am having a problem with restricting access on weapon for specific team. There are 2 teams. Humans and Stalker. I don't want stalker to or see, or buy this weapon. I want to restrict access (on weapons) for him. I tried it in multiple ways. First I would like to warn you that I am a beginner at coding and that I am trying to learn how to code with lua, so be patient with my "unlucky" code. [CODE]ITEM.Name = 'Minigun' ITEM.Price = 500 ITEM.Model = 'models/minigun_model/weapons/w_minigun.mdl' ITEM.WeaponClass = 'weapon_mini_gun_v3' ITEM.SingleUse = true function ITEM:OnBuy(ply) if ply:Team() == TEAM_STALKER then ply:StripWeapon(self.WeaponClass) else ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) end[/CODE] That is what I've done. It doesn't show any errors in console. Shit that happens is that as human you can normally buy this weapon (in this case minigun) but when I buy it as a stalker gun does not appear (THIS IS WHAT I ACTUALLY WANT) but pointshop says "You bought minigun for 500 points". And there is the problem. I don't want stalkers to buy this weapon. What should I do?
You're looking for [URL]http://pointshop.burt0n.net/items/functions#can-player-buy[/URL]
I know about this. I was searching what to do there and I tried to find the right function but no luck, that's why I came here. To get a clue or help for functions. Maybe I dont even have the right one. Belive me...I've tried everything that I had in my mind. I'm lost now :D.
[lua] function ITEM:CanPlayerBuy(ply) return ply:Team() ~= TEAM_STALKER end [/lua]
[QUOTE=adamdburton;50498624][lua] function ITEM:CanPlayerBuy(ply) return ply:Team() ~= TEAM_STALKER end [/lua][/QUOTE] Damn you helped me a lot. Thank you very much. It works.
Sorry, you need to Log In to post a reply to this thread.