Skip to content

Commit

Permalink
Feat: add convar to control timeouts
Browse files Browse the repository at this point in the history
Really good if ur pc is potato or ur server is running a framework that dosnt release models such as qb, qbox, esx or NDCore
  • Loading branch information
FjamZoo authored Sep 22, 2024
2 parents e24ba97 + 605c0e0 commit 5accd6d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion modules/objectplacer/client.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local placingObj

local requestTimeouts = GetConvarInt('renewed_requesttimeouts', 10000)

-- Object placer --
local OxTxt = {
'-- Place Object -- \n',
Expand Down Expand Up @@ -37,7 +39,7 @@ exports('placeObject', function(object, dist, snapGround, text, allowedMats, off

local txt = text or OxTxt

lib.requestModel(obj)
lib.requestModel(requestTimeouts)

placingObj = CreateObject(obj, 1.0, 1.0, 1.0, false, true, true)
SetModelAsNoLongerNeeded(obj)
Expand Down
3 changes: 2 additions & 1 deletion modules/objects/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local object_class = require 'classes.objects'
local objects = {}

local useInteract = GetConvar('renewed_useinteract', 'false') == 'true'
local requestTimeouts = GetConvarInt('renewed_requesttimeouts', 10000)
local playerInstance = LocalPlayer.state.instance or 0

---goes through the array and find the index and returns that with the object
Expand Down Expand Up @@ -61,7 +62,7 @@ end)
---@param self renewed_objects
local function createObject(self)
if playerInstance ~= self.instance then return end
lib.requestModel(self.model)
lib.requestModel(self.model, requestTimeouts)

local obj = CreateObject(self.model, self.coords.x, self.coords.y, self.coords.z, false, true, true)
SetEntityHeading(obj, self.heading)
Expand Down
4 changes: 3 additions & 1 deletion modules/particle/client.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
local entityParticle = {}

local requestTimeouts = GetConvarInt('renewed_requesttimeouts', 10000)

AddStateBagChangeHandler('entityParticle', nil, function(bagName, _, value)
local entity = GetEntityFromStateBagName(bagName)

Expand All @@ -12,7 +14,7 @@ AddStateBagChangeHandler('entityParticle', nil, function(bagName, _, value)

if value and type(value) == 'table' then
local offset, rotation = value.offset, value.rotation
lib.requestNamedPtfxAsset(value.dict, 1000)
lib.requestNamedPtfxAsset(value.dict, requestTimeouts)

UseParticleFxAsset(value.dict)

Expand Down
5 changes: 3 additions & 2 deletions modules/peds/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ local Peds = {}

local playerInstance = LocalPlayer.state.instance or 0
local useInteract = GetConvar('renewed_useinteract', 'false') == 'true'
local requestTimeouts = GetConvarInt('renewed_requesttimeouts', 10000)

---Spawns the ped on enter
---@param self renewed_peds
local function spawnPed(self)
lib.requestModel(self.model, 1000)
lib.requestModel(self.model, requestTimeouts)

local ped = CreatePed(0, self.model, self.coords.x, self.coords.y, self.coords.z, self.heading, false, true)

Expand All @@ -18,7 +19,7 @@ local function spawnPed(self)
SetBlockingOfNonTemporaryEvents(ped, self.tempevents)

if self.animDict and self.animName then
lib.requestAnimDict(self.animDict, 1000)
lib.requestAnimDict(self.animDict, requestTimeouts)
TaskPlayAnim(ped, self.animDict, self.animName, 8.0, 0, -1, 1, 0, 0, 0)
RemoveAnimDict(self.animDict)
end
Expand Down

0 comments on commit 5accd6d

Please sign in to comment.