Help: Pointshop OnBuy(ply) Function

You know every time you buy an Item in Pointshop it automatically equips, I want to prevent that, I tried a lot but nothing seems to work.
Anyways this is my current Script //which doesn’t work

By The Way could someone tell me why the script don’t works. Would be happy to know how to fix this :)! Thaanks <3
[lua]

if SERVER then
local plymeta = FindMetaTable( “Player” )
if not plymeta then return end
plymeta.notequip = false
end

function ITEM:OnBuy(ply)
ply.notequip = false
timer.Simple( 1, function() ply.notequip = true end)
end

function ITEM:OnEquip(ply, modifications)
if ply.notequip == true then
ply:PS_AddClientsideModel(self.ID)
end
end

function ITEM:OnHolster(ply)
end

function ITEM:ModifyClientsideModel(ply, model, pos, ang)
model:SetColor(Color(0,255,0))
return model, pos, ang
end

[/lua]

what does it say?
any errors?
Actully, go to addons/pointshop-master/lua/sv_player_extension.lua, go to line 247, and you’ll see this:


	self:PS_EquipItem(item_id)

Remove it.
It should work.

But I only want it to not equip for this swep :confused: not for all.
pm: I don’t get any errors. It just dont works

ahh i see.
well what you’ll need to do is this:

I dont promise that it’ll work, just guessing it should be that way.
Use the item_id instead there.
by the way since im new to lua, i might be an idiot, and fuck your script up, if it happens sorry :wink:

It doesn’t work I tried that already.
Little Information: I don’t want it to equip at all, In youre method it equips then de-equips!
:frowning:

Check sv_player_exentsion, and you should find everything you need. Basically, PS_BuyItem and PS_EquipItem both have a PS_CanPerformAction check inside this them.

Remove this line:
https://github.com/adamdburton/pointshop/blob/master/lua/sv_player_extension.lua#L247

he wants it to only happen on that item.

I don’t want to change the main code :).

Could you instead tell me whats wrong with my code, or send me a fixed version?

Well as you can see, the function already tells it to equip it, i’m afraid you’ll need to create another function, remove the part where is says to equip it, find it where it is being used, and use that function instead IF its that itemid.

There is another way I know, I saw it on another server

You can actully add in the buying process, if itemid = the id, then return, just before the equip function :stuck_out_tongue:
didn’t think of that.



	self:PS_GiveItem(item_id)
	if item_id == "YOURID then
		return
	end
	self:PS_EquipItem(item_id)
end

Think this should work.

Didn’t understand where should I put this script?

go to addons/pointshop-master/lua/sv_player_extension.lua, go to line 247.
then between self:PS_GiveItem(item_id) and self:PS_EquipItem(item_id)
add this:


if item_id == "YOURID" then
		return
	end

and type your item id instead of the YOURID.

understand, :confused: but i dont wanna change the main code :smiley:

it wont do anything… :stuck_out_tongue:
if it does, just remove it.

I know but if an update comes out I have to do extra work xD :DD and between I mean multiple Items

Right :stuck_out_tongue:
Well you can allways add “or” in between, but yeah, ok :stuck_out_tongue:

I tried it with convars xD but didnt work too. :smiley: