Forum

> > CS2D > Scripts > [Solved]Twice "E" (use) opens a menu
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

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

10 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

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

DC
Admin Off Offline

Zitieren
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.

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

Starkkz
Moderator Off Offline

Zitieren
@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
2× editiert, zuletzt 05.12.14 15:07:57

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

_Yank
User Off Offline

Zitieren
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")
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht