Skip to content

feat(resource/streaming): set timeout length and return requested item on success#4

Merged
thelindat merged 3 commits intooverextended:masterfrom
DokaDoka:patch-2
Dec 12, 2021
Merged

feat(resource/streaming): set timeout length and return requested item on success#4
thelindat merged 3 commits intooverextended:masterfrom
DokaDoka:patch-2

Conversation

@DokaDoka
Copy link
Copy Markdown
Collaborator

This is a bit of a mess since I've had it sitting around for about a month and I don't know how to split it up nicely at this point.

It's basically 2 parts:

  • adds the timeout parameter
    allows the number of ticks before timeout to be specified, timeout is avoided if nil
    20 ticks was rarely enough for vehicle spawns

  • returns the requested item on success
    basically just to return the vehicle hash so I don't have to joaat it twice
    added to the other functions for consistency

I haven't tested the functions aside from requestAnimDict and requestModel but everything should still function

@thelindat
Copy link
Copy Markdown
Member

Maybe something like this would be a bit nicer (I'll let you test it, don't want to load up FiveM atm).

local function hasLoaded(fn, type, request, timeout)
    timeout = timeout or 100
    while not fn(request) do
        Wait(0)
        timeout -= 0
        if timeout < 1 then
            return print(('Unable to load %s after %s ticks (%s)'):format(type, timeout, request))
        end
    end
    return name
end

@DokaDoka
Copy link
Copy Markdown
Collaborator Author

DokaDoka commented Dec 12, 2021

100 ticks as the default is fine by me, will still need use a separate variable for timeout or it will always print 0
Vehicles often fail to load in time but everything else is likely fine

@thelindat thelindat merged commit 34bd55e into overextended:master Dec 12, 2021
@DokaDoka DokaDoka deleted the patch-2 branch December 12, 2021 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants