diff --git a/fxmanifest.lua b/fxmanifest.lua index d5e103a..0357ba9 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -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' diff --git a/imports/math/shared.lua b/imports/math/shared.lua index d693251..9dbf15a 100644 --- a/imports/math/shared.lua +++ b/imports/math/shared.lua @@ -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 } \ No newline at end of file diff --git a/imports/player/client.lua b/imports/player/client.lua index 0dc8c37..3e50f9e 100644 --- a/imports/player/client.lua +++ b/imports/player/client.lua @@ -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 @@ -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 diff --git a/imports/player/server.lua b/imports/player/server.lua index 50f95bc..4e915d4 100644 --- a/imports/player/server.lua +++ b/imports/player/server.lua @@ -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 @@ -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 diff --git a/imports/tool/client.lua b/imports/tool/client.lua index 859de48..b2368bf 100644 --- a/imports/tool/client.lua +++ b/imports/tool/client.lua @@ -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) diff --git a/version.json b/version.json index 1de8df3..4724ed3 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { "script": "supv_core", - "version": "0.7.2", + "version": "0.7.3", "link": "https://github.com/SUP2Ak/supv_core" } \ No newline at end of file