From 64a954a61b5d3bb9e564d81a739ee5a0da2784f1 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sat, 12 Oct 2019 23:41:40 +0200 Subject: [PATCH] Dont use misleading keys table --- client/main.lua | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/client/main.lua b/client/main.lua index d5e4f6d6..f5cb316e 100644 --- a/client/main.lua +++ b/client/main.lua @@ -6,21 +6,8 @@ Citizen.CreateThread(function() Citizen.Wait(0) end - local Keys = { - ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, - ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, - ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, - ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, - ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, - ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, - ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, - ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, - ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 - } - - local GUI = {} - GUI.Time = 0 - local MenuType = 'default' + local GUI, MenuType = {}, 'default' + GUI.Time = 0 local openMenu = function(namespace, name, data) SendNUIMessage({ @@ -29,7 +16,6 @@ Citizen.CreateThread(function() name = name, data = data }) - end local closeMenu = function(namespace, name) @@ -46,7 +32,7 @@ Citizen.CreateThread(function() RegisterNUICallback('menu_submit', function(data, cb) local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) - if menu.submit ~= nil then + if menu.submit then menu.submit(data, menu) end @@ -56,7 +42,7 @@ Citizen.CreateThread(function() RegisterNUICallback('menu_cancel', function(data, cb) local menu = ESX.UI.Menu.GetOpened(MenuType, data._namespace, data._name) - if menu.cancel ~= nil then + if menu.cancel then menu.cancel(data, menu) end @@ -77,7 +63,7 @@ Citizen.CreateThread(function() end - if menu.change ~= nil then + if menu.change then menu.change(data, menu) end @@ -89,7 +75,7 @@ Citizen.CreateThread(function() Citizen.Wait(10) - if IsControlPressed(0, Keys['ENTER']) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 150 then + if IsControlPressed(0, 18) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 150 then SendNUIMessage({ action = 'controlPressed', control = 'ENTER' @@ -98,7 +84,7 @@ Citizen.CreateThread(function() GUI.Time = GetGameTimer() end - if IsControlPressed(0, Keys['BACKSPACE']) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 150 then + if IsControlPressed(0, 177) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 150 then SendNUIMessage({ action = 'controlPressed', control = 'BACKSPACE' @@ -107,7 +93,7 @@ Citizen.CreateThread(function() GUI.Time = GetGameTimer() end - if IsControlPressed(0, Keys['TOP']) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 200 then + if IsControlPressed(0, 27) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 200 then SendNUIMessage({ action = 'controlPressed', control = 'TOP' @@ -116,7 +102,7 @@ Citizen.CreateThread(function() GUI.Time = GetGameTimer() end - if IsControlPressed(0, Keys['DOWN']) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 200 then + if IsControlPressed(0, 173) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 200 then SendNUIMessage({ action = 'controlPressed', control = 'DOWN' @@ -125,7 +111,7 @@ Citizen.CreateThread(function() GUI.Time = GetGameTimer() end - if IsControlPressed(0, Keys['LEFT']) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 150 then + if IsControlPressed(0, 174) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 150 then SendNUIMessage({ action = 'controlPressed', control = 'LEFT' @@ -134,7 +120,7 @@ Citizen.CreateThread(function() GUI.Time = GetGameTimer() end - if IsControlPressed(0, Keys['RIGHT']) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 150 then + if IsControlPressed(0, 175) and IsInputDisabled(0) and (GetGameTimer() - GUI.Time) > 150 then SendNUIMessage({ action = 'controlPressed', control = 'RIGHT'