-
Notifications
You must be signed in to change notification settings - Fork 0
/
JdxBinds.lua
180 lines (168 loc) · 4.34 KB
/
JdxBinds.lua
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
local function ShowCursor()
if isCursorShowing() then
showCursor(false);
else
showCursor(true);
end
end
local IsActiveLMouseDown = false;
local IsActiveLMousePressed = false;
local IsActiveKeyDown = false;
local IsActiveLShiftDown = false;
local IsActiveMouseWheelUp = false;
local IsActiveMouseWheelDown = false;
local IsActiveLAltDown = false;
local Language = "en";
local ActiveButton = "";
function IsLMouseDown()
if IsActiveLMouseDown then
IsActiveLMouseDown = false;
return true;
end
return false;
end
function IsLMousePressed()
return IsActiveLMousePressed;
end
function IsKeyDown()
if ActiveButton ~= "" then
local result = ActiveButton;
ActiveButton = "";
return result;
end
return "";
end
function IsMouseWheelUp()
if IsActiveMouseWheelUp then
IsActiveMouseWheelUp = false;
return true;
end
return false;
end
function IsMouseWheelDown()
if IsActiveMouseWheelDown then
IsActiveMouseWheelDown = false;
return true;
end
return false;
end
local function BindKeys()
bindKey("x", "down", ShowCursor);
bindKey("mouse1", "down", function()
IsActiveLMouseDown = true;
IsActiveLMousePressed = true;
end);
bindKey("mouse1", "up", function()
IsActiveLMouseDown = false;
IsActiveLMousePressed = false;
end);
bindKey("lshift", "down", function()
IsActiveLShiftDown = true;
end);
bindKey("lshift", "up", function()
IsActiveLShiftDown = false;
end);
bindKey("lalt", "down", function()
IsActiveLAltDown = true;
end);
bindKey("lalt", "up", function()
IsActiveLAltDown = false;
end);
bindKey("mouse_wheel_up", "down", function()
IsActiveMouseWheelUp = true;
end);
bindKey("mouse_wheel_down", "down", function()
IsActiveMouseWheelDown = true;
end);
bindKey("mouse_wheel_up", "up", function()
IsActiveMouseWheelUp = false;
end);
bindKey("mouse_wheel_down", "up", function()
IsActiveMouseWheelDown = false;
end);
end
function IsChangeLanguage()
return
end
function onClientKey(button, press)
local ru = {
["q"] = "й",
["w"] = "ц",
["e"] = "у",
["r"] = "к",
["t"] = "е",
["y"] = "н",
["u"] = "г",
["i"] = "ш",
["o"] = "щ",
["p"] = "з",
["["] = "х",
["]"] = "ъ",
["a"] = "ф",
["s"] = "ы",
["d"] = "в",
["f"] = "а",
["g"] = "п",
["h"] = "р",
["j"] = "о",
["k"] = "л",
["l"] = "д",
[";"] = "ж",
["\'"] = "э",
["z"] = "я",
["x"] = "ч",
["c"] = "с",
["v"] = "м",
["b"] = "и",
["n"] = "т",
["m"] = "ь",
[","] = "б",
["."] = "ю",
["/"] = ".",
["?"] = ","
}
IsActiveKeyDown = not IsActiveKeyDown;
if IsActiveLShiftDown and IsActiveLAltDown then
if Language == "en" then
Language = "ru";
else
Language = "en";
end
end
if IsActiveKeyDown then
if #button == 1 or button == "backspace" or button == "space" then
if button == "space" then
ActiveButton = " ";
return;
end
if IsActiveLShiftDown then
button = string.upper(button);
local buttons = {
["-"] = "_",
["="] = "+",
["1"] = "!",
["2"] = "@",
["3"] = "#",
["4"] = "$",
["5"] = "%",
["6"] = "^",
["7"] = "&",
["8"] = "*",
["9"] = "(",
["0"] = ")",
["/"] = "?"
}
if buttons[button] then button = buttons[button] end
end
if Language == "ru" and button ~= "backspace" then
button = ru[button];
end
ActiveButton = button;
return;
end
else
ActiveButton = "";
end
end
addEventHandler("onClientResourceStart", root, BindKeys);
addEventHandler("onClientKey", root, onClientKey)