Holster all equiped PS items?

I need help getting and holstering all PS items. This is for a script on coderhire, that makes custom minigames in TTT. I tried using the pointshops built in code to holster all entities (assuming all the items are ents) but that didn’t work. Any help would be appreciated



	function EVENT:HolsterPSItems()
		if ply:GetRole() == ROLE_TRAITOR then
			LocalPlayer():PS_HolsterItem(ents.GetAll())
		end
	end

I think he has a function that gets a table of all the items a player has, they technically aren’t really ents so you can’t use that.

From what i can see they are taken from “ply.PS_Items = {}” Which is what you see under the clear items function, but that would remove all of their items, so i would need to then get all the items that you would have and take them from you, then return them at the end of the round. Thats just what i see anyway. But that would lead back to finding a way to get all the PS items.

The only other way i can see doing this would be to list all the items id in the PS_HolsterItem()
or create a table and just stick all the items in there, and make it holster any items in there, but that would be a pain.

You could take that table, use a for loop in pairs to isolate items by checking the HasEquipped item id of each, then unequip it from the player.

Welp. Ive tried that, and ive tried an “if then” to find any items i had equipped and holster them. Neither worked or im doing it wrong :confused:

There’s code already in PointShop that does exactly what you’re asking.

https://github.com/adamdburton/pointshop/blob/master/lua/sv_player_extension.lua#L21

So i have


function HolsterItems()
		for item_id, item in pairs(self.PS_Items) do
			if ply:GetRole() == ROLE_TRAITOR then 
				if item.Equipped then
					local ITEM = PS.Items[item_id]
					ITEM:OnHolster(self, item.Modifiers)
				end
                        end 
                end
	end

Still doesnt work, would i need to change “ITEM:OnHolster(self, item.Modifiers)” to anything?

If that is literally your code then ‘self’ does not refer to anything. You need to use a player object.

Well thats not the entire code but thats the function the line is in, the rest i couldnt post as it is a script i paid for on CH. and the code is supposed to get any items you have equipped and holster them.

[editline]31st December 2013[/editline]

Well my last attempt at getting it to work for tonight worked somewhat. This is what it is now so if someone could help me fix any problems seen that would be great!


	function HolsterItems( )
		for item_id, item in pairs(self.PS_Items) do
			if ply:GetRole() == ROLE_TRAITOR then 
				if item.Equipped then
					local ITEM = PS.Items[item_id]
					ITEM:PS_HolsterItem(ITEM)
				end
                        end
               end
	end
	hook.Add( "PlayerSpawn", "HolsterItems", HolsterItems )

[editline]31st December 2013[/editline]

I take that back, the items just reset for some reason no actual fix there :confused:

[lua]
function HolsterItems( ply )
for item_id, item in pairs(ply.PS_Items) do
if ply:GetRole() == ROLE_TRAITOR 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]

This should work.