When player presses key, since it's think, does function 100 times
5 replies, posted
[CODE]
function KeyPress()
if(input.IsKeyDown(KEY_F6)) then
factionDerma();
end
end
hook.Add("Think","BM - Clients - Key",KeyPress)
[/CODE]
factionDerma() gets called allot, I tried input.WasKeyPressed, but then it says "Not playing a local game"
Check if the panel you're creating is already visible?
[QUOTE=Inelegant;44521650][CODE]hook.Add( "PlayerBindPress", "BindsManager:PlayerBindPress", function( _p, bind, pressed )
local key = string.upper( input.LookupBinding( bind ) )
local _key = "KEY_" .. key;
print( "String Key: ", _key, " Pressed:", pressed, " Key Bound To:", key, " Bind: ", bind )
end );
-- acecool[/CODE][/QUOTE]
I believe this only works for IN_ keys on serverside
EDIT:
I changed it to this:
[CODE]
if(input.WasKeyPressed(KEY_F6) and !DermaPanel:IsVisible()) then
[/CODE]
(The derma panel is called DermaPanel)
and it says I am not playing on a local game
[CODE]local pressed = false
hook.Add("Think", "Think_DermaPanel", function()
if input.IsKeyDown(KEY_F6) then
if not pressed then
pressed = true
if ValidPanel(DermaPanel) and DermaPanel:IsVisible() then
DermaPanel:Close()
return false
else
factionDerma()
end
end
else
pressed = false
end
end)[/CODE]
[QUOTE=Inelegant;44521721][CODE]local pressed = false
hook.Add("Think", "Think_DermaPanel", function()
if input.IsKeyDown(KEY_F6) then
if not pressed then
pressed = true
if ValidPanel(DermaPanel) and DermaPanel:IsVisible() then
DermaPanel:Close()
return false
else
factionDerma()
end
end
else
pressed = false
end
end)[/CODE][/QUOTE]
Cheers, works great, thanks
Sorry, you need to Log In to post a reply to this thread.