PointShop unequip items when demoted from VIP!

Ok basically I have a group in ulx called VIP and they get everything for free in pointshop and I want to make it so if you demote them they get all their items they have equiped removed for example I buy a vip hat but I start breaking the rules so if I had to be demoted for some reason I would lose all the items I was wearing such as the hat!

I hope someone knows some code like that

Try
[lua]function ITEM:OnEquip(ply)
if ply:IsUserGroup(“GROUPNAME”) then
–CODE HERE
end
end[/lua]

Don’t know why you would want a vip to have everything for free, it defeats the purpose of earning points. Just my opinion.

@Blackout338 So where do I add this code and if I add it when they are demoted from VIP it will unequip all their items?

In the pointshop items

@Blackout Every single item I have about 200

Why do you have 200 items in pointshop? The amount of downloads people will have when they join would be insane.

You got any code that I could put in a file and it would add to all of them?

Try this
[lua] function HolsterItems( ply )
for item_id, item in pairs(ply.PS_Items) do
if !ply:IsUserGroup(“GROUPNAME”) then
if item.Equipped then
local ITEM = PS.Items[item_id]
ITEM:OnHolster(ply, item.Modifications)
end
end
end
end
hook.Add( “PlayerSpawn”, “HolsterItems”, HolsterItems )[/lua]
You will need to add all of your groups above vip otherwise it will unequip all items for everyone who isn’t vip. So change ‘if !ply:IsUserGroup(“vip”) then’ to ‘if !ply:IsUserGroup(“vip”) or !ply:IsUserGroup(“admin”) or !ply:IsUserGroup(“owner”) then’.

function HolsterItems( ply )
for item_id, item in pairs(ply.PS_Items) do
if !ply:IsUserGroup(“GROUPNAME”) then
if item.Equipped then
local ITEM = PS.Items[item_id]
ITEM:OnHolster(ply, item.Modifications)
end
end
end
end
hook.Add( “PlayerSpawn”, “HolsterItems”, HolsterItems )

I added this code to an afro and then demoted myself from superadmin to user and the afro did not de-equip

please note: I also want it to sell the VIP item aswell because when they are demoted they lose the item

Don’t add that to the items you can put that into a file in autorun/server
Add this for sell items[lua]
function SellItems( ply )
for item_id, item in pairs(ply.PS_Items) do
if !ply:IsUserGroup(“GROUPNAME”) then
if ply:PS_HasItem(item_id) then
local ITEM = PS.Items[item_id]
ITEM:OnSell(ply)
end
end
end
end
hook.Add( “PlayerSpawn”, “SellItems”, SellItems )[/lua]

I have a group called VIP and SuperVip and I wan’t it to sell and unequip if they get demoted to the group user

So what code do I put into autorun to do that?

It seems that if any user has items they will be holstered and sold when they spawn so I’ve made a command that’ll demote the player and sell and holster their items. It’s untested but if anyone sees anything wrong feel free to point it out as I’m no expert with lua. c: (Already had to edit it because I missed something ;-:wink:
[lua]local function FindTargetPlayer(str)

for _,tar in ipairs(player.GetAll()) do
	if string.find(string.lower(tar:Nick()),string.lower(str)) then
		return tar
	end
end

end

local function DemoteCommand(ply, args,target)

if args[1] == "!demote" then

	local target = FindTargetPlayer(args[2], ply)

	if ply:IsUserGroup("owner") then
		if target == nil then
			ply:ChatPrint("Target is invalid.")
		else
		RunConsoleCommand("ulx removeuser "..target)
			for item_id, item in pairs(target.PS_Items) do
				if target:PS_HasItem(item_id) then
					local ITEM = PS.Items[item_id]
					ITEM:OnSell(ply)
				elseif target:PS_HasItemEquipped(item_id) then
					local ITEM = PS.Items[item_id]
					ITEM:OnHolster(ply, item.Modifications)
				end
			end
		end	
	else
		ply:ChatPrint("You don't have permission to use this command.")
	end	
end

end

function getChatCommand(ply,text,public)

local args = string.Explode(" ",text)


DemoteCommand(ply,args)

end
hook.Add(“PlayerSay”,“getChatCommand”,getChatCommand)[/lua]
You can make a file called demote.lua or something and include it in the init.

@blackout

I put on a load of gear and typed !demote moltocraft and it did nothing at all :frowning:

Any error?

@blackout None that I can see can re recheck your code for errors or test it?