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

17 replies
Goto Page
To the start Previous 1 Next To the start
Up
haha1955
User
Offline Off
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
09.05.19 11:51:56 am
Up
Gaios
Security Supporter
Offline Off
Add this code to your script:

Code:
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:

Code:
1
2
3
if event == 0 and isDoubleClick(id) then
    ...
end
09.05.19 01:08:34 pm
Up
haha1955
User
Offline Off
@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
09.05.19 01:50:27 pm
Up
Goo
User
Offline Off
Haha you're supposed to place your code where the
...
is.
09.05.19 02:23:21 pm
Up
haha1955
User
Offline Off
@user Goo: ok what is here the fail? its not worked, you can not use double e for open menu
Code:
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
10.05.19 03:01:52 am
Up
Goo
User
Offline Off
Code:
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?
10.05.19 02:10:36 pm
Up
TrialAndError
User
Offline Off
Code:
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
10.05.19 02:53:03 pm
Up
haha1955
User
Offline Off
@user TrialAndError: double is now working, but cant see the chat when i use double e^^
10.05.19 03:08:30 pm
Up
Goo
User
Offline Off
You need to add a menu hook that checks for which menu you're on and what button you pressed.
10.05.19 03:30:36 pm
Up
TrialAndError
User
Offline Off
Try this and see if it works

Code:
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
10.05.19 04:22:07 pm
Up
haha1955
User
Offline Off
@user TrialAndError: its not working, and the double e its not worked just when your click one e come menu, and cant see the chat
10.05.19 04:25:33 pm
Up
TrialAndError
User
Offline Off
Any errors? Do you use it with another script. are you perhaps just adding the code at the end of your already existing code? I need more information.
10.05.19 04:36:37 pm
Up
haha1955
User
Offline Off
@user TrialAndError: ok have fixed it, its now working. thanks for helping.
edited 7×, last 10.05.19 07:09:45 pm
10.05.19 06:55:28 pm
Up
TrialAndError
User
Offline Off
@user haha1955: I still don't know, not getting enough information. It worked for me when I tested it.
10.05.19 07:12:57 pm
Up
haha1955
User
Offline Off
@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

Code:
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
11.05.19 10:24:06 pm
Up
TrialAndError
User
Offline Off
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 Ranw-X:'s file file cs2d [Ranw] Wanted List Script (5)
05.07.19 08:07:05 pm
Up
Ranw-X
User
Offline Off
@user haha1955: I am going to tell you to stop stealing my old jail scripts, I want know who sent you this, it's copy of my old jail quick menu.
VTA Community Discord: https://discord.gg/6rHKWvJ
06.07.19 01:30:57 am
Up
haha1955
User
Offline Off
@user Ranw-X: and? who cares?
To the start Previous 1 Next To the start