• TTT Pointshop Restrict Group Equip
    7 replies, posted
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. [CODE]ITEM.AllowedUserGroups = { "vipgold", "vip", "viptop", "headadmin", "superadmin", "admin", "owner", "vipsilver" }[/CODE]
Return true or false in this function based on the users group. [url]http://pointshop.burt0n.net/items/functions#can-player-equip[/url]
[QUOTE=adamdburton;47557740]Return true or false in this function based on the users group. [url]http://pointshop.burt0n.net/items/functions#can-player-equip[/url][/QUOTE] Ooooo Undefined answered my question Thanks :dance: [editline]19th April 2015[/editline] [QUOTE=adamdburton;47557740]Return true or false in this function based on the users group. [url]http://pointshop.burt0n.net/items/functions#can-player-equip[/url][/QUOTE] Doesn't seem to be working? [code]function ITEM:OnEquip(ply, modifications) if ply:IsUserGroup("vip") then ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end end [/code]
Add "return true" after "ply:SelectWeapon(self.WeaponClass)" and before the first "end".
[QUOTE=Aeternal;47559331]Add "return true" after "ply:SelectWeapon(self.WeaponClass)" and before the first "end".[/QUOTE] 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? [code]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[/code]
[QUOTE=monstermega10;47559708]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? [code]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[/code][/QUOTE] [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]
[QUOTE=adamdburton;47561865]Holy hell, what a mess. [lua] function ITEM:CanPlayerEquip(ply) return table.HasValue(self.AllowedUserGroups, ply:PS_GetUsergroup()) end [/lua][/QUOTE] For some weird reason, the players don't respawn with the equipped weapon. [code] 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[/code]
Sorry, you need to Log In to post a reply to this thread.