CodX Posted October 16, 2017 Posted October 16, 2017 Hello ! It's posible to place a mp4 media file onto account-system, like a trailer, to replace the image ? If yes, can you help me to make that script ?
^iiEcoo'x_) Posted October 17, 2017 Posted October 17, 2017 Create HTML web and connect to web . guiCreateBrowser
CodX Posted October 22, 2017 Author Posted October 22, 2017 Isn;t good. I want to play the video in background.
Moderators IIYAMA Posted October 22, 2017 Moderators Posted October 22, 2017 You can render it as well, see example: 'Local example' https://wiki.multitheftauto.com/wiki/CreateBrowser
CodX Posted October 22, 2017 Author Posted October 22, 2017 (edited) Work, but video isn't rendered. Edited October 22, 2017 by CodX
ShayF2 Posted October 22, 2017 Posted October 22, 2017 (edited) try using this Wiki Code: createBrowser Spoiler -- This is an example off of the wiki. I know browsers are a bit complicated. -- https://wiki.multitheftauto.com/wiki/CreateBrowser --In order to render the browser on the full screen, we need to know the dimensions. local sx,sy = guiGetScreenSize() --Let's create a new browser in local mode. We will not be able to load an external URL. local webBrowser = createBrowser(sx,sy,true,false) --This is the function to render the browser. function webBrowserRender() --Render the browser on the full size of the screen. dxDrawImage(0,0,sx,sy,webBrowser,0,0,0,tocolor(255,255,255,255),true) end --The event onClientBrowserCreated will be triggered, after the browser has been initialized. --After this event has been triggered, we will be able to load our URL and start drawing. addEventHandler('onClientBrowserCreated',webBrowser,function() --After the browser has been initialized, we can load our file. loadBrowserURL(webBrowser,'http://mta/local/html/site.html') --Now we can start to render the browser. addEventHandler('onClientRender',root,webBrowserRender) end) My code: Spoiler -- Create a table of browsers browsers = {} -- Then create a function to create the browser function dxDrawWebBrowser(x,y,w,h,url) -- creating a table for its data local self = {} self.x = x self.y = y self.w = w self.h = h self.url = url -- using a toggle for visibility self.visible = true -- creating the browser self.browser = createBrowser(self.x,self.y) -- creating a draw function for dx self.draw = function() dxDrawImage(self.x,self.y,self.x+self.w,self.y+self.h,self.browser,0,0,0,tocolor(255,255,255,255),true) end -- inserting it all to a table so we can grab data table.insert(browsers,self) end -- single global event so that we don't keep creating events addEventHandler('onClientBrowserCreated',resourceRoot,function() for i,v in pairs(browsers) do if source == v.browser then -- loading its url after grabbing its data loadBrowserURL(source,v.url) end end end) -- and this is just to put it on the screen.. addEventHandler('onClientRender',resourceRoot,function() for i,v in pairs(browsers) do if v.visible == true then v.draw() end end end) -- so after all that code we can finally create a browser.. local sx,sy = guiGetScreenSize() -- using 0.5 to take literally half the screen.. local newbrowser = dxDrawWebBrowser(sx*0.5,sy*0.5,sx*0.5,sy*0.5,'http://www.google.com/') -- there you go. -- and to change its visibility now just simply do this newbrowser.visible = false -- I hope this helped you. Edited October 22, 2017 by ShayF
Moderators IIYAMA Posted October 22, 2017 Moderators Posted October 22, 2017 1 hour ago, CodX said: Work, but video isn't rendered. Then you post your code, as simple as that...
CodX Posted October 22, 2017 Author Posted October 22, 2017 2 hours ago, ShayF said: try using this Wiki Code: createBrowser Hide contents -- This is an example off of the wiki. I know browsers are a bit complicated. -- https://wiki.multitheftauto.com/wiki/CreateBrowser --In order to render the browser on the full screen, we need to know the dimensions. local sx,sy = guiGetScreenSize() --Let's create a new browser in local mode. We will not be able to load an external URL. local webBrowser = createBrowser(sx,sy,true,false) --This is the function to render the browser. function webBrowserRender() --Render the browser on the full size of the screen. dxDrawImage(0,0,sx,sy,webBrowser,0,0,0,tocolor(255,255,255,255),true) end --The event onClientBrowserCreated will be triggered, after the browser has been initialized. --After this event has been triggered, we will be able to load our URL and start drawing. addEventHandler('onClientBrowserCreated',webBrowser,function() --After the browser has been initialized, we can load our file. loadBrowserURL(webBrowser,'http://mta/local/html/site.html') --Now we can start to render the browser. addEventHandler('onClientRender',root,webBrowserRender) end) My code: Reveal hidden contents -- Create a table of browsers browsers = {} -- Then create a function to create the browser function dxDrawWebBrowser(x,y,w,h,url) -- creating a table for its data local self = {} self.x = x self.y = y self.w = w self.h = h self.url = url -- using a toggle for visibility self.visible = true -- creating the browser self.browser = createBrowser(self.x,self.y) -- creating a draw function for dx self.draw = function() dxDrawImage(self.x,self.y,self.x+self.w,self.y+self.h,self.browser,0,0,0,tocolor(255,255,255,255),true) end -- inserting it all to a table so we can grab data table.insert(browsers,self) end -- single global event so that we don't keep creating events addEventHandler('onClientBrowserCreated',resourceRoot,function() for i,v in pairs(browsers) do if source == v.browser then -- loading its url after grabbing its data loadBrowserURL(source,v.url) end end end) -- and this is just to put it on the screen.. addEventHandler('onClientRender',resourceRoot,function() for i,v in pairs(browsers) do if v.visible == true then v.draw() end end end) -- so after all that code we can finally create a browser.. local sx,sy = guiGetScreenSize() -- using 0.5 to take literally half the screen.. local newbrowser = dxDrawWebBrowser(sx*0.5,sy*0.5,sx*0.5,sy*0.5,'http://www.google.com/') -- there you go. -- and to change its visibility now just simply do this newbrowser.visible = false -- I hope this helped you. Don't work your code. Give me error: ERROR: account\login-panel\client.lua:82: attempt to index local 'newbrowser' (a nil value) 1 hour ago, IIYAMA said: Then you post your code, as simple as that... This is: -- This is an example off of the wiki. I know browsers are a bit complicated. -- https://wiki.multitheftauto.com/wiki/CreateBrowser --In order to render the browser on the full screen, we need to know the dimensions. local sx,sy = guiGetScreenSize() --Let's create a new browser in local mode. We will not be able to load an external URL. local webBrowser = createBrowser(sx,sy,true,false) --This is the function to render the browser. function webBrowserRender() --Render the browser on the full size of the screen. dxDrawImage(0,0,sx,sy,webBrowser,0,0,0,tocolor(255,255,255,255),true) end --The event onClientBrowserCreated will be triggered, after the browser has been initialized. --After this event has been triggered, we will be able to load our URL and start drawing. addEventHandler('onClientBrowserCreated',webBrowser,function() --After the browser has been initialized, we can load our file. loadBrowserURL(webBrowser,'https://www.facebook.com/iulian.macovei.904/videos/1932180010376910/') --Now we can start to render the browser. addEventHandler('onClientRender',root,webBrowserRender) end)
Moderators IIYAMA Posted October 22, 2017 Moderators Posted October 22, 2017 (edited) Did you check if this video is available without being logged in? Afaik, you shouldn't be able to view Facebook video's if you aren't. Edited October 22, 2017 by IIYAMA
ShayF2 Posted October 22, 2017 Posted October 22, 2017 I'll make some code and test it before posting, give me a few hours.
CodX Posted October 23, 2017 Author Posted October 23, 2017 8 hours ago, ShayF said: I'll make some code and test it before posting, give me a few hours. Ok 10 hours ago, IIYAMA said: Did you check if this video is available without being logged in? Afaik, you shouldn't be able to view Facebook video's if you aren't. Yes, work without login. Spoiler
Moderators IIYAMA Posted October 23, 2017 Moderators Posted October 23, 2017 You didn't check the whitelist, pfff local screenWidth, screenHeight = guiGetScreenSize() function webBrowserRender() dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true) end requestBrowserDomains({ "www.facebook.com" }, false) local facebookWasAccepted local webBrowser = createBrowser(screenWidth, screenHeight, false, false) addEventHandler('onClientBrowserCreated',webBrowser, webBrowserCreated) addEventHandler("onClientBrowserWhitelistChange", root, function (newDomains) if not facebookWasAccepted then for i=1, #newDomains do if newDomains[i] == "www.facebook.com" then facebookWasAccepted = true break end end if facebookWasAccepted then loadBrowserURL(webBrowser,'https://www.facebook.com/iulian.macovei.904/videos/1932180010376910/') end end end) function webBrowserCreated () addEventHandler('onClientRender',root,webBrowserRender) if not isBrowserDomainBlocked("www.facebook.com") then loadBrowserURL(webBrowser,'https://www.facebook.com/iulian.macovei.904/videos/1932180010376910/') facebookWasAccepted = true end end
CodX Posted October 27, 2017 Author Posted October 27, 2017 On 10/23/2017 at 19:32, IIYAMA said: You didn't check the whitelist, pfff local screenWidth, screenHeight = guiGetScreenSize() function webBrowserRender() dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true) end requestBrowserDomains({ "www.facebook.com" }, false) local facebookWasAccepted local webBrowser = createBrowser(screenWidth, screenHeight, false, false) addEventHandler('onClientBrowserCreated',webBrowser, webBrowserCreated) addEventHandler("onClientBrowserWhitelistChange", root, function (newDomains) if not facebookWasAccepted then for i=1, #newDomains do if newDomains[i] == "www.facebook.com" then facebookWasAccepted = true break end end if facebookWasAccepted then loadBrowserURL(webBrowser,'https://www.facebook.com/iulian.macovei.904/videos/1932180010376910/') end end end) function webBrowserCreated () addEventHandler('onClientRender',root,webBrowserRender) if not isBrowserDomainBlocked("www.facebook.com") then loadBrowserURL(webBrowser,'https://www.facebook.com/iulian.macovei.904/videos/1932180010376910/') facebookWasAccepted = true end end Don't work. Just sended me a messaje to allow facebook. I allowed that site and then he don't create website. Sorry for my english.
Moderators IIYAMA Posted October 27, 2017 Moderators Posted October 27, 2017 Works for me on localhost. This might solve your issue: (use it when the browser has been created) focusBrowser ( webBrowser ) focusBrowser ( nil )
CodX Posted November 3, 2017 Author Posted November 3, 2017 I don't want to focus because the player can't login. I wan't that video to play in background, like a picture.
Moderators IIYAMA Posted November 4, 2017 Moderators Posted November 4, 2017 (edited) Please read those two lines better. Because at the end it is not focused. Edited November 4, 2017 by IIYAMA
CodX Posted November 4, 2017 Author Posted November 4, 2017 Don't work. local screenWidth, screenHeight = guiGetScreenSize() function webBrowserRender() dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true) end requestBrowserDomains({ "www.facebook.com" }, false) local facebookWasAccepted local webBrowser = createBrowser(screenWidth, screenHeight, false, false) addEventHandler("onClientBrowserCreated", browser, function () focusBrowser(source) end ) addEventHandler('onClientBrowserCreated',webBrowser, webBrowserCreated) addEventHandler("onClientBrowserWhitelistChange", root, function (newDomains) if not facebookWasAccepted then for i=1, #newDomains do if newDomains[i] == "www.facebook.com" then facebookWasAccepted = true break end end if facebookWasAccepted then loadBrowserURL(webBrowser,'https://www.facebook.com/iulian.macovei.904/videos/1932180010376910/') end end end) function webBrowserCreated () addEventHandler('onClientRender',root,webBrowserRender) if not isBrowserDomainBlocked("www.facebook.com") then loadBrowserURL(webBrowser,'https://www.facebook.com/iulian.macovei.904/videos/1932180010376910/') facebookWasAccepted = true end focusBrowser ( webBrowser ) focusBrowser ( nil ) end
Moderators IIYAMA Posted November 4, 2017 Moderators Posted November 4, 2017 If you don't debug your code manually, then you don't work either. Sounds like a great match to me.
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