TTT Pointshop Restrict Group Equip

I’m looking for a way to restrict item equip access using ulx user group.
I restricted my donor weapons for certain groups.
But i also have a trade system where players are allowed to trade any weapon. Pointshop allows you to restrict certain groups from purchasing that item but not equipping.
So as a regular, I would be able to equip a donor item traded to me but I wont be able to purchase or sell it.

This configuration only allows certain groups to purchase that item, but doesn’t restrict non added groups from equipping.


ITEM.AllowedUserGroups =  { "vipgold", "vip", "viptop", "headadmin", "superadmin", "admin", "owner", "vipsilver" }

Return true or false in this function based on the users group.

Ooooo Undefined answered my question
Thanks :dance:

[editline]19th April 2015[/editline]

Doesn’t seem to be working?


function ITEM:OnEquip(ply, modifications)
     if ply:IsUserGroup("vip") then
ply:Give(self.WeaponClass)
ply:SelectWeapon(self.WeaponClass)
end
end 


Add “return true” after “ply:SelectWeapon(self.WeaponClass)” and before the first “end”.

Thank you, that works now.
One more thing, if you wouldn’t mind answering, is there a better way to add groups rather than doing this?


if ply:IsUserGroup("vip") or ply:IsUserGroup("vipgold") or ply:IsUserGroup("topvip")  or ply:IsUserGroup("headadmin")  or ply:IsUserGroup("superadmin")  or ply:IsUserGroup("admin")  or ply:IsUserGroup("owner")  or ply:IsUserGroup("vipsilver") then

[lua]

local usergroups = {“vip”, “vipgold”, “topvip”, “everything else you want to add” }
if ( table.HasValue( usergroups, ply:GetUserGroup() ) ) then

end
[/lua]

Holy hell, what a mess.

[lua]
function ITEM:CanPlayerEquip(ply)
return table.HasValue(self.AllowedUserGroups, ply:PS_GetUsergroup())
end
[/lua]

For some weird reason, the players don’t respawn with the equipped weapon.



function ITEM:CanPlayerEquip(ply, modifications)
	if not ply._OldModel then
		ply._OldModel = ply:GetModel()
	end
	
    if table.HasValue(self.AllowedUserGroups, ply:PS_GetUsergroup()) then
		ply:Give(self.WeaponClass)
		ply:SelectWeapon(self.WeaponClass)
		timer.Simple(2, function() ply:SetModel(self.Model) end)
	return true
end
end