Cleanup, added locale system

This commit is contained in:
ElPumpo
2018-06-10 11:07:47 +02:00
parent 5f251a0345
commit 323452cc55
5 changed files with 83 additions and 62 deletions
+8 -9
View File
@@ -1,15 +1,14 @@
--[[
-- ESX Voice
-- Original Author of Script: github.com/aabbfive
-- Edited by: nearbyplayer
--]]
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
description 'ESX Voice Controller'
version '1.0.0'
version '1.1.0'
client_script 'client/main.lua'
client_scripts {
'@es_extended/locale.lua',
'locales/en.lua',
'locales/sv.lua',
'config.lua',
'client/main.lua'
}
+61 -53
View File
@@ -1,64 +1,72 @@
--[[
-- ESX Voice
-- Original Author of Script: github.com/aabbfive
-- Edited by: nearbyplayer
--]]
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 voice = {default = 5.0, shout = 12.0, whisper = 1.0, current = 0, level = nil}
function drawLevel(r, g, b, a)
SetTextFont(4)
SetTextProportional(1)
SetTextScale(0.5, 0.5)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString("~y~Voice:~s~ " .. voice.level)
DrawText(0.175, 0.92)
SetTextFont(4)
SetTextProportional(1)
SetTextScale(0.5, 0.5)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
BeginTextCommandDisplayText("STRING")
AddTextComponentSubstringPlayerName(_U('voice', voice.level))
EndTextCommandDisplayText(0.175, 0.92)
end
AddEventHandler('onClientMapStart', function()
if voice.current == 0 then
NetworkSetTalkerProximity(voice.default)
elseif voice.current == 1 then
NetworkSetTalkerProximity(voice.shout)
elseif voice.current == 2 then
NetworkSetTalkerProximity(voice.whisper)
end
if voice.current == 0 then
NetworkSetTalkerProximity(voice.default)
elseif voice.current == 1 then
NetworkSetTalkerProximity(voice.shout)
elseif voice.current == 2 then
NetworkSetTalkerProximity(voice.whisper)
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsControlJustPressed(1, 74) and IsControlPressed(1, 21) then
voice.current = (voice.current + 1) % 3
if voice.current == 0 then
NetworkSetTalkerProximity(voice.default)
voice.level = "Normal"
elseif voice.current == 1 then
NetworkSetTalkerProximity(voice.shout)
voice.level = "Shout"
elseif voice.current == 2 then
NetworkSetTalkerProximity(voice.whisper)
voice.level = "Whisper"
end
end
if voice.current == 0 then
voice.level = "Normal"
elseif voice.current == 1 then
voice.level = "Shout"
elseif voice.current == 2 then
voice.level = "Whisper"
end
if NetworkIsPlayerTalking(PlayerId()) then
drawLevel(41, 128, 185, 255)
elseif not NetworkIsPlayerTalking(PlayerId()) then
drawLevel(185, 185, 185, 255)
end
end
while true do
Citizen.Wait(1)
if IsControlJustPressed(1, Keys['H']) and IsControlPressed(1, Keys['LEFTSHIFT']) then
voice.current = (voice.current + 1) % 3
if voice.current == 0 then
NetworkSetTalkerProximity(voice.default)
voice.level = _U('normal')
elseif voice.current == 1 then
NetworkSetTalkerProximity(voice.shout)
voice.level = _U('shout')
elseif voice.current == 2 then
NetworkSetTalkerProximity(voice.whisper)
voice.level = _U('whisper')
end
end
if voice.current == 0 then
voice.level = _U('normal')
elseif voice.current == 1 then
voice.level = _U('shout')
elseif voice.current == 2 then
voice.level = _U('whisper')
end
if NetworkIsPlayerTalking(PlayerId()) then
drawLevel(41, 128, 185, 255)
elseif not NetworkIsPlayerTalking(PlayerId()) then
drawLevel(185, 185, 185, 255)
end
end
end)
+2
View File
@@ -0,0 +1,2 @@
Config = {}
Config.Locale = 'en'
+6
View File
@@ -0,0 +1,6 @@
Locales ['en'] = {
['voice'] = '~y~Voice: ~s~%s',
['normal'] = 'normal',
['shout'] = 'shout',
['whisper'] = 'whisper',
}
+6
View File
@@ -0,0 +1,6 @@
Locales ['sv'] = {
['voice'] = '~y~Röst: ~s~%s',
['normal'] = 'prata',
['shout'] = 'skrik',
['whisper'] = 'viska',
}