diff --git a/_g.lua b/_g.lua index 0f6fd3b..0d91674 100644 --- a/_g.lua +++ b/_g.lua @@ -1,2 +1,5 @@ -Config = {} -oncache = {} \ No newline at end of file +-- Don't touch hit +_G.Config = {} +_G.oncache = {} + +return _G.Config, _G.oncache \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua index f03487f..a792d62 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -6,7 +6,7 @@ use_experimental_fxv2_oal 'yes' author 'SUP2Ak' -version '0.3b' -- b for beta +version '0.4b' -- b for beta description 'a core standalone to manage your server and got useful function to develop it too' diff --git a/import.lua b/import.lua index 0e80311..3e9f60b 100644 --- a/import.lua +++ b/import.lua @@ -37,19 +37,25 @@ local function call_module(self, index) return module end -supv = setmetatable({name = supv_core, service = service, oncache = {}, config = {client = {}, server = {}}},{ __index = call_module, __call = call_module }) +supv = setmetatable({name = supv_core, service = service, config = {client = {}, server = {}}},{ __index = call_module, __call = call_module }) if service == 'client' then - local PlayerPedId , PlayerId , GetPlayerServerId = PlayerPedId, PlayerId, GetPlayerServerId - RegisterNetEvent('supv_core:refresh:cache', function(cache) - for k,v in pairs(cache)do - supv.oncache[k] = v - end + local PlayerPedId , PlayerId , GetPlayerServerId , GetActiveScreenResolution = PlayerPedId, PlayerId, GetPlayerServerId, GetActiveScreenResolution + CreateThread(function() supv.oncache.pedid = PlayerPedId() supv.oncache.playerid = PlayerId() supv.oncache.serverid = GetPlayerServerId(PlayerId()) - return supv.oncache + supv.oncache.screen = {GetActiveScreenResolution()} end) + supv.oncache = setmetatable({}, + { + __index = function(self, k) + RegisterNetEvent(('supv_core:set:cache:%s'):format(k), function(v) + self[k] = v + return true + end) + end + }) TriggerEvent('supv_core:insert:config-client', function(cfg) for k,v in pairs(cfg) do supv.config.client[k] = v @@ -63,4 +69,4 @@ elseif service == 'server' then end return supv.config.server end) -end \ No newline at end of file +end diff --git a/imports/draw/client.lua b/imports/draw/client.lua index 7d44c1d..9a893db 100644 --- a/imports/draw/client.lua +++ b/imports/draw/client.lua @@ -47,7 +47,7 @@ local function MeasureStringWidth(str, font, scale) AddTextComponentSubstringPlayerName(str) SetTextFont(font or 0) SetTextScale(1.0, scale or 0) - return EndTextCommandGetWidth(true) * supv.oncache.screen.x + return EndTextCommandGetWidth(true) * supv.oncache.screen[1] end local function AddText(str) @@ -65,7 +65,7 @@ local function AddText(str) end local function GetLineCount(Text, X, Y, Font, Scale, Color, Alignment, DropShadow, Outline, WordWrap) - local Text, X, Y = tostring(Text), (tonumber(X) or 0) / supv.oncache.screen.x, (tonumber(Y) or 0) / supv.oncache.screen.y + local Text, X, Y = tostring(Text), (tonumber(X) or 0) / supv.oncache.screen[1], (tonumber(Y) or 0) / supv.oncache.screen[2] SetTextFont(Font or 0) SetTextScale(1.0, Scale or 0) SetTextColour(tonumber(Color[1]) or 255, tonumber(Color[2]) or 255, tonumber(Color[3]) or 255, tonumber(Color[4]) or 255) @@ -84,11 +84,11 @@ local function GetLineCount(Text, X, Y, Font, Scale, Color, Alignment, DropShado end if tonumber(WordWrap) and tonumber(WordWrap) ~= 0 then if Alignment == 1 or Alignment == "Center" or Alignment == "Centre" then - SetTextWrap(X - ((WordWrap / supv.oncache.screen.x) / 2), X + ((WordWrap / supv.oncache.screen.y) / 2)) + SetTextWrap(X - ((WordWrap / supv.oncache.screen[1]) / 2), X + ((WordWrap / supv.oncache.screen[2]) / 2)) elseif Alignment == 2 or Alignment == "Right" then SetTextWrap(0, X) else - SetTextWrap(X, X + (WordWrap / supv.oncache.screen.x)) + SetTextWrap(X, X + (WordWrap / supv.oncache.screen[1])) end else if Alignment == 2 or Alignment == "Right" then @@ -126,10 +126,10 @@ local function Text3D(coords, text, data) DrawText(_x,_y) local factor = (string.len(text)) / 370 if color.rect1 then - DrawRect(_x,_y+0.0125, 0.015+ factor, 0.03, color.rect1[1], color.rect1[2], color.rect1[3], color.rect1[4]) + DrawRect(_x,_y+0.0125, 0.015+ factor + (scale[1]/4), 0.03, color.rect1[1], color.rect1[2], color.rect1[3], color.rect1[4]) end if color.rect2 then - DrawRect(_x,_y+0.0300, 0.015+ factor, 0.005, color.rect2[1], color.rect2[2], color.rect2[3], color.rect2[4]) + DrawRect(_x,_y+0.0300, 0.015+ factor + (scale[1]/4), 0.005, color.rect2[1], color.rect2[2], color.rect2[3], color.rect2[4]) end end @@ -144,7 +144,7 @@ end ---@param color table {int, int, int, int} ---@param heading float 0.0 local function Sprite(TextureDictionary, TextureName, x, y, width, heigth, color, heading)--drawSprite(TextureDictionary, TextureName, x, y, w, h, heading, color) - local screenX, screenY = supv.oncache.screen.x, supv.oncache.screen.y + local screenX, screenY = supv.oncache.screen[1], supv.oncache.screen[2] local x, y = (tonumber(x or 0) / tonumber(screenX)), (tonumber(y or 0) / tonumber(screenY)) local w, h = (tonumber(width or 0) / tonumber(screenX)), (tonumber(heigth or 0) / tonumber(screenY)) @@ -163,7 +163,7 @@ end ---@param h number ---@param color table local function Rect(x, y, w, h, color) - local x, y, w, h = (tonumber(x) or 0) / supv.oncache.screen.x, (tonumber(y) or 0) / supv.oncache.screen.y, (tonumber(w) or 0) / supv.oncache.screen.x, (tonumber(h) or 0) / supv.oncache.screen.y + local x, y, w, h = (tonumber(x) or 0) / supv.oncache.screen[1], (tonumber(y) or 0) / supv.oncache.screen[2], (tonumber(w) or 0) / supv.oncache.screen[1], (tonumber(h) or 0) / supv.oncache.screen[2] DrawRect(x + w * 0.5, y + h * 0.5, w, h, color[1] or 255, color[2] or 255, color[3] or 255, color[4] or 100) end @@ -180,7 +180,7 @@ end ---@param Outline boolean true or false or nil ---@param WordWrap nil|number int or nil local function Text2D(Text, X, Y, Font, Scale, Color, Alignment, DropShadow, Outline, WordWrap) - local Text, X, Y = tostring(Text), (tonumber(X) or 0) / supv.oncache.screen.x, (tonumber(Y) or 0) / supv.oncache.screen.y + local Text, X, Y = tostring(Text), (tonumber(X) or 0) / supv.oncache.screen[1], (tonumber(Y) or 0) / supv.oncache.screen[2] SetTextFont(Font or 0) SetTextScale(1.0, Scale or 0) SetTextColour(tonumber(Color[1]) or 255, tonumber(Color[2]) or 255, tonumber(Color[3]) or 255, tonumber(Color[4]) or 255) @@ -199,11 +199,11 @@ local function Text2D(Text, X, Y, Font, Scale, Color, Alignment, DropShadow, Out end if tonumber(WordWrap) and tonumber(WordWrap) ~= 0 then if Alignment == 1 or Alignment == "Center" or Alignment == "Centre" then - SetTextWrap(X - ((WordWrap / supv.oncache.screen.x) / 2), X + ((WordWrap / supv.oncache.screen.y) / 2)) + SetTextWrap(X - ((WordWrap / supv.oncache.screen[1]) / 2), X + ((WordWrap / supv.oncache.screen[2]) / 2)) elseif Alignment == 2 or Alignment == "Right" then SetTextWrap(0, X) else - SetTextWrap(X, X + (WordWrap / supv.oncache.screen.x)) + SetTextWrap(X, X + (WordWrap / supv.oncache.screen[1])) end else if Alignment == 2 or Alignment == "Right" then @@ -240,7 +240,7 @@ local function ProgressBar(text, time, setting, data, action) progressbar.setting.timeCancel = setting.timeCancel or 0 progressbar.setting.animation = setting.animation or defaultProgressBar.animation progressbar.setting.prop = setting.prop or defaultProgressBar.prop - progressbar.data.x = data.x or (supv.oncache.screen.x * 0.35) + progressbar.data.x = data.x or (supv.oncache.screen[1] * 0.35) progressbar.data.y = data.y or defaultProgressBar.y progressbar.data.w = data.w or defaultProgressBar.w progressbar.data.h = data.h or defaultProgressBar.h @@ -280,7 +280,7 @@ local function ProgressBar(text, time, setting, data, action) if (progressbar.data.progressAnim == 'simple') then local _y = progressbar.data.y - local _ymax = supv.oncache.screen.y + 100 + local _ymax = supv.oncache.screen[2] + 100 while _y < _ymax do Wait(0) @@ -495,7 +495,7 @@ local function ProgressBar(text, time, setting, data, action) CreateThread(function() if progressbar.data.progressAnim == 'simple' then - local _y = supv.oncache.screen.y + 100 + local _y = supv.oncache.screen[2] + 100 while _y > progressbar.data.y do Wait(0) if progressbar.data.progressType == 'sprite' then diff --git a/imports/laser/client.lua b/imports/laser/client.lua new file mode 100644 index 0000000..16353d6 --- /dev/null +++ b/imports/laser/client.lua @@ -0,0 +1,179 @@ +local SetTextScale = SetTextScale +local SetTextFont = SetTextFont +local SetTextProportional = SetTextProportional +local SetTextColour = SetTextColour +local SetTextEntry = SetTextEntry +local SetTextCentre = SetTextCentre +local AddTextComponentString = AddTextComponentString +local SetDrawOrigin = SetDrawOrigin +local DrawText = DrawText +local DrawSprite = DrawSprite +local DrawLine = DrawLine +local ClearDrawOrigin = ClearDrawOrigin +local GetEntityModel = GetEntityModel +local GetModelDimensions = GetModelDimensions +local GetEntityMatrix = GetEntityMatrix +local GetGroundZFor_3dCoord = GetGroundZFor_3dCoord +local GetGameplayCamRot = GetGameplayCamRot +local GetGameplayCamCoord = GetGameplayCamCoord +local GetShapeTestResult = GetShapeTestResult +local StartShapeTestRay = StartShapeTestRay +local math = math +local string = string + + +local function Draw3dText(coords, text, lines) + if not lines then lines = 1 end + SetTextScale(0.35, 0.35) + SetTextFont(4) + SetTextProportional(1) + SetTextColour(255, 255, 255, 215) + SetTextEntry("STRING") + SetTextCentre(true) + AddTextComponentString(text) + SetDrawOrigin(coords.x, coords.y, coords.z, 0) + DrawText(0.0, 0.0) + local factor = (string.len(text)) / 370 + DrawSprite("commonmenu", "gradient_bgd", 0.0, 0.0+0.0125 * lines, 0.017+ factor, 0.03 * lines, 0.1, 0, 0, 0, 75) + ClearDrawOrigin() +end + +local function DrawEntityBoundingBox(entity, color) + local model = GetEntityModel(entity) + local min, max = GetModelDimensions(model) + local rightVector, forwardVector, upVector, position = GetEntityMatrix(entity) + local dim = { + x = 0.5*(max.x - min.x), + y = 0.5*(max.y - min.y), + z = 0.5*(max.z - min.z) + } + + local FUR = { + x = position.x + dim.y*rightVector.x + dim.x*forwardVector.x + dim.z*upVector.x, + y = position.y + dim.y*rightVector.y + dim.x*forwardVector.y + dim.z*upVector.y, + z = 0 + } + + local _, FUR_z = GetGroundZFor_3dCoord(FUR.x, FUR.y, 1000.0, 0) + FUR.z = FUR_z + FUR.z = FUR.z + 2 * dim.z + + local BLL = { + x = position.x - dim.y*rightVector.x - dim.x*forwardVector.x - dim.z*upVector.x, + y = position.y - dim.y*rightVector.y - dim.x*forwardVector.y - dim.z*upVector.y, + z = 0 + } + + local _, BLL_z = GetGroundZFor_3dCoord(FUR.x, FUR.y, 1000.0, 0) + BLL.z = BLL_z + local edge1 = BLL + local edge5 = FUR + + local edge2 = { + x = edge1.x + 2 * dim.y*rightVector.x, + y = edge1.y + 2 * dim.y*rightVector.y, + z = edge1.z + 2 * dim.y*rightVector.z + } + + local edge3 = { + x = edge2.x + 2 * dim.z*upVector.x, + y = edge2.y + 2 * dim.z*upVector.y, + z = edge2.z + 2 * dim.z*upVector.z + } + + local edge4 = { + x = edge1.x + 2 * dim.z*upVector.x, + y = edge1.y + 2 * dim.z*upVector.y, + z = edge1.z + 2 * dim.z*upVector.z + } + + local edge6 = { + x = edge5.x - 2 * dim.y*rightVector.x, + y = edge5.y - 2 * dim.y*rightVector.y, + z = edge5.z - 2 * dim.y*rightVector.z + } + + local edge7 = { + x = edge6.x - 2 * dim.z*upVector.x, + y = edge6.y - 2 * dim.z*upVector.y, + z = edge6.z - 2 * dim.z*upVector.z + } + + local edge8 = { + x = edge5.x - 2 * dim.z*upVector.x, + y = edge5.y - 2 * dim.z*upVector.y, + z = edge5.z - 2 * dim.z*upVector.z + } + + DrawLine(edge1.x, edge1.y, edge1.z, edge2.x, edge2.y, edge2.z, color.r, color.g, color.b, color.a) + DrawLine(edge1.x, edge1.y, edge1.z, edge4.x, edge4.y, edge4.z, color.r, color.g, color.b, color.a) + DrawLine(edge2.x, edge2.y, edge2.z, edge3.x, edge3.y, edge3.z, color.r, color.g, color.b, color.a) + DrawLine(edge3.x, edge3.y, edge3.z, edge4.x, edge4.y, edge4.z, color.r, color.g, color.b, color.a) + DrawLine(edge5.x, edge5.y, edge5.z, edge6.x, edge6.y, edge6.z, color.r, color.g, color.b, color.a) + DrawLine(edge5.x, edge5.y, edge5.z, edge8.x, edge8.y, edge8.z, color.r, color.g, color.b, color.a) + DrawLine(edge6.x, edge6.y, edge6.z, edge7.x, edge7.y, edge7.z, color.r, color.g, color.b, color.a) + DrawLine(edge7.x, edge7.y, edge7.z, edge8.x, edge8.y, edge8.z, color.r, color.g, color.b, color.a) + DrawLine(edge1.x, edge1.y, edge1.z, edge7.x, edge7.y, edge7.z, color.r, color.g, color.b, color.a) + DrawLine(edge2.x, edge2.y, edge2.z, edge8.x, edge8.y, edge8.z, color.r, color.g, color.b, color.a) + DrawLine(edge3.x, edge3.y, edge3.z, edge5.x, edge5.y, edge5.z, color.r, color.g, color.b, color.a) + DrawLine(edge4.x, edge4.y, edge4.z, edge6.x, edge6.y, edge6.z, color.r, color.g, color.b, color.a) +end + +local function RotationToDirection(rotation) + local adjustedRotation = { + x = (math.pi / 180) * rotation.x, + y = (math.pi / 180) * rotation.y, + z = (math.pi / 180) * rotation.z + } + local direction = { + x = -math.sin(adjustedRotation.z) * math.abs(math.cos(adjustedRotation.x)), + y = math.cos(adjustedRotation.z) * math.abs(math.cos(adjustedRotation.x)), + z = math.sin(adjustedRotation.x) + } + return direction +end + +local function RayCastCamera(distance) + local cameraRotation = GetGameplayCamRot() + local cameraCoord = GetGameplayCamCoord() + local direction = RotationToDirection(cameraRotation) + local destination = { + x = cameraCoord.x + direction.x * distance, + y = cameraCoord.y + direction.y * distance, + z = cameraCoord.z + direction.z * distance + } + local _, b, c, _, e = GetShapeTestResult(StartShapeTestRay(cameraCoord.x, cameraCoord.y, cameraCoord.z, destination.x, destination.y, destination.z, -1, supv.oncache.pedid, 0)) + return b, c, e +end + +local GetEntityCoords = GetEntityCoords +local IsEntityAPed = IsEntityAPed +local IsEntityAnObject = IsEntityAnObject +local IsEntityAVehicle = IsEntityAVehicle +local DrawMarker = DrawMarker +local IsControlJustReleased = IsControlJustReleased +local vec3 = vec3 +local GetEntityArchetypeName = GetEntityArchetypeName +local PlayerPedId = PlayerPedId + +local function Show(cb) + local color = {r = 255, g = 0, b = 0, a = 200} + local position = GetEntityCoords(PlayerPedId()) + local hit, coords, entity = RayCastCamera(1000.0) + if hit and (IsEntityAVehicle(entity) or IsEntityAPed(entity) or IsEntityAnObject(entity)) then + local entityCoord = GetEntityCoords(entity) + DrawEntityBoundingBox(entity, color) + DrawLine(position.x, position.y, position.z, coords.x, coords.y, coords.z, color.r, color.g, color.b, color.a) + Draw3dText(vec3(entityCoord.x, entityCoord.y, entityCoord.z), ("model : %s | name : %s\nPress [~c~E~s~] to ~g~validate~s~ ~p~entity~s~"):format(GetEntityModel(entity), GetEntityArchetypeName(entity)), 2) + if IsControlJustReleased(0, 38) then + cb(entity, GetEntityModel(entity), GetEntityArchetypeName(entity)) + end + elseif coords.x ~= 0.0 and coords.y ~= 0.0 then + DrawLine(position.x, position.y, position.z, coords.x, coords.y, coords.z, color.r, color.g, color.b, color.a) + DrawMarker(28, coords.x, coords.y, coords.z, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 0.1, 0.1, 0.1, color.r, color.g, color.b, color.a, false, true, 2, nil, nil, false) + end +end + +return { + show = Show +} \ No newline at end of file diff --git a/imports/marker/client.lua b/imports/marker/client.lua index 8cd2096..7443b83 100644 --- a/imports/marker/client.lua +++ b/imports/marker/client.lua @@ -14,21 +14,23 @@ local function Marker(double, inside, coords, params, params2) local args = {} if params2 then - args.id = params2.id or default.m2.id - args.color = params2.color or default.m2.color - args.dir = params2.dir or default.m2.dir - args.rot = params2.rot or default.m2.rot - args.scale = params2.scale or default.m2.scale - args.updown = params2.updown or default.m2.updown - args.faceToCam = params2.faceToCam or default.m2.faceToCam - args.p19 = params2.p19 or default.m2.p19 - args.rotate = params2.rotate or default.m2.rotate - args.textureDict = params2.textureDict or default.m2.textureDict - args.textureName = params2.textureName or default.m2.textureName - args.drawOnEnts = params2.drawOnEnts or default.m2.drawOnEnts - args.z = params2.z or default.m2.z - args.op = params2.op or default.m2.op + 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 @@ -60,27 +62,31 @@ local function Marker(double, inside, coords, params, params2) end end - 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 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) + end end local args = {} if params then - args.id = params.id or default.m1.id - args.color = params.color or default.m1.color - args.dir = params.dir or default.m1.dir - args.rot = params.rot or default.m1.rot - args.scale = params.scale or default.m1.scale - args.updown = params.updown or default.m1.updown - args.faceToCam = params.faceToCam or default.m1.faceToCam - args.p19 = params.p19 or default.m1.p19 - args.rotate = params.rotate or default.m1.rotate - args.textureDict = params.textureDict or default.m1.textureDict - args.textureName = params.textureName or default.m1.textureName - args.drawOnEnts = params.drawOnEnts or default.m1.drawOnEnts - args.z = params.z or default.m1.z - args.op = params.op or default.m1.op + 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 else + args.visible = default.m1.visible args.id = default.m1.id args.color = default.m1.color args.dir = default.m1.dir @@ -112,7 +118,9 @@ local function Marker(double, inside, coords, params, params2) end end - 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 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) + end end diff --git a/imports/object/client.lua b/imports/object/client.lua index 47a0d97..3a59421 100644 --- a/imports/object/client.lua +++ b/imports/object/client.lua @@ -97,60 +97,7 @@ local function Created(model, coords, cb) end) end ---- For tools -local function editTools(self, data) - if not self.object then return end - DetachEntity(self.object, 1, 1) - if self.entity then - if data.coords then self.coords = data.coords end - if data.rot then self.rot = data.rot end - if data.bone then self.bone = data.bone end - AttachEntityToEntity(self.object, 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) - return - end - return -end - -local function removeTools(self) - if not self.object then return end - if self.entity then - DetachEntity(self.object, 1, 1) - end - DeleteEntity(self.object) - return nil, collectgarbage() -end - -local function tools(model, setting) - local self = {} - - CreateThread(function() - - self.model = model - self.coords = setting.coords or {0.0, 0.0, 0.0} - self.rot = setting.rot or {0.0, 0.0, 0.0} - - if setting then - if setting.entity then - self.entity = setting.entity - self.bone = setting.bone - self.entity_coords = GetOffsetFromEntityInWorldCoords(self.entity, 0.0, 0.0, 0.0) - self.object = CreateObject(self.model, self.entity_coords[1], self.entity_coords[2], self.entity_coords[3], false, false, true) - else - self.object = CreateObject(self.model, self.coords[1], self.coords[2], self.coords[3], false, false, true) - end - end - - if self.entity then - AttachEntityToEntity(self.object, 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) - end - end) - self.edit = editTools - self.remove = removeTools - return self -end - return { new = New, create = Created, - tool = tools } \ No newline at end of file diff --git a/imports/tool/client.lua b/imports/tool/client.lua new file mode 100644 index 0000000..c70be44 --- /dev/null +++ b/imports/tool/client.lua @@ -0,0 +1,405 @@ +local SetTextScale = SetTextScale +local SetTextFont = SetTextFont +local SetTextProportional = SetTextProportional +local SetTextColour = SetTextColour +local SetTextEntry = SetTextEntry +local SetTextCentre = SetTextCentre +local AddTextComponentString = AddTextComponentString +local SetDrawOrigin = SetDrawOrigin +local DrawText = DrawText +local DrawSprite = DrawSprite +local DrawLine = DrawLine +local ClearDrawOrigin = ClearDrawOrigin +local GetEntityModel = GetEntityModel +local GetModelDimensions = GetModelDimensions +local GetEntityMatrix = GetEntityMatrix +local GetGroundZFor_3dCoord = GetGroundZFor_3dCoord +local GetGameplayCamRot = GetGameplayCamRot +local GetGameplayCamCoord = GetGameplayCamCoord +local GetShapeTestResult = GetShapeTestResult +local StartShapeTestRay = StartShapeTestRay +local math = math +local string = string + +--- Methode + +local function Draw3dText(coords, text, lines) + if not lines then lines = 1 end + SetTextScale(0.35, 0.35) + SetTextFont(4) + SetTextProportional(1) + SetTextColour(255, 255, 255, 215) + SetTextEntry("STRING") + SetTextCentre(true) + AddTextComponentString(text) + SetDrawOrigin(coords.x, coords.y, coords.z, 0) + DrawText(0.0, 0.0) + local factor = (string.len(text)) / 370 + DrawSprite("commonmenu", "gradient_bgd", 0.0, 0.0+0.0125 * lines, 0.017+ factor, 0.03 * lines, 0.1, 0, 0, 0, 75) + ClearDrawOrigin() +end + +local function DrawEntityBoundingBox(entity, color) + local model = GetEntityModel(entity) + local min, max = GetModelDimensions(model) + local rightVector, forwardVector, upVector, position = GetEntityMatrix(entity) + local dim = { + x = 0.5*(max.x - min.x), + y = 0.5*(max.y - min.y), + z = 0.5*(max.z - min.z) + } + + local FUR = { + x = position.x + dim.y*rightVector.x + dim.x*forwardVector.x + dim.z*upVector.x, + y = position.y + dim.y*rightVector.y + dim.x*forwardVector.y + dim.z*upVector.y, + z = 0 + } + + local _, FUR_z = GetGroundZFor_3dCoord(FUR.x, FUR.y, 1000.0, 0) + FUR.z = FUR_z + FUR.z = FUR.z + 2 * dim.z + + local BLL = { + x = position.x - dim.y*rightVector.x - dim.x*forwardVector.x - dim.z*upVector.x, + y = position.y - dim.y*rightVector.y - dim.x*forwardVector.y - dim.z*upVector.y, + z = 0 + } + + local _, BLL_z = GetGroundZFor_3dCoord(FUR.x, FUR.y, 1000.0, 0) + BLL.z = BLL_z + local edge1 = BLL + local edge5 = FUR + + local edge2 = { + x = edge1.x + 2 * dim.y*rightVector.x, + y = edge1.y + 2 * dim.y*rightVector.y, + z = edge1.z + 2 * dim.y*rightVector.z + } + + local edge3 = { + x = edge2.x + 2 * dim.z*upVector.x, + y = edge2.y + 2 * dim.z*upVector.y, + z = edge2.z + 2 * dim.z*upVector.z + } + + local edge4 = { + x = edge1.x + 2 * dim.z*upVector.x, + y = edge1.y + 2 * dim.z*upVector.y, + z = edge1.z + 2 * dim.z*upVector.z + } + + local edge6 = { + x = edge5.x - 2 * dim.y*rightVector.x, + y = edge5.y - 2 * dim.y*rightVector.y, + z = edge5.z - 2 * dim.y*rightVector.z + } + + local edge7 = { + x = edge6.x - 2 * dim.z*upVector.x, + y = edge6.y - 2 * dim.z*upVector.y, + z = edge6.z - 2 * dim.z*upVector.z + } + + local edge8 = { + x = edge5.x - 2 * dim.z*upVector.x, + y = edge5.y - 2 * dim.z*upVector.y, + z = edge5.z - 2 * dim.z*upVector.z + } + + DrawLine(edge1.x, edge1.y, edge1.z, edge2.x, edge2.y, edge2.z, color.r, color.g, color.b, color.a) + DrawLine(edge1.x, edge1.y, edge1.z, edge4.x, edge4.y, edge4.z, color.r, color.g, color.b, color.a) + DrawLine(edge2.x, edge2.y, edge2.z, edge3.x, edge3.y, edge3.z, color.r, color.g, color.b, color.a) + DrawLine(edge3.x, edge3.y, edge3.z, edge4.x, edge4.y, edge4.z, color.r, color.g, color.b, color.a) + DrawLine(edge5.x, edge5.y, edge5.z, edge6.x, edge6.y, edge6.z, color.r, color.g, color.b, color.a) + DrawLine(edge5.x, edge5.y, edge5.z, edge8.x, edge8.y, edge8.z, color.r, color.g, color.b, color.a) + DrawLine(edge6.x, edge6.y, edge6.z, edge7.x, edge7.y, edge7.z, color.r, color.g, color.b, color.a) + DrawLine(edge7.x, edge7.y, edge7.z, edge8.x, edge8.y, edge8.z, color.r, color.g, color.b, color.a) + DrawLine(edge1.x, edge1.y, edge1.z, edge7.x, edge7.y, edge7.z, color.r, color.g, color.b, color.a) + DrawLine(edge2.x, edge2.y, edge2.z, edge8.x, edge8.y, edge8.z, color.r, color.g, color.b, color.a) + DrawLine(edge3.x, edge3.y, edge3.z, edge5.x, edge5.y, edge5.z, color.r, color.g, color.b, color.a) + DrawLine(edge4.x, edge4.y, edge4.z, edge6.x, edge6.y, edge6.z, color.r, color.g, color.b, color.a) +end + +local function RotationToDirection(rotation) + local adjustedRotation = { + x = (math.pi / 180) * rotation.x, + y = (math.pi / 180) * rotation.y, + z = (math.pi / 180) * rotation.z + } + local direction = { + x = -math.sin(adjustedRotation.z) * math.abs(math.cos(adjustedRotation.x)), + y = math.cos(adjustedRotation.z) * math.abs(math.cos(adjustedRotation.x)), + z = math.sin(adjustedRotation.x) + } + return direction +end + +local function RayCastCamera(distance) + local cameraRotation = GetGameplayCamRot() + local cameraCoord = GetGameplayCamCoord() + local direction = RotationToDirection(cameraRotation) + local destination = { + x = cameraCoord.x + direction.x * distance, + y = cameraCoord.y + direction.y * distance, + z = cameraCoord.z + direction.z * distance + } + local _, b, c, _, e = GetShapeTestResult(StartShapeTestRay(cameraCoord.x, cameraCoord.y, cameraCoord.z, destination.x, destination.y, destination.z, -1, supv.oncache.pedid, 0)) + return b, c, e +end + +local GetEntityCoords = GetEntityCoords +local IsEntityAPed = IsEntityAPed +local IsEntityAnObject = IsEntityAnObject +local IsEntityAVehicle = IsEntityAVehicle +local DrawMarker = DrawMarker +local IsControlJustReleased = IsControlJustReleased +local vec3 = vec3 +local GetEntityArchetypeName = GetEntityArchetypeName +local PlayerPedId = PlayerPedId + +-- function Laser + +local function Show(cb) + local color = {r = 255, g = 0, b = 0, a = 200} + local position = GetEntityCoords(PlayerPedId()) + local hit, coords, entity = RayCastCamera(1000.0) + if hit and (IsEntityAVehicle(entity) or IsEntityAPed(entity) or IsEntityAnObject(entity)) then + local entityCoord = GetEntityCoords(entity) + DrawEntityBoundingBox(entity, color) + DrawLine(position.x, position.y, position.z, coords.x, coords.y, coords.z, color.r, color.g, color.b, color.a) + Draw3dText(vec3(entityCoord.x, entityCoord.y, entityCoord.z), ("model : %s | name : %s\nPress [~c~E~s~] to ~g~validate~s~ ~p~entity~s~"):format(GetEntityModel(entity), GetEntityArchetypeName(entity)), 2) + if IsControlJustReleased(0, 38) then + cb(entity, GetEntityModel(entity), GetEntityArchetypeName(entity)) + end + elseif coords.x ~= 0.0 and coords.y ~= 0.0 then + DrawLine(position.x, position.y, position.z, coords.x, coords.y, coords.z, color.r, color.g, color.b, color.a) + DrawMarker(28, coords.x, coords.y, coords.z, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 0.1, 0.1, 0.1, color.r, color.g, color.b, color.a, false, true, 2, nil, nil, false) + end +end + + +-- Mehtode Object Tool + +local BoneList = { + [1] = { + {label = "SKEL_L_Hand", index = 18905}, + {label = "SKEL_ROOT", index = 0}, + {label = "FB_R_Brow_Out_000", index = 1356}, + {label = "SKEL_L_Toe0", index = 2108}, + {label = "MH_R_Elbow", index = 2992}, + {label = "SKEL_L_Finger01", index = 4089}, + {label = "SKEL_L_Finger02", index = 4090}, + {label = "SKEL_L_Finger31", index = 4137}, + {label = "SKEL_L_Finger32", index = 4138}, + {label = "SKEL_L_Finger41", index = 4153}, + {label = "SKEL_L_Finger42", index = 4154}, + {label = "SKEL_L_Finger11", index = 4169}, + {label = "SKEL_L_Finger12", index = 4170}, + {label = "SKEL_L_Finger21", index = 4185}, + {label = "SKEL_L_Finger22", index = 4186}, + {label = "RB_L_ArmRoll", index = 5232}, + {label = "IK_R_Hand", index = 6286}, + {label = "RB_R_ThighRoll", index = 6442}, + {label = "SKEL_R_Clavicle", index = 10706}, + {label = "FB_R_Lip_Corner_000", index = 11174}, + {label = "SKEL_Pelvis", index = 11816}, + {label = "IK_Head", index = 12844}, + {label = "SKEL_L_Foot", index = 14201}, + {label = "MH_R_Knee", index = 16335}, + {label = "FB_LowerLipRoot_000", index = 17188}, + {label = "FB_R_Lip_Top_000", index = 17719}, + {label = "FB_R_CheekBone_000", index = 19336}, + {label = "FB_UpperLipRoot_000", index = 20178}, + {label = "FB_L_Lip_Top_000", index = 20279}, + {label = "FB_LowerLip_000", index = 20623}, + {label = "SKEL_R_Toe0", index = 20781}, + {label = "FB_L_CheekBone_000", index = 21550}, + {label = "MH_L_Elbow", index = 22711}, + {label = "SKEL_Spine0", index = 23553}, + {label = "RB_L_ThighRoll", index = 23639}, + {label = "PH_R_Foot", index = 24806}, + {label = "SKEL_Spine1", index = 24816}, + {label = "SKEL_Spine2", index = 24817}, + {label = "SKEL_Spine3", index = 24818}, + {label = "FB_L_Eye_000", index = 25260}, + {label = "SKEL_L_Finger00", index = 26610}, + {label = "SKEL_L_Finger10", index = 26611}, + {label = "SKEL_L_Finger20", index = 26612}, + {label = "SKEL_L_Finger30", index = 26613}, + {label = "SKEL_L_Finger40", index = 26614}, + {label = "FB_R_Eye_000", index = 27474}, + {label = "SKEL_R_Forearm", index = 28252}, + {label = "PH_R_Hand", index = 28422}, + {label = "FB_L_Lip_Corner_000", index = 29868}, + {label = "SKEL_Head", index = 31086}, + {label = "IK_R_Foot", index = 35502}, + {label = "RB_Neck_1", index = 35731}, + {label = "IK_L_Hand", index = 36029}, + {label = "SKEL_R_Calf", index = 36864}, + {label = "RB_R_ArmRoll", index = 37119}, + {label = "FB_Brow_Centre_000", index = 37193}, + {label = "SKEL_Neck_1", index = 39317}, + {label = "SKEL_R_UpperArm", index = 40269}, + {label = "FB_R_Lid_Upper_000", index = 43536}, + {label = "RB_R_ForeArmRoll", index = 43810}, + {label = "SKEL_L_UpperArm", index = 45509}, + {label = "FB_L_Lid_Upper_000", index = 45750}, + {label = "MH_L_Knee", index = 46078}, + {label = "FB_Jaw_000", index = 46240}, + {label = "FB_L_Lip_Bot_000", index = 47419}, + {label = "FB_Tongue_000", index = 47495}, + {label = "FB_R_Lip_Bot_000", index = 49979}, + {label = "SKEL_R_Thigh", index = 51826}, + {label = "SKEL_R_Foot", index = 52301}, + {label = "IK_Root", index = 56604}, + {label = "SKEL_R_Hand", index = 57005}, + {label = "SKEL_Spine_Root", index = 57597}, + {label = "PH_L_Foot", index = 57717}, + {label = "SKEL_L_Thigh", index = 58271}, + {label = "FB_L_Brow_Out_000", index = 58331}, + {label = "SKEL_R_Finger00", index = 58866}, + {label = "SKEL_R_Finger10", index = 58867}, + {label = "SKEL_R_Finger20", index = 58868}, + {label = "SKEL_R_Finger30", index = 58869}, + {label = "SKEL_R_Finger40", index = 58870}, + {label = "PH_L_Hand", index = 60309}, + {label = "RB_L_ForeArmRoll", index = 61007}, + {label = "SKEL_L_Forearm", index = 61163}, + {label = "FB_UpperLip_000", index = 61839}, + {label = "SKEL_L_Calf", index = 63931}, + {label = "SKEL_R_Finger01", index = 64016}, + {label = "SKEL_R_Finger02", index = 64017}, + {label = "SKEL_R_Finger31", index = 64064}, + {label = "SKEL_R_Finger32", index = 64065}, + {label = "SKEL_R_Finger41", index = 64080}, + {label = "SKEL_R_Finger42", index = 64081}, + {label = "SKEL_R_Finger11", index = 64096}, + {label = "SKEL_R_Finger12", index = 64097}, + {label = "SKEL_R_Finger21", index = 64112}, + {label = "SKEL_R_Finger22", index = 64113}, + {label = "SKEL_L_Clavicle", index = 64729}, + {label = "FACIAL_facialRoot", index = 65068}, + {label = "IK_L_Foot", index = 65245}, + }, + [2] = { + {label = "chassis", index = "chassis" }, + {label = "windscreen", index = "windscreen" }, + {label = "seat_pside_r", index = "seat_pside_r" }, + {label = "seat_dside_r", index = "seat_dside_r" }, + {label = "bodyshell", index = "bodyshell" }, + {label = "suspension_lm", index = "suspension_lm" }, + {label = "suspension_lr", index = "suspension_lr" }, + {label = "platelight", index = "platelight" }, + {label = "attach_female", index = "attach_female" }, + {label = "attach_male", index = "attach_male" }, + {label = "bonnet", index = "bonnet" }, + {label = "boot", index = "boot" }, + {label = "chassis_dummy", index = "chassis_dummy" }, + {label = "chassis_Control", index = "chassis_Control" }, + {label = "door_dside_f", index = "door_dside_f" }, + {label = "door_dside_r", index = "door_dside_r" }, + {label = "door_pside_f", index = "door_pside_f" }, + {label = "door_pside_r", index = "door_pside_r" }, + {label = "Gun_GripR", index = "Gun_GripR" }, + {label = "windscreen_f", index = "windscreen_f" }, + {label = "platelight", index = "platelight" }, + {label = "VFX_Emitter", index = "VFX_Emitter" }, + {label = "window_lf", index = "window_lf" }, + {label = "window_lr", index = "window_lr" }, + {label = "window_rf", index = "window_rf" }, + {label = "window_rr", index = "window_rr" }, + {label = "engine", index = "engine" }, + {label = "gun_ammo", index = "gun_ammo" }, + {label = "ROPE_ATTATCH", index = "ROPE_ATTATCH" }, + {label = "wheel_lf", index = "wheel_lf" }, + {label = "wheel_lr", index = "wheel_lr" }, + {label = "wheel_rf", index = "wheel_rf" }, + {label = "wheel_rr", index = "wheel_rr" }, + {label = "exhaust", index = "exhaust" }, + {label = "overheat", index = "overheat" }, + {label = "misc_e", index = "misc_e" }, + {label = "seat_dside_f", index = "seat_dside_f" }, + {label = "seat_pside_f", index = "seat_pside_f" }, + {label = "Gun_Nuzzle", index = "Gun_Nuzzle" }, + {label = "seat_r", index = "seat_r" }, + }, + [3] = { + {label = "root", index = 0 } + } +} + +local DetachEntity = DetachEntity +local AttachEntityToEntity = AttachEntityToEntity +local GetPedBoneIndex = GetPedBoneIndex +local DeleteEntity = DeleteEntity +local GetOffsetFromEntityInWorldCoords = GetOffsetFromEntityInWorldCoords +local CreateObject = CreateObject +local GetEntityType = GetEntityType +local GetEntityBoneIndexByName = GetEntityBoneIndexByName + +local function editTools(self, data) + if not self.object then return end + DetachEntity(self.object, 1, 1) + if data.coords then self.coords = data.coords end + if data.rot then self.rot = data.rot end + if data.bone then self.bone = data.bone end + if self.entity_type == 1 then + AttachEntityToEntity(self.object, 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) + return + elseif self.entity_type == 2 then -- vehicle + AttachEntityToEntity(self.object, 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) + else + AttachEntityToEntity(self.object, 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) + end + return +end + +local function removeTools(self) + if not self.object then return end + if self.entity then + DetachEntity(self.object, 1, 1) + end + DeleteEntity(self.object) + return nil, collectgarbage() +end + +local function CreateProps(model, setting) + local self = {} + + CreateThread(function() + + self.model = model + self.coords = setting.coords or {0.0, 0.0, 0.0} + self.rot = setting.rot or {0.0, 0.0, 0.0} + + if setting then + if setting.entity then + self.entity = setting.entity + self.entity_type = GetEntityType(self.entity) + self.bone = setting.bone or nil + self.entity_coords = GetOffsetFromEntityInWorldCoords(self.entity, 0.0, 0.0, 0.0) + self.object = CreateObject(self.model, self.entity_coords[1], self.entity_coords[2], self.entity_coords[3], false, false, true) + end + end + + if self.entity_type == 1 then -- ped + AttachEntityToEntity(self.object, 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) + elseif self.entity_type == 2 then -- vehicle + AttachEntityToEntity(self.object, 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) + elseif self.entity_type == 3 then -- object (3) + AttachEntityToEntity(self.object, 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) + else -- == 0 + return print("error entity type = 0") + end + end) + self.edit = editTools + self.remove = removeTools + return self +end + + +return { + laser = Show, + boneList = BoneList, + createProps = CreateProps +} \ No newline at end of file diff --git a/imports/vehicle/client.lua b/imports/vehicle/client.lua index 9573852..4d33145 100644 --- a/imports/vehicle/client.lua +++ b/imports/vehicle/client.lua @@ -528,7 +528,7 @@ function SpawnVehicle(vehicle, coords, cb) end function SpawnLocalVehicle(vehicle, coords, cb) - local vehicleCreated, id + local vehicleCreated CreateThread(function() diff --git a/imports/webhook/client.lua b/imports/webhook/client.lua index ca1b04f..9413a76 100644 --- a/imports/webhook/client.lua +++ b/imports/webhook/client.lua @@ -3,6 +3,7 @@ ---@param channel_id string ---@param text string ---@param bot_name nil|string +---@return message TriggerServerEvent local function Message(channel_id, text, bot_name) return TriggerServerEvent('supv_core:server:webhook:message', channel_id, text, bot_name) end @@ -13,6 +14,7 @@ end ---@param embed table ---@param bot_name nil|string ---@param avatar nil|string +---@return embed TriggerServerEvent local function Embed(channel_id, embed, bot_name, avatar) return TriggerServerEvent('supv_core:server:webhook:embed', channel_id, embed, bot_name, avatar) end diff --git a/resources/client/cache.lua b/resources/client/cache.lua index 0ab9ac4..caf8ac4 100644 --- a/resources/client/cache.lua +++ b/resources/client/cache.lua @@ -1,91 +1,53 @@ -oncache.player = {} -oncache.player.coords = nil -oncache.player.screen = {} -CreateThread(function() - while not NetworkIsPlayerActive(PlayerId()) do - Wait(0) +oncache.playerid = PlayerId() +oncache.serverid = GetPlayerServerId(PlayerId()) +oncache.screen = {GetActiveScreenResolution()} + +function oncache:set(k, v) + if self[k] ~= v then + self[k] = v + TriggerEvent(('supv_core:set:cache:%s'):format(k), v) + return true end +end - local GetEntityCoords = GetEntityCoords - local PlayerPedId = PlayerPedId - local GetVehiclePedIsIn = GetVehiclePedIsIn - local PlayerId = PlayerId - local GetPlayerServerId = GetPlayerServerId - local GetActiveScreenResolution = GetActiveScreenResolution - - oncache.player.pedid = PlayerPedId() - oncache.player.playerid = PlayerId() - oncache.player.serverid = GetPlayerServerId(PlayerId()) - oncache.player.currentvehicle = GetVehiclePedIsIn(PlayerPedId(), false) - oncache.player.screen.x, oncache.player.screen.y = GetActiveScreenResolution() - oncache.player.coords = GetEntityCoords(PlayerPedId(), false) +local GetEntityCoords = GetEntityCoords +local PlayerPedId = PlayerPedId +--local GetVehiclePedIsUsing = GetVehiclePedIsUsing -- fuck perf +local GetVehiclePedIsIn = GetVehiclePedIsIn - local coords, distance, needUpdate - - coords = GetEntityCoords(PlayerPedId()) +CreateThread(function() + local ped, currentVeh, distance, coords + oncache.coords = GetEntityCoords(PlayerPedId()) while true do + ped = PlayerPedId() + currentVeh = GetVehiclePedIsIn(ped) + coords = GetEntityCoords(ped) + + distance = #(coords - oncache.coords) - needUpdate = false - distance = #(coords - GetEntityCoords(PlayerPedId())) - if distance > 0.75 then - oncache.player.coords = GetEntityCoords(PlayerPedId()) - coords = oncache.player.coords - needUpdate = true - end - - if (oncache.player.currentvehicle ~= GetVehiclePedIsIn(PlayerPedId(), false)) then - oncache.player.currentvehicle = GetVehiclePedIsIn(PlayerPedId(), false) - needUpdate = true + if distance > 0.80 then + oncache:set('coords', coords) end - if needUpdate then - TriggerEvent('supv_core:refresh:cache', oncache.player) - end + --print(currentVeh) - Wait(300) - if not needUpdate then - Wait(600) + if currentVeh > 0 then + oncache:set('currentvehicle', currentVeh) + else + oncache:set('currentvehicle', false) end + + Wait(1000) end end) +_ENV.oncache = oncache --- garde de côté pour l'utilisation de statebag un jour mais bon ca consomme légèrement plus que le system de cache ---[[ -CreateThread(function() - local loaded = false - while true do - screenX, screenY = GetActiveScreenResolution() - if not loaded then - loaded = true - Cache.player.pedId = PlayerPedId() - Cache.player.id = PlayerId() - Cache.player.serverId = GetPlayerServerId(PlayerId()) - --LocalPlayer.state:set('playerPedId', PlayerPedId(), true) - --LocalPlayer.state:set('playerId', PlayerId(), true) - --LocalPlayer.state:set('serverId', GetPlayerServerId(PlayerId()), true) - end - if not next(Cache.player.screen) or (Cache.player.screen.x ~= screenX and Cache.player.screen.y ~= screenY ) then - Cache.player.screen.x, Cache.player.screen.y = GetActiveScreenResolution() - --LocalPlayer.state:set('resolution', GetActiveScreenResolution(), true) - needUpdate = true - end - if not Cache.player.coords or #(GetEntityCoords(PlayerPedId()) - Cache.player.coords) > 3.0 then - Cache.player.coords = GetEntityCoords(PlayerPedId()) - --LocalPlayer.state:set('coords', GetEntityCoords(PlayerPedId()), true) - needUpdate = true - end - if not Cache.player.currentVehicle or (GetVehiclePedIsIn(PlayerPedId(), false) ~= Cache.player.currentVehicle) then - Cache.player.currentVehicle = GetVehiclePedIsIn(PlayerPedId(), false) - --LocalPlayer.state:set('currentVehicle', GetVehiclePedIsIn(PlayerPedId(), false), true) - needUpdate = true - end - if needUpdate then - TriggerEvent('supv_core:refresh:cache', Cache.player) - end - Wait(500) - end -end) -]] ---_ENV.oncache = oncache \ No newline at end of file +--Player:set('playerid', PlayerId(), true) +--Player:set('pedid', PlayerPedId(), true) +--Player:set('serverid', GetPlayerServerId(PlayerId()), true) +--Player:set('screen', {GetActiveScreenResolution()}, true) +--Player:set('coords', GetEntityCoords(PlayerPedId()), true) +--Player:set('currentvehicle', GetVehiclePedIsIn(PlayerPedId(), false), true) + diff --git a/resources/client/general.lua b/resources/client/general.lua index d154e01..7ec3506 100644 --- a/resources/client/general.lua +++ b/resources/client/general.lua @@ -1,13 +1,20 @@ local Traffic , Npc , VehicleParked = Config.Traffic.amount.traffic, Config.Traffic.amount.npc, Config.Traffic.amount.parked local EnableBoats , EnableTrain , EnableGarbageTruck , EnablePolice = Config.Traffic.enable.boats, Config.Traffic.enable.trains, Config.Traffic.enable.garbageTruck, Config.Traffic.enable.polices - local GetEntityModel = GetEntityModel local RemoveAllPickupsOfType = RemoveAllPickupsOfType local GetGamePool = GetGamePool local DisplayRadar = DisplayRadar local DisableControlAction = DisableControlAction local IsControlPressed = IsControlPressed +local SetRadarBigmapEnabled = SetRadarBigmapEnabled +local RequestScaleformMovie = RequestScaleformMovie +local BeginScaleformMovieMethod = BeginScaleformMovieMethod +local ScaleformMovieMethodAddParamInt = ScaleformMovieMethodAddParamInt +local EndScaleformMovieMethod = EndScaleformMovieMethod +local GetEntityCoords = GetEntityCoords +local PlayerPedId = PlayerPedId +local IsPedArmed = IsPedArmed local function ClearPickupsFromRewards() CreateThread(function() @@ -16,16 +23,16 @@ local function ClearPickupsFromRewards() if Config.DevMod then print(json.encode(GetGamePool('CPickup'))) end - RemoveAllPickupsOfType(0xDF711959) -- carbine rifle + RemoveAllPickupsOfType(0xA9355DCD) -- shotgun + RemoveAllPickupsOfType(0xDF711959) -- carbine-rifle RemoveAllPickupsOfType(0xF9AFB48F) -- pistol - RemoveAllPickupsOfType(0xA9355DCD) -- pumpshotgun end end) end CreateThread(function() - while next(oncache.player) == nil do Wait(50) end + while not next(oncache) do Wait(50) end SetRandomBoats(EnableBoats) SetRandomTrains(EnableTrain) @@ -34,7 +41,7 @@ CreateThread(function() SetCreateRandomCops(EnablePolice) SetCreateRandomCopsNotOnScenarios(EnablePolice) SetCreateRandomCopsOnScenarios(EnablePolice) - SetDispatchCopsForPlayer(oncache.player.playerid, EnablePolice) + SetDispatchCopsForPlayer(oncache.playerid, EnablePolice) SetPedPopulationBudget(Npc) -- 0 = none / 3 = normal (max is 3) SetVehiclePopulationBudget(Traffic) -- https://docs.fivem.net/natives/?_0xCB9E1EB3BE2AF4E9 no more info but is like SetPedPopulationBudget I think... @@ -53,12 +60,12 @@ CreateThread(function() end if not Config.Rewards.vehicle then - DisablePlayerVehicleRewards(oncache.player.playerid) + DisablePlayerVehicleRewards(oncache.playerid) end if not Config.Rewards.npc then for i = 1, #Config.Pickups.Blacklisted do - ToggleUsePickupsForPlayer(oncache.player.playerid, Config.Pickups.Blacklisted[i], false) + ToggleUsePickupsForPlayer(oncache.playerid, Config.Pickups.Blacklisted[i], false) end if Config.Rewards.clearPickUpsRewards then ClearPickupsFromRewards() @@ -89,16 +96,16 @@ CreateThread(function() for i = 1, #list do assert(type(list[i].flagId) == 'number', ("[Error] : In Config.PlayerOptions.flag.list flagId: %s, isn't a number"):format(list[i].flagId)) assert(type(list[i].value) == 'boolean', ("[Error] : In Config.PlayerOptions.flag.list value %s, isn't a boolean"):format(list[i].value)) - SetPedConfigFlag(oncache.player.pedid, list[i].flagId, list[i].value) + SetPedConfigFlag(PlayerPedId(), list[i].flagId, list[i].value) end end if not Config.PlayerOptions.canRagdoll then - SetPedCanRagdoll(oncache.player.pedid, false) + SetPedCanRagdoll(PlayerPedId(), false) end if Config.PlayerOptions.gotDamagedOnlyByPlayers then - SetEntityOnlyDamagedByPlayer(oncache.player.pedid, true) + SetEntityOnlyDamagedByPlayer(PlayerPedId(), true) end if not Config.PlayerOptions.showRadar.visible then @@ -108,9 +115,9 @@ CreateThread(function() end if Config.PlayerOptions.canDoDriveBy == false then - SetPlayerCanDoDriveBy(oncache.player.playerid, false) + SetPlayerCanDoDriveBy(oncache.playerid, false) elseif Config.PlayerOptions.canDoDriveBy == true then - SetPlayerCanDoDriveBy(oncache.player.playerid, true) + SetPlayerCanDoDriveBy(oncache.playerid, true) end end) @@ -123,7 +130,7 @@ if not Config.Traffic.enable.polices then CreateThread(function() while true do Wait(2500) - if #(oncache.player.coords - coords) < 100 then + if #(GetEntityCoords(PlayerPedId()) - coords) < 100 then ClearAreaOfCops(coords.x, coords.y, coords.z, 100.0) Wait(10000) end @@ -137,9 +144,7 @@ if Config.PlayerOptions.showRadar.visible == 'vehicle' then local vehicleBlacklisted , currentValue = Config.PlayerOptions.showRadar.blacklist, false local function ShowRadar(bool) - if currentValue == bool then - return - else + if currentValue ~= bool then currentValue = bool DisplayRadar(bool) return currentValue @@ -151,19 +156,25 @@ if Config.PlayerOptions.showRadar.visible == 'vehicle' then if next(vehicleBlacklisted) then while true do Wait(1000) - if not vehicleBlacklisted[GetEntityModel(oncache.player.currentvehicle)] then + if not vehicleBlacklisted[GetEntityModel(oncache.currentvehicle)] then + if Config.PlayerOptions.showRadarArmourHealth then + SetRadarBigmapEnabled(false, false) + end ShowRadar(true) end - if oncache.player.currentvehicle == 0 then + if oncache.currentvehicle == 0 then ShowRadar(false) end end else while true do Wait(1000) - if oncache.player.currentvehicle == 0 then + if oncache.currentvehicle == 0 then ShowRadar(false) else + if Config.PlayerOptions.showRadarArmourHealth then + SetRadarBigmapEnabled(false, false) + end ShowRadar(true) end end @@ -184,7 +195,7 @@ if not Config.Rewards.vehicle then while true do Wait(1) - DisablePlayerVehicleRewards(oncache.player.playerid) + DisablePlayerVehicleRewards(oncache.playerid) if (GetGameTimer() - time > timer) then return false end @@ -197,7 +208,7 @@ if not Config.Rewards.vehicle then while true do Wait(500) - if listeVehicle[GetEntityModel(GetVehiclePedIsTryingToEnter(oncache.player.pedid))] then + if listeVehicle[GetEntityModel(GetVehiclePedIsTryingToEnter(PlayerPedId()))] then RemoveRewardsFromPoliceVehicle() Wait(2500) end @@ -223,8 +234,8 @@ if Config.PlayerOptions.hideHudComponent.enable then HideHudComponentThisFrame(list[i]) end else - if IsPedArmed(oncache.player.pedid, 4) then intervale = false - local _, hash = GetCurrentPedWeapon(oncache.player.pedid, true) + if IsPedArmed(PlayerPedId(), 4) then intervale = false + local _, hash = GetCurrentPedWeapon(PlayerPedId(), true) if not scopeList[hash] then HideHudComponentThisFrame(14) end @@ -259,7 +270,7 @@ if not Config.PlayerOptions.CrossHit then while true do Wait(0) intervale = true - if IsPedArmed(oncache.player.pedid, 4) then intervale = false + if IsPedArmed(PlayerPedId(), 4) then intervale = false DisableControlAction(1, 140, true) DisableControlAction(1, 141, true) DisableControlAction(1, 142, true) @@ -279,17 +290,17 @@ if Config.AudioRadio.enable or Config.AudioRadio.enable == 'full' then if Config.AudioRadio.enable == true then while true do Wait(1000) - if blacklist[GetEntityModel(oncache.player.currentvehicle)] then + if blacklist[GetEntityModel(oncache.currentvehicle)] then SetUserRadioControlEnabled(false) - SetVehRadioStation(oncache.player.currentvehicle, "OFF") + SetVehRadioStation(oncache.currentvehicle, "OFF") end end elseif Config.AudioRadio.enable == 'full' then while true do Wait(1000) - if oncache.player.currentvehicle then + if oncache.currentvehicle then SetUserRadioControlEnabled(false) - SetVehRadioStation(oncache.player.currentvehicle, "OFF") + SetVehRadioStation(oncache.currentvehicle, "OFF") end end else return false @@ -319,7 +330,7 @@ if Config.PlayerOptions.unlimitedStamina then CreateThread(function() while true do Wait(2000) - ResetPlayerStamina(oncache.player.playerid) + ResetPlayerStamina(oncache.playerid) end end) end @@ -332,8 +343,8 @@ if Config.PlayerOptions.noRollingGunFight then Wait(0) intervale = true - if IsPlayerFreeAiming(oncache.player.playerid) and IsControlPressed(0, 22) then intervale = false - ClearPedTasksImmediately(oncache.player.pedid) + if IsPlayerFreeAiming(oncache.playerid) and IsControlPressed(0, 22) then intervale = false + ClearPedTasksImmediately(PlayerPedId()) end if intervale then @@ -349,8 +360,8 @@ if Config.PlayerOptions.noPunchRunning then while true do Wait(0) intervale = true - if IsPedRunningMeleeTask(oncache.player.pedid) then intervale = false - ClearPedTasksImmediately(oncache.player.pedid) + if IsPedRunningMeleeTask(PlayerPedId()) then intervale = false + ClearPedTasksImmediately(PlayerPedId()) end if intervale then @@ -358,4 +369,33 @@ if Config.PlayerOptions.noPunchRunning then end end end) +end + +if not Config.PlayerOptions.showRadarArmourHealth then + local size = 1 + CreateThread(function() + local minimap = RequestScaleformMovie("minimap") + Wait(1000) + SetRadarBigmapEnabled(true, false) + while size < 1000 do + Wait(0) + BeginScaleformMovieMethod(minimap, "SETUP_HEALTH_ARMOUR") + ScaleformMovieMethodAddParamInt(3) + EndScaleformMovieMethod() + SetRadarBigmapEnabled(false, false) + size += 1 + end + end) +else + --local size = 1 + --CreateThread(function() + -- while size < 500 do + -- Wait(0) + -- SetRadarBigmapEnabled(true, false) + -- SetRadarBigmapEnabled(false, false) + -- DisplayRadar(true) + -- size += 1 + -- end + -- if not Config.PlayerOptions.showRadar then DisplayRadar(false) end + --end) end \ No newline at end of file diff --git a/resources/config/client/client.lua b/resources/config/client/client.lua index 94fdb7d..788a8a2 100644 --- a/resources/config/client/client.lua +++ b/resources/config/client/client.lua @@ -1,27 +1,28 @@ +-- ALL PARAMETER ARE DESACTIVATE PER DEFAULT YOU CAN ACTIVATE AND USE WHAT YOU WANT!!!!!!!! --[[__Manage rewards of your server__]]-- -Config.Rewards = {vehicle = false, npc = false, clearPickUpsRewards = true, listVehicle = {[`polmav`] = true, [`fbi`] = true, [`fib2`] = true, [`police`] = true, [`police2`] = true, [`police3`] = true, [`police4`] = true, [`policeb`] = true, [`policet`] = true, [`policeold1`] = true, [`policeold2`] = true, [`pranger`] = true, [`riot`] = true, [`sheriff`] = true, [`sheriff2`] = true}} -- false to desactivate rewards & true to active them / clearPickUpsRewards set true if npc = false +Config.Rewards = {vehicle = true, npc = true, clearPickUpsRewards = false, listVehicle = {[`polmav`] = true, [`fbi`] = true, [`fib2`] = true, [`police`] = true, [`police2`] = true, [`police3`] = true, [`police4`] = true, [`policeb`] = true, [`policet`] = true, [`policeold1`] = true, [`policeold2`] = true, [`pranger`] = true, [`riot`] = true, [`sheriff`] = true, [`sheriff2`] = true}} -- false to desactivate rewards & true to active them / clearPickUpsRewards set true if npc = false --[[__Manage traffic of your server & dispatch__]]-- Config.Traffic = { - amount = {traffic = 1, npc = 1, parked = 1}, -- 0 = none / 3 is normal (max is maximum) (type: integrer, so don't write 2.5...) - enable = {polices = false, garbageTruck = true, boats = true, trains = true}, - dispatch = { -- https://docs.fivem.net/natives/?_0xDC0F817884CDD856 - polices = {enable = false, list = {1,2,4,6,7,8,9,10,12,13}}, - army = {enable = false, list = {14}}, - ambulance = {enable = false, list = {5,3}}, -- & FireDepartement - gang = {enable = false, list = {11,15}}, - unknow = {enable = false, list = {0}} + amount = {traffic = 3, npc = 3, parked = 3}, -- 0 = none / 3 is normal (max is maximum) (type: integrer, so don't write 2.5...) + enable = {polices = true, garbageTruck = true, boats = true, trains = true}, -- true turn on traffic (default) from key, false turn turn off traffic from key + dispatch = { -- https://docs.fivem.net/natives/?_0xDC0F817884CDD856 -- enable = true (default) active dispatch / false to desactivate dispatch + polices = {enable = true, list = {1,2,4,6,7,8,9,10,12,13}}, -- enable = true (default) active dispatch / false to desactivate dispatch + army = {enable = true, list = {14}}, -- enable = true (default) active dispatch / false to desactivate dispatch + ambulance = {enable = true, list = {5,3}}, -- & FireDepartement -- enable = true (default) active dispatch / false to desactivate dispatch + gang = {enable = true, list = {11,15}}, -- enable = true (default) active dispatch / false to desactivate dispatch + unknow = {enable = true, list = {0}} -- enable = true (default) active dispatch / false to desactivate dispatch }, } --[[__Manage AudioFlag of your server__]]-- Config.AudioFlag = { -- https://docs.fivem.net/natives/?_0xB9EFD5C25018725A - enable = true, -- turn on true to activate script + enable = false, -- turn on true to activate script list = { - {enable = false, name = 'PoliceScannerDisabled'}, -- in an example how to use it, copy/past (enable = false you desactivate AudioFlag of name) + {enable = false, name = 'PoliceScannerDisabled'}, -- in an example how to use it, copy/past (enable = false you desactivate AudioFlag of name) -- false turn off } } --[[__Manage Relationship of your server__]]-- Config.Relationship = { -- https://docs.fivem.net/natives/?_0xBF25EB89375A37AD - enable = true, -- turn on true to activate script + enable = false, -- turn on true to activate script list = { {relation = 1, group1 = {`CIVMALE`, `CIVFEMALE`, `GANG_1`, `GANG_2`, `GANG_9`, `GANG_10`, `AMBIENT_GANG_LOST`, `AMBIENT_GANG_MEXICAN`, `AMBIENT_GANG_FAMILY`, `AMBIENT_GANG_BALLAS`, `AMBIENT_GANG_MARABUNTE`, `AMBIENT_GANG_CULT`, `AMBIENT_GANG_SALVA`, `AMBIENT_GANG_WEICHENG`, `AMBIENT_GANG_HILLBILLY`, `DEALER`,`COP`, `PRIVATE_SECURITY`, `SECURITY_GUARD`, `ARMY`, `MEDIC`, `FIREMAN`, `HATES_PLAYER`, `NO_RELATIONSHIP`, `SPECIAL`, `MISSION2`, `MISSION3`, `MISSION4`, `MISSION5`, `MISSION6`, `MISSION7`, `MISSION8`}, group2 = {`PLAYER`}} -- in this example all ped are neutral with player you can make table in group1 and group2 if you want set a lot type of relationship between ped and player or ped and ped } @@ -29,14 +30,14 @@ Config.Relationship = { -- https://docs.fivem.net/natives/?_0xBF25EB89375A37AD --[[__Manage a lot of options for any player are loaded__]]-- Config.PlayerOptions = { flag = { -- https://docs.fivem.net/natives/?_0x9CFBE10D - enable = true, -- true active script + enable = false, -- true active script list = { {value = false, flagId = 35}, -- for player don't auto put helmet when he is on bike --{value = true, flagId = 429}, -- disable auto start engin when player entered in vehicle } }, hideHudComponent = { -- https://docs.fivem.net/natives/?_0x6806C51AD12B83B8 - enable = true, + enable = false, list = {3,4,6,7,8,9,13,14}, scopeList = {[`WEAPON_SNIPERRIFLE`] = true,[`WEAPON_HEAVYSNIPER`] = true,[`WEAPON_MARKSMANRIFLE`] = true,[`WEAPON_HEAVYSNIPER_MKII`] = true,[`WEAPON_MARKSMANRIFLE_MK2`] = true} -- if you got 14 in list add scope weapon }, @@ -44,15 +45,16 @@ Config.PlayerOptions = { noRollingGunFight = false, -- turn on true to clear task when player try press escape with weapon to roll on the ground noPunchRunning = false, -- turn on true to clear task when player melee attack during run unlimitedStamina = false, -- turn on true for sprint everytime - CrossHit = true, -- false if you want turn off cross hit with weapon + CrossHit = false, -- false if you want turn off cross hit with weapon afkCam = false, -- true per default, false desactivate afkCam canRagdoll = true, -- true per default, false desactivate ragdoll gotDamagedOnlyByPlayers = false, -- false per default, true active script - showRadar = {visible = 'vehicle', blacklist = {[`sanchez`] = true, [`bmx`] = true}}, -- visible: true/false or 'vehicle', if visible = 'vehicle' then you can blacklist some vehicle + showRadar = {visible = true, blacklist = {[`sanchez`] = true, [`bmx`] = true}}, -- visible: true/false or 'vehicle', if visible = 'vehicle' then you can blacklist some vehicle + showRadarArmourHealth = true -- true per default } --[[__Manage Radio Control in vehicle__]]-- Config.AudioRadio = { - enable = 'full', -- turn on true and you use blacklist to turn off radio center key is name of car and true desable radio center, if enable = 'full' blacklist is useless and isn't possible switch, turn off radio in every vehicle, false ignore this script + enable = false, -- turn on true and you use blacklist to turn off radio center key is name of car and true desable radio center, if enable = 'full' blacklist is useless and isn't possible switch, turn off radio in every vehicle, false ignore this script blacklist = { [`police`] = true, -- some example, write hashName only --[`taxi`] = true, @@ -61,7 +63,7 @@ Config.AudioRadio = { } --[[__Edit echap menu__]]-- Config.PauseMenu = { - enable = true, + enable = false, title = 'sublime_core', map = 'sublime city', game = 'you want left?', @@ -69,16 +71,13 @@ Config.PauseMenu = { quit = 'quit game', information = 'breafing', stats = 'statistique', - setting = 'settigs', + setting = 'settings', fivemKey = 'key fivem' , gallery = 'gallery', editor = 'editor', } - - - - -Config.import = { +--[[__Config module default value__]]-- +Config.import = { -- Touch it only if you use module (import) and you want other value per default marker = { m1 = { visible = true, diff --git a/resources/config/shared/shared.lua b/resources/config/shared/shared.lua index 7b09605..77dca8c 100644 --- a/resources/config/shared/shared.lua +++ b/resources/config/shared/shared.lua @@ -1,7 +1,7 @@ -Config.StageBag = { -- don't touch this - player = { - coords = true - } -} +-- Config.StageBag = { -- don't touch this not implemented yet +-- player = { +-- coords = true +-- } +-- } Config.DevMod = false -- turn on true only if you want print ara visible diff --git a/resources/config/translation.lua b/resources/config/translation.lua index b93c564..3212cd5 100644 --- a/resources/config/translation.lua +++ b/resources/config/translation.lua @@ -3,7 +3,7 @@ TR_SELECTED = 'fr' TR = { ['fr'] = { - + }, ['en'] = { diff --git a/version.json b/version.json index 4ef4946..4dda691 100644 --- a/version.json +++ b/version.json @@ -1,7 +1,7 @@ { "enable": true, "script": "supv_core", - "version": "0.3b", + "version": "0.4b", "changelog": [ "^8[Resources]^2:", "\t^3- ^3WATCH ^7CHANGLOG readme on github", diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..e69de29 diff --git a/web/scripts.js b/web/scripts.js new file mode 100644 index 0000000..e69de29 diff --git a/web/styles.css b/web/styles.css new file mode 100644 index 0000000..e69de29