Binding keys from lua

Hi,
i want creat module for force players bind key for open a cutom Inventory

I created to addons/customInv/lua/

sv_customInv.lua

hook.Add(“PlayerKeyPress”,“BindMenu”,function(pl,key)
if key == KEY_F3 then openInventory()
end)

i want wen players press F3 open my menu Inv

by default Inventory open by PlayerSay

is possible add this or something this
hook.Add(“PlayerSay”, “PlayerKeyPress”, function( ply, text, team )
if text == “/inv” then
if key == KEY_F3 then
end

	net.Start("openInventory")

thx for reply

Clientsided chat script



hook.Add('OnPlayerChat', 'Inv', function(ply, text)
	if ply != LocalPlayer() then return end

	if text == '/inv' then
    		openInventory()
	end
end)


Also, there is no PlayerKeyPress hook, here is the table http://wiki.garrysmod.com/page/Category:GM_Hooks

by default my inv have this
hook.Add(“PlayerSay”, “INV_Say”, function( ply, text, team )
if text == “/inv” then
end

	net.Start("openInventory")

but I want creat module for open this by press key
exemple

hook.Add(“PlayerKeyPress”,“BindMenu”,function(pl,key)
if key == KEY_F3 then openInventory()
end)


hook.Add('ShowSpare1', 'Inv', function(ply)
	net.Start("openInventory")
	-- part of code from your PlayerSay
	-- ends with net.Send(ply)
end)

thx for reply

I creat this to addons/custominv/lua/sv_inv.lua ?

Just append file with PlayerSay hook

I changed PlayerSAY by

hook.Add(‘ShowSpare1’, ‘inv’, function(ply)
– if text == “/inv” then
if ply.inv == nil then
ply.inv = {}
end

	net.Start("openInventory")
	net.WriteTable(ply.inv)

– net.Send(ply)
return “”

end)

but don’t work



hook.Add('ShowSpare1', 'inv', function(ply)
	if ply.inv == nil then
		ply.inv = {}
	end

	net.Start("openInventory")
		net.WriteTable(ply.inv)
	net.Send(ply)
end)


Try this

BTW, Seems like a paid script from scriptfodder :ohno:

Thx work now