Lergen Posted December 23, 2019 Share Posted December 23, 2019 Hello. I made a slight modification to Dutchman's BSOD script to play a video rather than display an image, but I'm receiving an error on line 5: "attempt to call global 'playVideo' (a nil value). Can anyone offer some advice as to what's wrong here? I'd greatly appreciate it. local bsodTimer function renderBSOD() local x, y = guiGetScreenSize() playVideo (0, 0, x, y, "bs2.mp4", 90600, false, false) -- bs.png for win7/XP, bs2.png for Win10/modern BSOD screen. change at will end function performPrank(thePlayer) if (thePlayer == getLocalPlayer()) then if (isTimer(bsodTimer)) then killTimer(bsodTimer) end for i = 1, 100 do setWorldSoundEnabled(i, false) end setAmbientSoundEnabled("general", false) setAmbientSoundEnabled("gunfire", false) setInteriorSoundsEnabled(false) showChat(false) setPlayerHudComponentVisible("all", false) setSoundVolume(sound, 0.5) removeEventHandler("onClientRender", getRootElement(), renderBSOD) addEventHandler("onClientRender", getRootElement(), renderBSOD) bsodTimer = setTimer( function() removeEventHandler("onClientRender", getRootElement(), renderBSOD) showChat(true) setPlayerHudComponentVisible("all", true) setAmbientSoundEnabled("general", true) setAmbientSoundEnabled("gunfire", true) setInteriorSoundsEnabled(true) resetWorldSounds() end,420000,1) end end addEvent("showBSODToPlayer", true) addEventHandler("showBSODToPlayer", getRootElement(), performPrank) Link to comment
Bilal135 Posted December 23, 2019 Share Posted December 23, 2019 'playVideo' is not a built in function. Its a useful function that can be found on wiki but it has to be defined first. Copy and paste this above renderBSOD, function playVideo (posX, posY, width, height, url, duration, canClose, postGUI) if not posX or not posY or not width or not height or not url then return false end local webBrowser = false closeButton = guiCreateButton (0.97, 0, 0.03, 0.03, "X", true) guiSetAlpha (closeButton, 0.5) guiSetVisible (closeButton, false) if not isElement (webBrowser) then webBrowser = createBrowser (width, height, false, false) function createVideoPlayer () function webBrowserRender () dxDrawImage (posX, posY, width, height, webBrowser, 0, 0, 0, tocolor(255,255,255,255), postGUI) end loadBrowserURL (webBrowser, url) setTimer (function() addEventHandler ("onClientRender", getRootElement(), webBrowserRender) showChat (false) if canClose then guiSetVisible (closeButton, true) showCursor (true) end end, 500, 1) setElementFrozen (localPlayer, true) if duration then videoTimer = setTimer (function() removeEventHandler ("onClientRender", getRootElement(), webBrowserRender) setElementFrozen (localPlayer, false) guiSetVisible (closeButton, false) showCursor (false) showChat (true) destroyElement (webBrowser) end, duration, 1) end addEventHandler ("onClientGUIClick", closeButton, function (button, state) if button == "left" then if isTimer (videoTimer) then killTimer (videoTimer) videoTimer = nil removeEventHandler ("onClientRender", getRootElement(), webBrowserRender) setElementFrozen (localPlayer, false) guiSetVisible (closeButton, false) showCursor (false) showChat (true) destroyElement (webBrowser) end end end, false) end setTimer (createVideoPlayer, 500, 1) end end 1 Link to comment
Lergen Posted December 23, 2019 Author Share Posted December 23, 2019 Thanks for the tip. So after trying that code and starting the script, I get barraged with error messages when I start the video: "bad argument at 'dxDrawimage' [expected material at argument 5, got nil]" and "bad argument at 'loadbrowserURL' [expected browser at argument 1, got nil]" Thinking the problem was with it being that I was using a video file rather than a video URL, I tried the YouTube example on the wiki function renderBSOD() local x, y = guiGetScreenSize() playVideo (0, 0, x, y, "https://www.youtube.com/embed/rRjY8SOZ9Uo?autoplay=1&showinfo=0&rel=0&controls=0&disablekb=1", 90600, false, false) -- bs.png for win7/XP, bs2.png for Win10/modern BSOD screen. change at will end However doing it this way causes the screen to go white and crashes MTA. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now