diff --git a/client/main.lua b/client/main.lua index 0249ab82..dd69b91f 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,40 +1,21 @@ -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 = {} -local PhoneData = { phoneNumber = 0, contacts = {} } -local CurrentAction = nil -local CurrentActionMsg = '' -local CurrentActionData = {} -local CurrentDispatchRequestId = -1 -local PhoneNumberSources = {} - -ESX = nil -GUI.PhoneIsShowed = false -GUI.MessagesIsShowed = false -GUI.AddContactIsShowed = false +local GUI, PhoneData, CurrentActionData, PhoneNumberSources, CurrentDispatchRequestId = {}, {phoneNumber = 0, contacts = {}}, {}, {}, -1 +local CurrentAction, CurrentActionMsg +GUI.PhoneIsShowed = false +GUI.MessagesIsShowed = false +GUI.AddContactIsShowed = false +ESX = nil Citizen.CreateThread(function() while ESX == nil do TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Citizen.Wait(0) end - + ESX.UI.Menu.RegisterType('phone', OpenPhone, ClosePhone) end) function OpenPhone() local playerPed = PlayerPedId() - TriggerServerEvent('esx_phone:reload', PhoneData.phoneNumber) SendNUIMessage({ @@ -188,7 +169,7 @@ AddEventHandler('esx_phone:onMessage', function(phoneNumber, message, position, anonyme = anon, job = job } - + ESX.SetTimeout(15000, function() CurrentAction = nil end) @@ -222,7 +203,7 @@ RegisterNUICallback('send', function(data) local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed) - if tonumber(phoneNumber) ~= nil then + if tonumber(phoneNumber) then phoneNumber = tonumber(phoneNumber) end @@ -231,7 +212,7 @@ RegisterNUICallback('send', function(data) y = coords.y, z = coords.z }) - + SendNUIMessage({ showMessageEditor = false }) @@ -269,7 +250,7 @@ Citizen.CreateThread(function() else -- open phone -- todo: is player busy (handcuffed, etc) - if IsControlJustReleased(0, Keys['F1']) and IsInputDisabled(0) then + if IsControlJustReleased(0, 288) and IsInputDisabled(0) then if not ESX.UI.Menu.IsOpen('phone', GetCurrentResourceName(), 'main') then ESX.UI.Menu.CloseAll() ESX.UI.Menu.Open('phone', GetCurrentResourceName(), 'main') @@ -292,10 +273,10 @@ Citizen.CreateThread(function() while true do Citizen.Wait(0) - if CurrentAction ~= nil then + if CurrentAction then ESX.ShowHelpNotification(CurrentActionMsg) - if IsControlJustReleased(0, Keys['E']) and IsInputDisabled(0) then + if IsControlJustReleased(0, 38) and IsInputDisabled(0) then if CurrentAction == 'dispatch' then TriggerServerEvent('esx_phone:stopDispatch', CurrentDispatchRequestId) SetNewWaypoint(CurrentActionData.position.x, CurrentActionData.position.y) @@ -307,4 +288,4 @@ Citizen.CreateThread(function() Citizen.Wait(500) end end -end) +end) \ No newline at end of file diff --git a/esx_phone.sql b/esx_phone.sql index 76da439f..220d5ad1 100644 --- a/esx_phone.sql +++ b/esx_phone.sql @@ -1,12 +1,15 @@ USE `essentialmode`; CREATE TABLE `user_contacts` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `identifier` varchar(255) NOT NULL, - `name` varchar(255) NOT NULL, - `number` int(11) NOT NULL, - - PRIMARY KEY (`id`) + `id` INT(11) NOT NULL AUTO_INCREMENT, + `identifier` VARCHAR(22) NOT NULL, + `name` VARCHAR(100) NOT NULL, + `number` INT(11) NOT NULL, + + PRIMARY KEY (`id`), + INDEX `index_user_contacts_identifier_name_number` (`identifier`, `name`, `number`) ); -ALTER TABLE `users`ADD COLUMN `phone_number` INT NULL; \ No newline at end of file +ALTER TABLE `users` + ADD COLUMN `phone_number` INT(11) NULL, + ADD UNIQUE INDEX `index_users_phone_number` (`phone_number`); \ No newline at end of file diff --git a/html/ui.html b/html/ui.html index e9023e74..d958ac00 100644 --- a/html/ui.html +++ b/html/ui.html @@ -25,9 +25,10 @@
Brak kontaktów
-Brak kontaktów
+