Skip to content

Commit

Permalink
#update supv_core v0.7.3b
Browse files Browse the repository at this point in the history
Module :
- Add math.time
- Add math.doubleDigits
- Edit player/server last coords
- Edit tool (laser function)
  • Loading branch information
SUP2Ak committed Dec 18, 2022
1 parent 87d012d commit 829d5ed
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ game 'gta5'
lua54 'yes'

author 'SUP2Ak'
version '0.7.2'
version '0.7.3'
link 'https://github.com/SUP2Ak/supv_core'

description 'a core standalone to manage your server and got useful function to develop it too'
Expand Down
45 changes: 45 additions & 0 deletions imports/math/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,52 @@ local function Chance(percent, cb)
return result <= percent
end

--retourne une valeur sur 2 digit (exemple 1 retourne 01)
local function deuxDigits(nombre)
nombre = string.format("%02d",nombre)
return nombre
end

--convertit un temps (en seconde) en SEM JJ HH MM SS
local function format_temps(sec, value)
--valeur possible semaine, jour, heure, minute ou seconde
local sem, jj, hh, mm, ss, reste = 0, 0, 0, 0, 0
if value ~= nil then
if value == 'semaine' then
sem = math.floor(sec/(60*60*24*7))
reste = sec%604800
jj = math.floor(reste/(60*60*24))
reste = (reste%86400)
hh = math.floor(reste/(60*60))
reste = (reste%3600)
mm = math.floor(reste/60)
ss = (reste%60)
elseif value == 'jour' then
jj = math.floor(sec/(60*60*24))
reste = (sec%86400)
hh = math.floor(reste/(60*60))
reste = (reste%3600)
mm = math.floor(reste/60)
ss = (reste%60)
elseif value == 'heure' then
hh = math.floor(sec/(60*60))
reste = (sec%3600)
mm = math.floor(reste/60)
ss = (reste%60)
elseif value == 'minute' then
mm = math.floor(sec/60)
reste = (sec%60)
ss = (reste)
elseif value == 'seconde' then
ss = sec
end
end
return sem, jj, deuxDigits(hh), deuxDigits(mm), deuxDigits(ss)
end

return {
round = Round,
chance = Chance,
doubleDigits = deuxDigits,
time = format_temps
}
5 changes: 5 additions & 0 deletions imports/player/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ local function getCurrentVehicle(self)
return false
end

local function getIsDead(self)
return IsPedDeadOrDying(self.pedid, 1) or false
end

--- player.get
---
---@param target nil|source
Expand All @@ -47,6 +51,7 @@ local function getPlayer(target)
self.currentvehicle = GetVehiclePedIsIn(self.pedid)
self.coords = GetEntityCoords(self.pedid)
self.dist = nil
self.isDead = getIsDead
self.distance = getDistanceCoords
self.getCoords = getCoords
self.currentVehicle = getCurrentVehicle
Expand Down
10 changes: 10 additions & 0 deletions imports/player/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ local function GetPlayerIdentifier(self, key)
if self[key] then return self[key] end
end

local function UpdateCoords(self)
self.lastCoords = self:getVec3()
end

local function GetLastCoords(self)
return self.lastCoords
end

--- player.getFromId
---
---@param source number
Expand All @@ -86,9 +94,11 @@ local function GetPlayerFromId(source)
self.getVec4 = Vector4
self.distance = GetDistanceBetweenCoords
self.getPedInVehicle = GetVehicle
self.updateCoords = UpdateCoords

self.license = self:getIdentifier('license')
self.steamid = self:getIdentifier('steamid')
self.lastCoords = self:getVec3()

self.dist = 0

Expand Down
2 changes: 1 addition & 1 deletion imports/tool/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ local function Show(cb)
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))
cb(entity, GetEntityModel(entity), GetEntityArchetypeName(entity), GetEntityCoords(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)
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"script": "supv_core",
"version": "0.7.2",
"version": "0.7.3",
"link": "https://github.com/SUP2Ak/supv_core"
}

0 comments on commit 829d5ed

Please sign in to comment.