[F]ranK

[HELP] Problem with youtube script on Drive-in

Recommended Posts

Posted (edited)
I was looking for a script that could run videos on my server on some screen, I found this: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11851
However, since I wanted to take the video to another place, I used the modifications that my friend suggested here: https://forum.mtasa.com/topic/81334-cinema-problem-xyz/?tab=comments#comment-744381

But on my server nothing worked, it keeps playing music but the video does not appear on Drive-in. I was wondering how to put the command to open the video panel just for admin.

Here is the script:



local cWindow = guiCreateWindow(337, 177, 816, 762, "CINEMA", false)
local browser = guiCreateBrowser(0, 0, 800, 600, false, false, false, cWindow)

local theBrowser = guiGetBrowser(browser)
addEventHandler("onClientBrowserCreated", theBrowser, 
	function()
		loadBrowserURL(source, "http://www.youtube.com")
	end
)


CINEMA = {
    button = {},
    window = {},
    edit = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        guiWindowSetSizable(cWindow, false)
        guiSetProperty(cWindow, "CaptionColour", "FF0309FB")
		guiSetVisible(cWindow,false)



        CINEMA.button[1] = guiCreateButton(9, 608, 388, 35, "GET URL", false, cWindow)
        guiSetFont(CINEMA.button[1], "default-bold-small")
        guiSetProperty(CINEMA.button[1], "NormalTextColour", "FFFF0000")
        CINEMA.button[2] = guiCreateButton(427, 608, 381, 35, "PUT VIDEO IN CINEMA", false, cWindow)
        guiSetFont(CINEMA.button[2], "default-bold-small")
        guiSetProperty(CINEMA.button[2], "NormalTextColour", "FFFF0000")
        CINEMA.button[3] = guiCreateButton(10, 653, 388, 35, "CLOSE", false, cWindow)
        guiSetFont(CINEMA.button[3], "default-bold-small")
        guiSetProperty(CINEMA.button[3], "NormalTextColour", "FFFF0000")
        CINEMA.button[4] = guiCreateButton(425, 654, 383, 34, "VIEW VIDEO IN FULL SCREEN MODE", false, cWindow)
        guiSetFont(CINEMA.button[4], "default-bold-small")
        guiSetProperty(CINEMA.button[4], "NormalTextColour", "FFFF0000")
        CINEMA.edit[1] = guiCreateEdit(11, 700, 796, 52, "", false, cWindow)
        guiEditSetReadOnly(CINEMA.edit[1], true)    
    end
)


function geturl()
if source == CINEMA.button[1] then
guiSetText(CINEMA.edit[1],getBrowserURL(theBrowser))
end
end
addEventHandler("onClientGUIClick",root,geturl)


function dxDrawImage3D(x,y,z,w,h,m,c,r,...)
        local lx, ly, lz = x+w, y+h, (z+tonumber(r or 0)) or z
    return dxDrawMaterialLine3D(x,y,z, lx, ly, lz, m, h, c , ...)
end
 
 
local screenWidth, screenHeight = guiGetScreenSize()
 
local webBrowser = createBrowser(screenWidth, screenHeight, false, false)

function getPositionFromElementOffset(element, offX, offY, offZ) 
    local m = getElementMatrix(element) 
    local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] 
    local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] 
    local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] 
    return x, y, z 
end 
  
function webBrowserRender() 
    -- This will fetch the top middle point of the drive-in screen (Remember to replace the INSERTSCREENELEMENTHERE variable with your object pointer) 
    local screenPosX, screenPosY, screenPosZ = getPositionFromElementOffset(INSERTSCREENELEMENTHERE, 0, 0.04, 10.6) 
    dxDrawMaterialLine3D(screenPosX, screenPosY, screenPosZ, screenPosX, screenPosY, screenPosZ-8.5, webBrowser, 18, tocolor(255, 255, 255, 255), screenPosX, screenPosY+1, screenPosZ) 
end 

function fullscreen()
local URLs = string.sub(guiGetText(CINEMA.edit[1]),"33")
if source == CINEMA.button[4] then
loadBrowserURL(webBrowser, "https://www.youtube.com/embed/"..URLs.."?autoplay=1&iv_load_policy=3&enablejsapi=1&fs=0&theme=light")
end
end
addEventHandler("onClientGUIClick",root,fullscreen)

function brow()
	if source == CINEMA.button[2] then
        loadBrowserURL(webBrowser, guiGetText(CINEMA.edit[1]))
        addEventHandler("onClientPreRender", root, webBrowserRender)
    end
end
addEventHandler("onClientBrowserCreated", webBrowser, brow)
addEventHandler("onClientGUIClick",root,brow)

function url()
guiSetVisible(cWindow,true)
showCursor( true )
guiSetInputEnabled( true )
end
addCommandHandler("cinema",url)

function closeman()
if source == CINEMA.button[3] then
guiSetVisible(cWindow,false)
showCursor( false )
guiSetInputEnabled( false )
end 
end
addEventHandler("onClientGUIClick",root,closeman)


UP

Edited by [F]ranK

Share this post


Link to post

UP

Share this post


Link to post

HELP PLS

 

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.