Skip to content

Commit

Permalink
#update 0.7 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
SUP2Ak committed Oct 30, 2022
1 parent d823b9f commit 84ccd4f
Show file tree
Hide file tree
Showing 61 changed files with 475 additions and 103 deletions.
5 changes: 0 additions & 5 deletions _g.lua

This file was deleted.

Empty file removed imports/getmethods/client.lua
Empty file.
13 changes: 0 additions & 13 deletions imports/math/shared.lua

This file was deleted.

14 changes: 0 additions & 14 deletions resources/config/translation.lua

This file was deleted.

2 changes: 1 addition & 1 deletion README.md → supv_core/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align="center"><u><b>supv_core v0.5b</b></u></h1>
<h1 align="center"><u><b>supv_core v0.3b</b></u></h1>

:fr:

Expand Down
3 changes: 3 additions & 0 deletions supv_core/_g.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Don't touch hit
_G.Config = {}
_G.oncache = {}
8 changes: 4 additions & 4 deletions fxmanifest.lua → supv_core/fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
fx_version 'cerulean'
game 'gta5'
lua54 'yes'
use_experimental_fxv2_oal 'yes'
--use_experimental_fxv2_oal 'yes'

author 'SUP2Ak'


version '0.5b' -- b for beta
version '0.7' -- [beta]
link 'https://github.com/SUP2Ak/supv_core'

description 'a core standalone to manage your server and got useful function to develop it too'

shared_script '_g.lua'

shared_scripts {
'import.lua',
'resources/config/shared/*.lua',
'resources/shared/*.lua',
}
Expand Down
File renamed without changes.
File renamed without changes.
81 changes: 81 additions & 0 deletions supv_core/imports/blips/client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
local RemoveBlip <const> = RemoveBlip
local AddBlipForCoord <const> = AddBlipForCoord
local SetBlipSprite <const> = SetBlipSprite
local SetBlipColour <const> = SetBlipColour
local SetBlipScale <const> = SetBlipScale
local SetBlipAsShortRange <const> = SetBlipAsShortRange
local BeginTextCommandSetBlipName <const> = BeginTextCommandSetBlipName
local AddTextComponentSubstringPlayerName <const> = AddTextComponentSubstringPlayerName
local EndTextCommandSetBlipName <const> = EndTextCommandSetBlipName
local DoesBlipExist <const> = DoesBlipExist

local function Delete(self)
if self[1] then
for i = 1, #self do
if self[i].blip and DoesBlipExist(self[i].blip) then RemoveBlip(self[i].blip) end
end
else
if self.blip and DoesBlipExist(self.blip) then RemoveBlip(self.blip) end
end
return nil, collectgarbage()
end

local function Create(coords, data)
if not data.sprite and not data.label and not data.color then return end

local self, multiple = {}, false

if type(coords) == 'table' then
for i = 1, #coords do
self[i] = {}
self[i].coords = coords[i]
self[i].sprite = data.sprite
self[i].color = data.color
self[i].label = data.label
self[i].scale = data?.scale or 1.0
self[i].range = data?.range or true
self[i].group = data?.group or nil
self[i].remove = Delete
end
multiple = true
elseif type(coords) == 'vector3' then
self.coords = coords
self.sprite = data.sprite
self.label = data.label
self.color = data.color
self.scale = data?.scale or 1.0
self.range = data?.range or true
self.group = data?.group or nil
self.remove = Delete
else return end

CreateThread(function()
if multiple then
for i = 1, #self do
self[i].blip = AddBlipForCoord(self[i].coords)
SetBlipSprite(self[i].blip, self[i].sprite)
SetBlipColour(self[i].blip, self[i].color)
SetBlipScale(self[i].blip, self[i].scale)
SetBlipAsShortRange(self[i].blip, self[i].range)
BeginTextCommandSetBlipName('STRING')
AddTextComponentSubstringPlayerName(self[i].label)
EndTextCommandSetBlipName(self[i].blip)
end
else
self.blip = AddBlipForCoord(self.coords)
SetBlipSprite(self.blip, self.sprite)
SetBlipColour(self.blip, self.color)
SetBlipScale(self.blip, self.scale)
SetBlipAsShortRange(self.blip, self.range)
BeginTextCommandSetBlipName('STRING')
AddTextComponentSubstringPlayerName(self.label)
EndTextCommandSetBlipName(self.blip)
end
end)

return self
end

return {
new = Create
}
File renamed without changes.
17 changes: 8 additions & 9 deletions imports/draw/client.lua → supv_core/imports/draw/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ end
---@param text string string
---@param data table {color_rect1 = {0,0,0,150}, color_rect2 = {255,0,0,100}, scale = {0.35,0.35}, police = 1}
local function Text3D(coords, text, data)

if data.z then
coords = vec3(coords.x, coords.y, coords.z + data.z)
end

local onScreen, _x, _y = World3dToScreen2d(coords.x, coords.y, coords.z)
local color, scale, police = {}, data.scale or {0.25,0.25}, data.police or 0
color.text = data.color_text or {255,255,255,255}
Expand Down Expand Up @@ -472,20 +477,14 @@ local function ProgressBar(text, time, setting, data, action)
end
end
if progressbar.setting.animation then
if anim == nil then
anim = supv.animation.strict(progressbar.setting.animation, progressbar.setting.prop)
end
if anim == nil then anim = supv.animation.strict(progressbar.setting.animation, progressbar.setting.prop ~= nil and progressbar.setting.prop) end
anim:play()
end

if (GetGameTimer() - ProgressInitTimer > time) then
Finished(false)
if anim then
anim = anim:stop()
end
if action.success then
action.success()
end
if anim then anim = anim:stop() end
if action.success then action.success() end
ProgressBarActive = false
return false
end
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,42 @@ local default <const> = {

local DrawMarker <const> = DrawMarker

local function Show(coords, params)

local args = {}

--print(json.encode(params, {indent=true}), 'show')

args.visible = params?.visible or nil
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.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
args.color = params?.color or default.m1.color1

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)
end
end

local function Marker(double, inside, coords, params, params2)

if double then
Expand Down Expand Up @@ -125,5 +161,6 @@ end


return {
simple = Marker
simple = Marker,
show = Show
}
31 changes: 31 additions & 0 deletions supv_core/imports/math/shared.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
local math <const>, type <const>, tonumber <const> = math, type, tonumber

--- math.round
---
---@param num number
---@param numDecimalPlaces? number
---@return number
local function Round(num, numDecimalPlaces)
return tonumber(string.format("%."..(numDecimalPlaces or 0).."f", num))
end

--- math.chance
---
---@param percent number
---@param cb? function
---@return boolean
local function Chance(percent, cb)
if type(percent) ~= 'number' then return end
if percent < 1 then return false end
if percent > 99 then return true end
local result = math.random(1,100)
if cb then
cb(result)
end
return result <= percent
end

return {
round = Round,
chance = Chance,
}
23 changes: 23 additions & 0 deletions supv_core/imports/nativeui/client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local IsOpen = false


local function CreateMenu(title, subtitle, options)

if IsOpen then return end

local self = {}

self.title = title
self.subtitle = subtitle
self.options = options

return self
end

RegisterNetEvent('supv_core:nativeui:menuIsShow', function(open)
IsOpen = open
end)

return {
menu = CreateMenu
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ local function GetContent(self)
if result ~= nil then
return json.decode(result)
end
error(("[ERROR] de la récupération du fichier %s"):format(filePath), 2)
error(("[ERROR] de la récupération du fichier %s"):format(self.filePath), 2)
return nil
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
local SetNotificationTextEntry <const> = SetNotificationTextEntry
local AddTextComponentString <const> = AddTextComponentString
local ThefeedNextPostBackgroundColor <const> = ThefeedNextPostBackgroundColor
local EndTextCommandThefeedPostTicker <const> = EndTextCommandThefeedPostTicker
local BeginTextCommandThefeedPost <const> = BeginTextCommandThefeedPost
local AddTextEntry <const> = AddTextEntry
local AddTextComponentSubstringPlayerName <const> = AddTextComponentSubstringPlayerName
local EndTextCommandThefeedPostMessagetext <const> = EndTextCommandThefeedPostMessagetext
local DisplayHelpTextThisFrame <const> = DisplayHelpTextThisFrame
local BeginTextCommandDisplayHelp <const> = BeginTextCommandDisplayHelp
local EndTextCommandDisplayHelp <const> = EndTextCommandDisplayHelp
local SetFloatingHelpTextWorldPosition <const> = SetFloatingHelpTextWorldPosition
local SetFloatingHelpTextStyle <const> = SetFloatingHelpTextStyle

--- SimpleNotification
---
---@param txt string
Expand Down Expand Up @@ -54,10 +68,10 @@ end
---@param txt string
---@param coords vector3
local function FloatNotification(txt, coords) --> [Client]
AddTextEntry('supv_core:FloatingHelpNotification', txt)
AddTextEntry('supv_coreFloatingHelpNotification', txt)
SetFloatingHelpTextWorldPosition(1, coords)
SetFloatingHelpTextStyle(1, 1, 2, -1, 3, 0)
BeginTextCommandDisplayHelp('supv_core:FloatingHelpNotification')
BeginTextCommandDisplayHelp('supv_coreFloatingHelpNotification')
EndTextCommandDisplayHelp(2, false, false, -1)
end

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions imports/npc/client.lua → supv_core/imports/npc/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ local function DeletedNoSync(self)
if DoesEntityExist(self.ped) then
DeleteEntity(self.ped)
end
return nil , collectgarbage()
return nil, collectgarbage()
end

--- npc.unNet
Expand All @@ -122,7 +122,7 @@ end
---@return table
local function NoSync(hash, coords, data, weapon)
local self = {}
local iter = 0

if hash == nil or coords == nil then
return
end
Expand Down
File renamed without changes.
Loading

0 comments on commit 84ccd4f

Please sign in to comment.