Skip to content

Commit

Permalink
#update 0.7.1 beta
Browse files Browse the repository at this point in the history
- Update a lot tool module
- 1 minor issue corrected npc module
- Add createLocal object module
- Update checker version auto message with default translate
  • Loading branch information
SUP2Ak committed Nov 2, 2022
1 parent 55802a9 commit 39d67c0
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 24 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'
version '0.7.1'
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
8 changes: 4 additions & 4 deletions imports/npc/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ local function NoSync(hash, coords, data, weapon)
self.data = {}

if data then
self.data.blockevent = data.blockevent or default.client.data.blockevent
self.data.freeze = data.freeze or default.client.data.freeze
self.data.godmode = data.godmode or default.client.data.godmode
self.data.variation = data.varation or default.client.data.varation
self.data.blockevent = data?.blockevent or default.client.data.blockevent
self.data.freeze = data?.freeze or default.client.data.freeze
self.data.godmode = data?.godmode or default.client.data.godmode
self.data.variation = data?.variation or default.client.data.varation
else
self.data.blockevent = default.client.data.blockevent
self.data.freeze = default.client.data.freeze
Expand Down
16 changes: 14 additions & 2 deletions imports/object/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,22 @@ local function New(modelHash, setting)
return self
end

local function Created(model, coords, cb, mission)
local function Created(model, coords, cb, mission) -- networked
CreateThread(function()
supv.stream.request(model)

local obj = CreateObjectNoOffset(model, coords.xyz, true, mission or false, true)
local obj = CreateObject(model, coords.xyz, true, mission or false, true)
if cb then
cb(obj)
end
end)
end

local function CreatedLocal(model, coords, cb, mission) -- not networked
CreateThread(function()
supv.stream.request(model)

local obj = CreateObject(model, coords.xyz, false, mission or false, true)
if cb then
cb(obj)
end
Expand All @@ -115,4 +126,5 @@ end
return {
new = New,
create = Created,
createLocal = CreatedLocal
}
142 changes: 130 additions & 12 deletions imports/tool/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,17 @@ local PlayerPedId <const> = PlayerPedId

-- function Laser

local function Show(mode, cb)
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)
if mode == 'select' then
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 mode == 'delete' then
--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), entityCoord)
--end
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)
Expand Down Expand Up @@ -430,10 +423,135 @@ local function CreateProps(model, setting)
return self
end

-- Get Entity Obj

local function SelectedRemove(self)
if self.entity and DoesEntityExist(self.entity) then
DeleteEntity(self.entity)
end
return nil, collectgarbage()
end

local function SelectedSetter(self, key, value, value2, value3)
if key == 'freeze' then
FreezeEntityPosition(self.entity, value)
elseif key == 'collision' then
SetEntityCollision(self.entity, value, value2 or true)
elseif key == 'alpha' then
SetEntityAlpha(self.entity, value, value2 or 0)
elseif key == 'visible' then
SetEntityVisible(self.entity, value, value2 or 0)
elseif key == 'coords' then
SetEntityCoords(self.entity, value, value2, value3)
elseif key == 'heading' then
SetEntityHeading(self.entity, value)
end
end

local function SelectedGetter(self, key)
if key == 'freeze' then
self.entity_isFrozen = IsEntityPositionFrozen(self.entity)
return self.entity_isFrozen
elseif key == 'collision' then
self.entity_collision = GetEntityCollisionDisabled(self.entity)
return self.entity_collision
elseif key == 'vec3' then
self.coords = GetEntityCoords(self.entity)
return self.coords
elseif key == 'heading' then
self.heading = GetEntityHeading(self.entity)
return self.heading
elseif key == 'vec4' then
local coords, heading = GetEntityCoords(self.entity), GetEntityHeading(self.entity)
self.vec4 = vec4(coords.x, coords.y, coords.z, heading)
return self.vec4
elseif key == 'alpha' then
self.entity_alpha = GetEntityAlpha(self.entity)
return self.entity_alpha
end
self.entity_isFrozen, self.entity_collision, self.coords, self.heading, self.entity_alpha = IsEntityPositionFrozen(self.entity), GetEntityCollisionDisabled(self.entity), GetEntityCoords(self.entity), GetEntityHeading(self.entity), GetEntityAlpha(self.entity)
local coords, heading = GetEntityCoords(self.entity), GetEntityHeading(self.entity)
self.vec4 = vec4(coords.x, coords.y, coords.z, heading)
return {isFrozen = self.entity_isFrozen, collisionDisable = self.entity_collision, coords = self.coords, heading = self.heading, vec4 = self.vec4, alpha = self.entity_alpha}
end

local function SelectedAttach(self, target, data)
if not DoesEntityExist(target) and not DoesEntityExist(self.entity) then return end
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 IsEntityAttached(self.entity) then DetachEntity(self.entity, 1, 1) end
if IsEntityAttached(target) then DetachEntity(target, 1, 1) end
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)
self.native = ("AttachEntityToEntity(%s:entity, %s:entity, GetPedBoneIndex(%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])
return
elseif self.entity_type == 2 then -- vehicle
if not self._bone then self._bone = BoneList[2][1].index end
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
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
return
end

local function SelectedDetach(self)
if not DoesEntityExist(self.entity) then return end
if IsEntityAttached(self.entity) or IsEntityAttachedToAnyObject(self.entity) then
DetachEntity(self.entity,1,1)
end
end

local function UnSelected(self)
return nil, collectgarbage()
end

local function SelectedReset(self)
ResetEntityAlpha(self.entity)
SetEntityCollision(self.entity, true, true)
--SetEntityVisible(self.entity, false, 0)
SetEntityCoords(self.entity, self.firstCoord.x, self.firstCoord.y, self.firstCoord.z)
SetEntityHeading(self.entity, self.firstHeading)
--SetEntityVisible(self.entity, true, 0)
end

local function SelectEntity(entity)
local self = {}

self.entity = entity
self.model = GetEntityModel(self.entity) ---@return hash
self.coords = GetEntityCoords(self.entity) ---@return vector3
self.heading = GetEntityHeading(self.entity) ---@return float
self.entity_type = GetEntityType(self.entity) ---@return int
self.entity_alpha = GetEntityAlpha(self.entity) ---@return int
self.entity_isFrozen = IsEntityPositionFrozen(self.entity) ---@return boolean
self.entity_collision = GetEntityCollisionDisabled(self.entity) ---@return boolean
self.vec4 = vec4(self.coords.x, self.coords.y, self.coords.z, self.heading) ---@return vector4
self.firstCoord = self.coords
self.firstHeading = self.heading

self.boneList = BoneList[self.entity_type] ---@return table

self.set = SelectedSetter
self.get = SelectedGetter
self.remove = SelectedRemove
self.attach = SelectedAttach
self.detach = SelectedDetach
self.unSelect = UnSelected
self.reset = SelectedReset
--self.edit = SelectedEdit

return self
end


return {
laser = Show,
draw3d = Draw3dText,
boneList = BoneList,
createProps = CreateProps
createProps = CreateProps,
selectEntity = SelectEntity
}
25 changes: 22 additions & 3 deletions imports/version/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,28 @@ local function findPattern(text, pattern, start)
return string.sub(text, string.find(text, pattern, start))
end

local function Check(url, checker, error, types, link, timer)
local function Check(url, checker, error, types, link, lang, timer)
if #url < 10 and not version and not types then return end

local message <const> = {
['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"
}
}

local tr

if lang and not message[lang] then tr = 'en' elseif lang and message[lang] then tr = lang end

local Checker = checker or message[tr].needUpate or message['en'].needUpate
local Error = error or message[tr].error or message['en'].error

CreateThread(function()
Wait(timer or 3000)

Expand All @@ -30,11 +49,11 @@ local function Check(url, checker, error, types, link, timer)
if _gv.version == version then return end
if _gv.version ~= version then
print('^9---------------------------------------------------------')
print(checker:format(_gv.script, version, _gv.version, _gv.link))
print(Checker:format(_gv.script, version, _gv.version, _gv.link))
print('^9---------------------------------------------------------')
end
else
print(error)
print(Error)
end
end)
end)
Expand Down
4 changes: 2 additions & 2 deletions imports/webhook/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
---@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)
TriggerServerEvent('supv_core:server:webhook:message', channel_id, text, bot_name)
end

--- webhook.embed
Expand All @@ -16,7 +16,7 @@ end
---@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)
TriggerServerEvent('supv_core:server:webhook:embed', channel_id, embed, bot_name, avatar)
end

return {
Expand Down

0 comments on commit 39d67c0

Please sign in to comment.