all-in-simplicity / fivem-hypnonema

Media Player Resource for FiveM
Other
140 stars 73 forks source link

[FEATUREREQUEST] Autoplay on Server Startup #81

Open mikrolai opened 2 years ago

mikrolai commented 2 years ago

Hi dude, first at all ur script is awesome and im very thankful for it! Can u add an option so hypnonema plays a video (that can be set in the config for example) automatically on server startup?

So we dont have to start it manually.

Rosw3lluk commented 2 years ago

You Could use the new exports he has added, Example:

Citizen.CreateThread(function()
    while not exports or not exports['hypnonema'] do Wait(1) end
    local URLTOPLAY = 'https://www.linktovideo.com/video,mp4'
    local screens = json.decode(exports.hypnonema:getScreenList())
    for k, v in pairs(screens) do
        if v.Name ~= nil then
            exports.hypnonema:play(v.Name, URLTOPLAY)
        end
    end
end)

Please note i have not tested this as i was not at a computer, but it seems correct at first glance :)

Simply just add this inside any server side file to run immediately on server startup, and your good,

I have edited to ensure the exports for hypnonema is ready before executing

all-in-simplicity commented 2 years ago

I'll implement it. This will come next after I finished the schedulable playback feature.