• Print

Author Topic: Prop Hunt server; Props getting weapons from the pointshop  (Read 5350 times)

0 Members and 1 Guest are viewing this topic.

Offline DJX

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Prop Hunt server; Props getting weapons from the pointshop
« on: October 14, 2015, 11:10:56 am »
So I am starting a dedicated Garry's Mod Server with the prop hunt game mode. I installed the point shop mod but I have an issue with permanent weapons were props are also having the weapons equipped. How can I restrict props from having point shop weapons?

Here is a code example for the Gamma Shooter in my point shop.

Code: Lua
  1. ITEM.Name = 'Permanant Gamma Shooter'
  2. ITEM.Price = 40000
  3. ITEM.Model = 'models/weapons/w_smg1.mdl'
  4. ITEM.WeaponClass = 'weapon_gammashooter'
  5. ITEM.SingleUse = false
  6.  
  7. function ITEM:OnBuy(ply)
  8.         ply:Give(self.WeaponClass)
  9.         ply:SelectWeapon(self.WeaponClass)
  10. end
  11.  
  12. function ITEM:OnSell(ply)
  13.         ply:StripWeapon(self.WeaponClass)
  14. end
  15.  
  16.  
  17. function ITEM:OnEquip(ply)
  18.         ply:Give(self.WeaponClass)
  19.         ply:SelectWeapon(self.WeaponClass)
  20. end
  21.  
  22. function ITEM:OnHolster(ply)
  23.         ply:StripWeapon(self.WeaponClass)
  24. end
  25.  
  26. local function PlayerLoadout( ply )
  27.         ply:Give(self.WeaponClass)
  28. end

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Prop Hunt server; Props getting weapons from the pointshop
« Reply #1 on: October 14, 2015, 04:24:09 pm »
Before all the places where you give them a weapon, check their team. If they are on the props team, then return.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline DJX

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Prop Hunt server; Props getting weapons from the pointshop
« Reply #2 on: October 15, 2015, 06:31:14 am »
Thank you for the reply. I tried adding this code to the equipt function but it just removed the weapon from both teams and I get this error in the console but I can't figure out what I did wrong. I stole the if statement from the init.lua file.

Code: Lua
  1. ITEM.Name = 'Permanant Gamma Shooter'
  2. ITEM.Price = 40000
  3. ITEM.Model = 'models/weapons/w_smg1.mdl'
  4. ITEM.WeaponClass = 'weapon_gammashooter'
  5. ITEM.SingleUse = false
  6.  
  7. function ITEM:OnBuy(ply)
  8.         ply:Give(self.WeaponClass)
  9.         ply:SelectWeapon(self.WeaponClass)
  10. end
  11.  
  12. function ITEM:OnSell(ply)
  13.         ply:StripWeapon(self.WeaponClass)
  14. end
  15.  
  16.  
  17. function ITEM:OnEquip(ply)
  18.         if pl:Team() == TEAM_HUNTERS then
  19.                 ply:Give(self.WeaponClass)
  20.                 ply:SelectWeapon(self.WeaponClass)
  21.         end
  22. end
  23.  
  24. function ITEM:OnHolster(ply)
  25.         ply:StripWeapon(self.WeaponClass)
  26. end
  27.  
  28. local function PlayerLoadout( ply )
  29.         ply:Give(self.WeaponClass)
  30. end

And I get this console error
[ERROR] addons/pointshop-master/lua/pointshop/items/weapons/gammashooter.lua:18:attempt to index global 'ITEM' (a nil value)
and
[ERROR] addons/pointshop-master/lua/pointshop/items/weapons/gammashooter.lua:18:attempt to index global 'pl' (a nil value)

Offline DJX

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
Re: Prop Hunt server; Props getting weapons from the pointshop
« Reply #3 on: October 15, 2015, 06:37:12 am »
I figured out my error, I changed pl in the if statement for ply and that fixed it!
Thank you very much!

  • Print