Skip to content

Commit

Permalink
devtools - v1.0.2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
RampBST committed Dec 19, 2021
1 parent 6ebc3fe commit b6697e1
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 26 deletions.
31 changes: 19 additions & 12 deletions client/client.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Citizen.CreateThread(function()
while true do
Wait(5)
if IsControlJustReleased(0, Config.Keys.open_ui) then
TriggerEvent('table', 'cd_123')
end

if IsControlJustReleased(0, Config.Keys.toggle_nuifocus) then
TriggerEvent('cd_devtools:ToggleNUIFocus')
end
Expand All @@ -13,6 +17,7 @@ end)

--credits https://stackoverflow.com/a/41943392 (google is for more than just porn!)
local function tprint (tbl, indent)
if type(tbl) ~= 'table' then return end
if not indent then indent = 0 end
local toprint = string.rep(" ", 0) .. "{\r\n"
indent = indent + 2
Expand All @@ -37,29 +42,31 @@ local function tprint (tbl, indent)
return toprint
end

local ui_open, last_table = false, ''
local ui_open, last_data, last_tprint = false, nil, nil
RegisterNetEvent('table')
AddEventHandler('table', function(data)
if type(data) == 'table' then
local string_table = tprint(data)
local tprint = tprint(data)
if type(data) == 'table' or data == 'cd_123' then
if data == 'cd_123' then data = last_data end
if not ui_open then
ui_open = true
SendNUIMessage({
action = 'show',
data = data,
tprint = string_table
action = 'show',
data = data or last_data,
tprint = tprint or last_tprint
})
TriggerEvent('cd_devtools:ToggleNUIFocus')
elseif string_table ~= last_table then
elseif tprint ~= last_tprint then
SendNUIMessage({
action = 'update',
data = data,
tprint = string_table
action = 'update',
data = data or last_data,
tprint = tprint or last_tprint
})
end
last_table = string_table
last_tprint = tprint or last_tprint
last_data = data or last_data
else
print('table is nil')
print(string.format('Table expected, got %s : %s', type(data), data))
end
end)

Expand Down
2 changes: 2 additions & 0 deletions configs/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Config = {}
Config.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,['LEFTARROW']=174,['RIGHTARROW']=175,['TOP']=27,['DOWNARROW']=173,['NENTER']=201,['N4']=108,['N5']=60,['N6']=107,['N+']=96,['N-']=97,['N7']=117,['N8']=61,['N9']=118,['UPARROW']=172,['INSERT']=121,['MMB']=27}

Config.Keys = {
open_ui = Config.Keys['NENTER'], --(numpad enter)

toggle_nuifocus = Config.Keys['MMB'], --(middle mouse button)

restart_script = Config.Keys['N+'], --(numpad +)
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fx_version 'cerulean'
game 'gta5'
author 'Codesign#2715'
description 'Devtools'
version '1.0.1'
version '1.0.2'

shared_script 'configs/config.lua'
client_script 'client/client.lua'
Expand Down
2 changes: 1 addition & 1 deletion html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<textarea type="text" id="clipboard-input" ></textarea>
<div id="footer" class="clearfix">
<span id="footer-info"></span>
<span id="footer-credits">Table Viewer 1.0.1 &middot; Created by Codesign &copy; 2021. <span id="resize"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-filter" viewBox="0 0 16 16">
<span id="footer-credits">Table Viewer 1.0.2 &middot; Created by Codesign &copy; 2021. <span id="resize"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-filter" viewBox="0 0 16 16">
<path d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/>
</svg></span>
</span>
Expand Down
1 change: 0 additions & 1 deletion restart_script.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
cd_carhud
32 changes: 26 additions & 6 deletions server/server.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
local resource_name, saved_resource = GetCurrentResourceName()

local function ConsolePrint(action, message)
local colour
if action == 'success' then
colour = '^3'
elseif action == 'error' then
colour = '^1'
end
print(colour..'['..resource_name..'] - '..message..'^0')
end

Citizen.CreateThread(function()
saved_resource = LoadResourceFile(resource_name,'./restart_script.txt')
print('^3['..resource_name..'] - Saved Resource applied^0')
local data = LoadResourceFile(resource_name, './restart_script.txt')
if data ~= nil then
if #data > 0 then
saved_resource = data
ConsolePrint('success', 'Saved resource name cached.')
else
ConsolePrint('error', 'Saved resource name empty.')
end
else
SaveResourceFile(resource_name, 'restart_script.txt', '', -1)
ConsolePrint('error', 'restart_script.txt file missing, automatically fixed.')
end
end)

RegisterCommand('restart_script', function(source, args)
if args[1] then
SaveResourceFile(resource_name,'restart_script.txt', args[1], -1)
print('^3['..resource_name..'] - Resource Saved^0')
ConsolePrint('success', 'Resource name saved and updated.')
saved_resource = args[1]
else
print('enter script name in 1st argument')
ConsolePrint('error', 'Enter resource name in 1st argument.')
end
end)

Expand All @@ -27,6 +47,6 @@ AddEventHandler('cd_devtools:RestartScript', function()
args = {'RESTART SCRIPT:', saved_resource..' has been restarted successfully'}
})
else
print('saved_resource is nil')
ConsolePrint('error', 'Saved resource name is nil.')
end
end)
end)
18 changes: 13 additions & 5 deletions server/version_check.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
Citizen.CreateThread(function()
Citizen.Wait(5000)
local function ToNumber(cd) return tonumber(cd) end
local resource_name = GetCurrentResourceName()
local current_version = GetResourceMetadata(resource_name, 'version', 0)
PerformHttpRequest('https://raw.githubusercontent.com/RampBST/Codesign_Versions/master/cd_devtools.txt',function(error, result, headers)
if not result then return end
local new_version = result:sub(1, -2)
if new_version ~= current_version then
print('^2['..resource_name..'] - New Update Available.^0\nCurrent Version: ^5'..current_version..'^0\nNew Version: ^5'..new_version..'^0')
PerformHttpRequest('https://raw.githubusercontent.com/RampBST/Codesign_Versions_V2/master/'..resource_name..'.txt',function(error, result, headers)
if not result then print('^1Version check disabled because github is down.^0') return end
local result = json.decode(result:sub(1, -2))
if ToNumber(result.version:gsub('%.', '')) > ToNumber(current_version:gsub('%.', '')) then
local symbols = '^'..math.random(1,9)
for cd = 1, 26+#resource_name do
symbols = symbols..'='
end
symbols = symbols..'^0'
print(symbols)
print('^2['..resource_name..'] - New Update Available.^0\nCurrent Version: ^5'..current_version..'^0.\nNew Version: ^5'..result.version..'^0.\nNotes: ^5'..result.notes..'^0.')
print(symbols)
end
end,'GET')
end)

0 comments on commit b6697e1

Please sign in to comment.