Code:
[url]http://paste.ubuntu.com/10097031/[/url]
Basically I just need F4 to open the menu (run that con command) but it does not seem to work :/
Examples using the serverside hook for F1-F4 or using PlayerBindPress: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/open_vgui_based_on_keypress.lua.html[/url]
remove .html to view .lua
[QUOTE=Judd;47088414]Code:
[url]http://paste.ubuntu.com/10097031/[/url]
Basically I just need F4 to open the menu (run that con command) but it does not seem to work :/[/QUOTE]
You are running that command for every key execpt F4. You are also not defining ply, as you have it garbage collected (with an "_").
[code]
hook.Add( "PlayerButtonDown", "pht.menu", function( ply, key )
if key == KEY_F4 then ply:ConCommand("echo hello!") end
end )
[/code]
[QUOTE=Pandaman09;47088478]You are running that command for every key execpt F4. You are also not defining ply, as you have it garbage collected (with an "_").
[code]
hook.Add( "PlayerButtonDown", "pht.menu", function( ply, key )
if key == KEY_F4 then ply:ConCommand("echo hello!") end
end )
[/code][/QUOTE]
Awesome thanks! Got it working now!
Also just incase someone reads this I'm also getting:
attempt to call method 'KeyPressed' (a nil value)
code:
[url]http://paste.ubuntu.com/10097330/[/url]
Not sure whats wrong there either
[QUOTE=Judd;47088552]Awesome thanks! Got it working now!
Also just incase someone reads this I'm also getting:
attempt to call method 'KeyPressed' (a nil value)
code:
[url]http://paste.ubuntu.com/10097330/[/url]
Not sure whats wrong there either[/QUOTE]
[url]http://pointshop.burt0n.net/items/hooks[/url]
This may help a bit.
Also, don't use Entity(1) unless you are debugging.
Use LocalPlayer() if you are running code on a client and want the... you guessed it, local player.
Use the player object (usually returned in a hook, or function) in server sided code.
So for your example, according to the documentation for pointshop you cannot use hook.Add
[code]
local taunting = false
function ITEM:PlayerButtonDown(ply, modification, ply2, key)
if key == KEY_USE and not taunting then
ply2:PS_Taunt() --i'm using ply2 simply because that is what is returned by the hook. Not sure if ply can be another person
end
end
[/code]
P.s. this is untested since I do not have pointshop or a taunt function.
EDIT: turns out pointshop returns two variables before the rest. fixed code.
Adding that code seems to break my pointshop (that hook was not on the individual item, it was in the cl_init.lua for the pointshop)
[QUOTE=Judd;47088690]Adding that code seems to break my pointshop (that hook was not on the individual item, it was in the cl_init.lua for the pointshop)[/QUOTE]
Oops, I assumed it was for an item. What are you trying to do. If you want an item to do something, you should do that in the item, you should not modify pointshop directly.
Sorry, you need to Log In to post a reply to this thread.