Forum

> > CS2D > Scripts > Change the "E" for double click E for come a menu
Forums overviewCS2D overview Scripts overviewLog in to reply

English Change the "E" for double click E for come a menu

17 replies
To the start Previous 1 Next To the start

old Change the "E" for double click E for come a menu

haha1955
User Off Offline

Quote
so guys, when your click just one "e" come a menu, pls help me to change this for double "e"

-- EEEE

addhook("use","usechat")
function usechat(id,event)
     if event == 0 then
                if (player(id,"team")==2) then
                menu(id,"C-Terrorist Command,Don't do that!,Don't break your cuffs!,Return to your cell!,Follow me!, Halt!, Last warning!, Drop everything!, Go there!, Go scan!")
          end
           if (player(id,"team")==1) then
                menu(id, "Terrorist Command,Sorry!,I need health.,I don't need to go there.,I don't have anything!,I'm not your prisoner,I'm not armed!,Please open this!,Please stop shooting!,Please let me have freetime.")
          end
     end
end

addhook("menu", "menuchat")
function menuchat(id, title,b)
if title == "C-Terrorist Command" then
if b==1 then
msg("\169050150255"..player(id,"name")..": \169255220000Don't do that!")
                end
edited 1×, last 09.05.19 01:22:25 pm

old Re: Change the "E" for double click E for come a menu

Gaios
Reviewer Off Offline

Quote
Add this code to your script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
click_users = {}
for id = 1, 32 do
    click_users[id] = nil
end
function isDoubleUse(id)
    local last_click = click_users[id]
    if not last_click then
        click_users[id] = os.time()
        return false
    end
    if last_click == os.time() then
        click_users[id] = nil
        return true
    end
    return false
end

And then use it like this:

1
2
3
if event == 0 and isDoubleClick(id) then
    ...
end

old Re: Change the "E" for double click E for come a menu

haha1955
User Off Offline

Quote
@user Gaios: LUA ERROR: sys/lua/AS/main.lua:152: unexpected symbol near '...'

he can not read the ...

if event == 0 and isDoubleClick(id) then
...
end

its error


LUA ERROR: sys/lua/AS/main.lua:159: attempt to call global 'isDoubleClick' (a nil value)
-> sys/lua/AS/main.lua:159: in function <sys/lua/AS/main.lua:158>
-> in Lua hook 'use', params: 1, 0, 0, 0, 0
edited 1×, last 09.05.19 01:23:02 pm

old Re: Change the "E" for double click E for come a menu

haha1955
User Off Offline

Quote
@user Mami Tomoe: ok what is here the fail? its not worked, you can not use double e for open menu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- EEEEE

click_users = {}
for id = 1, 32 do
    click_users[id] = nil
end

addhook("use","usechat")
function usechat(id,event)
    if event == 0 and isDoubleUse(id)==true then
             if (player(id,"team")==2) then 
             menu(id,"C-Terrorist Command,Don't do that!,Don't break your cuffs!,Return to your cell!,Follow me!, Halt!, Last warning!, Drop everything!, Go there!, Go scan!")
        end
         if (player(id,"team")==1) then
             menu(id, "Terrorist Command,Sorry!,I need health.,I don't need to go there.,I don't have anything!,I'm not your prisoner,I'm not armed!,Please open this!,Please stop shooting!,Please let me have freetime.")
        end
    end
end

addhook("use","isDoubleUse")
function isDoubleUse(id)
    local last_click = click_users[id]
    if not last_click then
        click_users[id] = os.time()
        return false
    end
    if last_click == os.time() then
        click_users[id] = nil
        return true
    end
    return false
end
edited 1×, last 10.05.19 01:24:35 am

old Re: Change the "E" for double click E for come a menu

Mami Tomoe
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
click_users = {}

for id = 1, 32 do
    click_users[id] = nil
end

addhook('use', '_use')
function _use(id, event)
	if event == 0 and IsDoubleUse(id) and player(id, 'health') > 0 then
		if player(id, 'team') > 1 then 
             menu(id,"CT Command,Don't do that!,Don't break your cuffs!,Return to your cell!,Follow me!, Halt!, Last warning!, Drop everything!, Go there!, Go scan!")
        else
             menu(id, "T Command,Sorry!,I need health.,I don't need to go there.,I don't have anything!,I'm not your prisoner,I'm not armed!,Please open this!,Please stop shooting!,Please let me have freetime.")
        end
    end
end

function IsDoubleUse(id)
    local last_click = click_users[id]
	
    if not last_click then
        click_users[id] = os.time()
        return false
    end
	
    if last_click == os.time() then
        click_users[id] = nil
        return true
    end
	
    return false
end

Try this?

old Re: Change the "E" for double click E for come a menu

TrialAndError
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
local click_users = {}

addhook('use', '_use')
function _use(id, event)
    if event == 0 and IsDoubleUse(id) and player(id, 'health') > 0 then
        if player(id, 'team') > 1 then
            menu(id,"CT Command,Don't do that!,Don't break your cuffs!,Return to your cell!,Follow me!, Halt!, Last warning!, Drop everything!, Go there!, Go scan!")
        else
            menu(id, "T Command,Sorry!,I need health.,I don't need to go there.,I don't have anything!,I'm not your prisoner,I'm not armed!,Please open this!,Please stop shooting!,Please let me have freetime.")
        end
    end
end

function IsDoubleUse(id)
    if click_users[id] == os.time() then
        click_users[id] = nil
        return true
    end

    click_users[id] = os.time()
    return false
end

old Re: Change the "E" for double click E for come a menu

TrialAndError
User Off Offline

Quote
Try this and see if it works

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
--Helper Variables
local click_users = {}
local commands = {
    CT = {"Don't do that!", "Don't break your cuffs!", "Return to your cell!", "Follow me!", "Halt!", "Last warning!", "Drop everything!", "Go there!", "Go scan!"},
    T = {"Sorry!", "I need health.", "I don't need to go there.", "I don't have anything", "I'm not your prisoner!", "I'm not armed!", "Please open this!", "Please stop shooting!", "Please let me have freetime!"},

    CT_Title = "CT Commands",
    T_Title = "T Commands"
}

local Menu_CTCommands = commands.CT_Title .. "," .. table.concat(commands.CT, ",")
local Menu_TCommands =  commands.T_Title  .. "," .. table.concat(commands.T, ",")

--Helper Functions
function IsDoubleUse(id)
    if click_users[id] == os.time() then
        click_users[id] = nil
        return true
    end

    click_users[id] = os.time()
    return false
end

function say(id, message)
    local messageColor = "\169255220000"
    local nameColor = player(id,"team") == 1 and "\169255025000" or player(id,"team") == 2 and "\169050150255" or messageColor
    local name = nameColor .. player(id, "name") .. messageColor .. (player(id,"health") == 0 and " *DEAD*" or "")
    local message = messageColor .. message
    msg(name .. ": " .. message)
end

--Init Hooks
addhook('menu', 'hook_Menu')
addhook('use', 'hook_Use')

--Hook Callbacks
function hook_Use(id, event)
    if event == 0 and IsDoubleUse(id) and player(id, 'health') > 0 then
        if player(id, 'team') > 1 then
            menu(id, Menu_CTCommands)
        else
            menu(id, Menu_TCommands)
        end
    end
end

function hook_Menu(id, title, button)
    if title == commands.CT_Title then
        say(id, commands.CT[button])
    elseif title == commands.T_Title then
        say(id, commands.T[button])
    end
end

old Re: Change the "E" for double click E for come a menu

haha1955
User Off Offline

Quote
@user TrialAndError: this script gives erros, does not work properly, and if it works then still some settings must be set. when ts kill ct he mus in the wanted list

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
parse("mp_hudscale 1")

addhook("ms100", "_ms100")
addhook("die", "died")
addhook("leave", "left")
addhook("name", "name")
addhook("startround", "roundrestart")
max_kills = 0
b = {}
c = {}
 
if(f1 ~= 1) then
	a = {} 
	for i = 1, 32, 1 do
		a[i] = 0
	end
	f1 = 1
	wantedHUDID = 34
end

function _ms100()
	parse('hudtxt 39 "\169255255255- Wanted List -" 20 130 0')
	end


function wantedDisplay()
	wantedNum = 1
	for j = 2, 32, 1 do
		num = 0
		parse('hudtxt '..'"'..j..' " "" 20 '..'"'..num..'"')
	end
	for k = 1, #a, 1 do
		b[k] = a[k]
	end
	c = sortPlayers(a)
	for j = 1, #c, 1 do
		if(a[tonumber(c[j])] > 0 and player(tonumber(c[j]), "health") > 0) then
			wantedNum = wantedNum + 1
			msg('\169255255000'..player(tonumber(c[j]), "name")..' \169255255255is now wanted')
			height = 117 + (wantedNum * 16)
			parse('hudtxt '..'"'..wantedNum..' "'..'"'..wantedLevel_color(tonumber(c[j]))..player(tonumber(c[j]), "name")..'"'..' 20 '..'"'..height..'"')
		end
	end
end

function died(victim, killer)
	
	if player(victim, 'exists') then
		if player(victim, 'team') == 1 then
			a[victim] = 0
		else
			if player(killer, 'team') == 1 then 
				wantedD = true
				a[killer] = a[killer] + 1
			end
		end
	end
	wantedDisplay()
end

function left(id)
	a[id] = 0
	wantedDisplay()
end

function name()
	wantedDisplay()
end

function roundrestart()
	wantedD = false
	for i = 1, 32 do
		a[i] = 0
	end
	wantedDisplay()
end

function wantedLevel_color(id)
	if a[id] == nil then return '\169255255000' end
	if a[id] == 2 then return '\169255180000' end
	if a[id] == 3 then return '\169255150000' end
	if a[id] == 4 then return '\169255100000' end
	if a[id] > 4 then return '\169255000000' end
	return '\169255255000'
end

function sortPlayers(a_array)
	for p = 1 , #b do
		maximum_id = findMax(b)
		c[p] = maximum_id
	end
	return c
end

function findMax(array)
	local flag = 0
	for id ,kills in pairs(array) do
		if (tonumber(max_kills) < tonumber(kills)) then 
			max_id = id
			max_kills = kills
			flag = 1
		end
	end
	if flag == 1 then 
		array[max_id] = -999
		max_kills = -1
	end
	return max_id
end
edited 1×, last 11.05.19 10:11:52 pm

old Re: Change the "E" for double click E for come a menu

TrialAndError
User Off Offline

Quote
user haha1955 has written
@user TrialAndError: this script gives erros, does not work properly, and if it works then still some settings must be set. when ts kill ct he mus in the wanted list


Doesn't help by pushing, it only makes it worse for you. The script you say you have problem with works fine for me.
Yet, again: not enough information. What is the error, what settings must be set?

That script also looks freshly downloaded from @user Ranu:'s file file cs2d [Ranw] Wanted List Script
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview