Forum

> > CS2D > Scripts > [Solved]Twice "E" (use) opens a menu
Forums overviewCS2D overview Scripts overviewLog in to reply

English [Solved]Twice "E" (use) opens a menu

10 replies
To the start Previous 1 Next To the start

old Re: [Solved]Twice "E" (use) opens a menu

DC
Admin Off Offline

Quote
Lua scripts are executed on the server and the server does not receive client input unless a certain action is bound to it.

E is by default bound to "use" but the hook cs2d lua hook use is only triggered when you actually use something and not when you just press the key without pointing at anything usable.

So in short: Not possible unless the client manually binds the serveraction to that key (in the controls menu). In that case you could use the cs2d lua hook serveraction hook. By default the serveractions are bound to F2, F3 and F4 I think so you could use these keys instead.

old Re: [Solved]Twice "E" (use) opens a menu

Starkkz
Moderator Off Offline

Quote
@user DC: Are you sure? If I recall correctly I've used the "use" hook without being actually using something.
IMG:https://i.imgur.com/jX89qh0.jpg


@user Ajmin: I'm not sure if this would work, try it.
1
2
3
4
5
6
7
8
PlayerLastUse = {}
addhook("use","UseTwice")
function UseTwice(id, event)
	if PlayerLastUse[id] and os.clock() - PlayerLastUse[id] < 0.5 then
		-- Open the menu
	end
	PlayerLastUse[id] = os.clock()
end
edited 2×, last 05.12.14 03:07:57 pm

old Re: [Solved]Twice "E" (use) opens a menu

_Yank
User Off Offline

Quote
I wont post the code here, I think that would be kinda disrespectful to Fws. But here's a quick remake of it, (didn't tested)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
pressInterval = 600
pPresses = {}
for i = 1, 32 do pPresses[id] = 0 end

function pPress(id, event)
	if event == 0 then
		pPresses[id] = pPresses[id] + 1
		
		freetimer(pressInterval, "kPresses", id)
		timer(pressInterval, "kPresses", id)
		
		if pPresses[id] >= 2 then -- You can change it for example you want penta press O.o
			-- Do da stuff
		end
	end
end

function kPresses(id)
	pPresses[id] = 0
end

addhook("use","pPress")
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview