This commit is contained in:
Nordi98 2025-07-20 22:12:41 +02:00
parent 702bab121c
commit 9aa690dfc4
37 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,8 @@
Core = {}
Core.Info = {}

local function returnCoreObject()
return Core
end

exports('returnCoreObject', returnCoreObject)

View file

@ -0,0 +1,105 @@
local blips = {}

Core.Natives = {}

function Core.Natives.CreateBlip(coords, sprite, color, scale, label, shortRange)
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
SetBlipSprite(blip, sprite)
SetBlipColour(blip, color)
SetBlipScale(blip, scale)
SetBlipAsShortRange(blip, shortRange)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(label)
EndTextCommandSetBlipName(blip)
blips[#blips + 1] = { id = blip, creator = GetInvokingResource() }
return blips[#blips].id
end

function Core.Natives.RemoveBlip(id)
for _, blip in pairs(blips) do
if blip.id == id then
RemoveBlip(id)
table.remove(blips, _)
return
end
end
end

function Core.Natives.SetGpsRoute(render, coords, color)
if not render then SetGpsMultiRouteRender(render) return end
ClearGpsMultiRoute()
StartGpsMultiRoute(color, true, true)
AddPointToGpsMultiRoute(coords.x, coords.y, coords.z)
SetGpsMultiRouteRender(render)
end

function Core.Natives.CreateProp(model, coords, heading, networked)
RequestModel(joaat(model))
while not HasModelLoaded(joaat(model)) do Wait(10) end
local prop = CreateObject(joaat(model), coords.x, coords.y, coords.z, networked, false, false)
SetEntityHeading(prop, heading)
SetModelAsNoLongerNeeded(model)
return prop
end

function Core.Natives.CreateNpc(model, coords, heading, networked)
RequestModel(model)
while not HasModelLoaded(model) do Wait(10) end
local npc = CreatePed(0, model, coords.x, coords.y, coords.z, heading, networked, false)
SetModelAsNoLongerNeeded(model)
return npc
end

function Core.Natives.CreateVeh(model, coords, heading, networked)
RequestModel(model)
while not HasModelLoaded(model) do Wait(10) end
local veh = CreateVehicle(model, coords.x, coords.y, coords.z, heading, networked, false)
SetModelAsNoLongerNeeded(model)
return veh
end

function Core.Natives.SetEntityProperties(entity, frozen, invincible, oblivious)
if not DoesEntityExist(entity) then return end
FreezeEntityPosition(entity, frozen)
SetEntityInvincible(entity, invincible)
SetBlockingOfNonTemporaryEvents(entity, oblivious)
end

function Core.Natives.PlayAnim(ped, dict, anim, duration, flag, playback)
RequestAnimDict(dict)
while not HasAnimDictLoaded(dict) do Wait(10) end
TaskPlayAnim(ped, dict, anim, 8.0, 8.0, duration, flag, playback, false, false, false)
RemoveAnimDict(dict)
end

function Core.Natives.PlayPtFx(coords, asset, effect, scale)
RequestNamedPtfxAsset(asset)
while not HasNamedPtfxAssetLoaded(asset) do Wait(10) end
UseParticleFxAsset(asset)
StartParticleFxNonLoopedAtCoord(effect, coords.x, coords.y, coords.z, 0, 0, 0, scale, false, false, false)
RemoveNamedPtfxAsset(asset)
end

function Core.Natives.PlayPtFxLooped(coords, asset, effect, scale, duration)
RequestNamedPtfxAsset(asset)
while not HasNamedPtfxAssetLoaded(asset) do Wait(0) end
UseParticleFxAsset(asset)
local ptFx = StartParticleFxLoopedAtCoord(effect, coords.x, coords.y, coords.z, 0, 0, 0, scale, false, false, false, false)
SetTimeout(duration, function()
StopParticleFxLooped(ptFx, false)
RemoveNamedPtfxAsset(asset)
end)
end

AddEventHandler('onResourceStop', function(resource)
local removed = 0
if resource ~= GetCurrentResourceName() then
for _, blip in pairs(blips) do
if blip.creator == resource then
RemoveBlip(blip.id)
removed = removed + 1
end
end
if removed > 0 then print('[DEBUG] - removed blips for ' .. resource) end
end
end)

View file

@ -0,0 +1,8 @@
Core = {}
Core.Info = {}

local function returnCoreObject()
return Core
end

exports('returnCoreObject', returnCoreObject)

View file

@ -0,0 +1,54 @@
local second = 1000
local minute = second * 60
local hour = minute * 60

local function checkBridgeVersion()
if Cfg.VersionCheck then
Core.VersionCheck(GetCurrentResourceName())
SetTimeout(1 * hour, checkBridgeVersion)
end
end

function Core.VersionCheck(resource)
local url = 'https://api.github.com/repos/r-scripts-versions/' .. resource .. '/releases/latest'
local current = GetResourceMetadata(resource, 'version', 0)
PerformHttpRequest(url, function(err, txt, head)
if err == 200 then
local data = json.decode(txt)
local latest = data.tag_name
if latest ~= current then
print('[^3WARNING^0] Please update ' .. resource .. ' to its latest version.')
print('[^3WARNING^0] Current: ' .. current .. '')
print('[^3WARNING^0] Latest: ' .. latest .. '')
print('[^3WARNING^0] https://discord.gg/rscripts')
end
end
end)
end

AddEventHandler('onResourceStart', function(resource)
if (GetCurrentResourceName() == resource) then
print('------------------------------')
print(resource .. ' | ' .. GetResourceMetadata(resource, 'version', 0))
if not Core.Info.Framework then
print('^1Framework not found^0')
else
print('Framework: ' .. Core.Info.Framework)
end
if not Core.Info.Inventory then
print('^1Inventory not found^0')
else
print('Inventory: ' .. Core.Info.Inventory)
end
if not Core.Info.Target then
print('^1Target not found^0')
else
print('Target: ' .. Core.Info.Target)
end
if Cfg.Carlock then
print('Carlock: ' .. Cfg.Carlock)
end
print('------------------------------')
checkBridgeVersion()
end
end)