A little Pointshop Help

So I am making an item for pointshop so that someone needs to have the item equipped in order to double jump. I have it working fine on my private server which is hosted in windows 8.1 on my PC but when I move it over to my Linux DS then for some reason everyone can suddenly double jump with out needing the item equipped. I have no idea what is going on and if someone can help me I would greatly appreciate it, The code is down below.


ITEM.Name = 'Double Jump'
ITEM.Price = 15000
ITEM.Material = 'materials/pointshopicons/doublejump.png'


function ITEM:OnEquip(ply)
	local function doublejump(ply, key)
		if key == IN_JUMP then
			if !ply:IsOnGround() then
				if ply.FirstJump == 1 then
					ply:SetVelocity(Vector(0,0,300) + Vector(0,0,-1*ply:GetVelocity().z))
					ply.FirstJump = 0
				end
			else
				ply.FirstJump = 1
			end
		end
	end
	hook.Add("KeyPress", "doublejump", doublejump)
end

function ITEM:OnHolster(ply)
	hook.Remove("KeyPress", "doublejump", doublejump) 
end

You’re calling this on the server. This means that it makes it so everyone can double jump as soon as someone equips the item. It worked fine when you tested it on the PC because the only person there was you. A better way to do this would to hook into it outside of the OnEquip function and check for a variable on the player (something like ply.doublejump) and allow them to double jump based on that. Take a look:



ITEM.Name = 'Double Jump'
ITEM.Price = 15000
ITEM.Material = 'materials/pointshopicons/doublejump.png'


function ITEM:OnEquip(ply)
	ply.doublejump = true
end

function ITEM:OnHolster(ply)
	ply.doublejump = false
end

hook.Add('KeyPress', 'DoDoubleJump', function(ply, key)
	if key == IN_JUMP and ply.doublejump then
		if !ply:IsOnGround() then
			if ply.FirstJump == 1 then
				ply:SetVelocity(Vector(0,0,300) + Vector(0,0,-1*ply:GetVelocity().z))
				ply.FirstJump = 0
			end
		else
			ply.FirstJump = 1
		end
	end
end)


You can add something like this to ensure the player owns the item and has it equipped…:


hook.Add( "SetupMove", "Acecool:PointShop:AutoBunnyHop", function( _p, _movedata, _cmd )
	if ( IsValid( _p ) && _p.PS_HasItemEquipped && _p:PS_HasItemEquipped( _filename ) ) then

	end
end );	

I don’t recommend using the pointshop hook system ( ie ITEM:SetupMove ) which you did avoid, so +1 there. I would also NOT add the hook inside your on equip… Simply create a hook which is called per player for movement, ie SetupMove and handle everything there…

Here’s a frictionless auto-hop system: https://dl.dropboxusercontent.com/u/26074909/tutoring/player_movement/auto_hop_bunnyhop.lua.html and as pointshop 1 item: https://dl.dropboxusercontent.com/u/26074909/tutoring/pointshop/frictionless_autohop_item/sh_frictionless_autohop_item.lua.html - remove .html to view .lua

The issue with your method of adding hooks is this: Player 1 equips item and enables double-jump. Player 2 enables then disables double-jump. Player 1 can no longer double-jump…

If you do use hooks like that, then they need to be uniquely named, however there is no reason to create multiple hooks for this when there’s already movement hooks available and usable by us.

Thank you both very much, I have learned a lot and appreciate your help :slight_smile: