• Cutscenes
    31 replies, posted
Does anybody know how to create a "cutscene" (im pretty sure that's not what they are called in gmod terms) like when you join an openAura server and you get the little cutscene at the start. Any help would be appreciated.
[b][url=wiki.garrysmod.com/?title=Gamemode.CalcView]Gamemode.CalcView [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] [b][url=wiki.garrysmod.com/?title=Gamemode.HUDShouldDraw]Gamemode.HUDShouldDraw [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] These 2 hooks should be enough for you. Just attach a variable to the player on their first spawn. Then use the CalcView hook to swerve the camera everywhere, as well as the HUDShouldDraw hook to hide the HUD. Do this only when the variable is true, after the cut scene is over set the variable back to false.
Ok, is there any way to play a video when the spawn (I know its a long shot) Also - 200th post (:D)
[lua] -- serverside st00f hook.Add("PlayerInitialSpawn", "VideoOnSpawn", function(ply) umsg.Start("YourVideo", ply) umsg.End() end) usermessage.Hook("YourVideo", function() -- clientside st00f end) [/lua]
Is the video one you record or one that is map based? Should there be players in the video that are currently on the server?
[QUOTE=zzaacckk;32945506]Is the video one you record or one that is map based? Should there be players in the video that are currently on the server?[/QUOTE] It should be one that is pre-recorded (Like a kinda, intro to the gamemode/server). [editline]24th October 2011[/editline] [QUOTE=Bloodwave;32944927][lua] -- serverside st00f hook.Add("PlayerInitialSpawn", "VideoOnSpawn", function(ply) umsg.Start("YourVideo", ply) umsg.End() end) usermessage.Hook("YourVideo", function() -- clientside st00f end) [/lua][/QUOTE] What formats does that support?
[QUOTE=Dorkslayz;32945971]It should be one that is pre-recorded (Like a kinda, intro to the gamemode/server). [editline]24th October 2011[/editline] What formats does that support?[/QUOTE] None. Its alot of [url]http://luasearch.overvprojects.nl/?keywords=timer.Create[/url] And [url]http://luasearch.overvprojects.nl/?keywords=surface[/url]
The best if not only way to do it would be to upload it to be a youtube video and then play it, can you upload it and give us the link please.
[QUOTE=zzaacckk;32948779]The best if not only way to do it would be to upload it to be a youtube video and then play it, can you upload it and give us the link please.[/QUOTE] what about the 3596 Ads there? what if a player joins and he sees an ad and he is like WHAT THE FUCK IS THIS and then disconnect.
Im working on a video and ill upload it as soon as its done.
Ok, ive got an "intro" ready. [url]http://www.youtube.com/watch?v=guXjvn4rmFU[/url] (I only spent 20 minutes or so on it, its temporary.)
You can always use a HTML5 video. Just make a HTML panel, surround it with fancy borders and shit. Then do something like: [code] pnl:SetHTML([[ <video poster="star.png" autoplay="autoplay" loop="loop" controls="controls" tabindex="0"> <source src="movie.webm" type='video/webm; codecs="vp8, vorbis"' /> <source src="movie.ogv" type='video/ogg; codecs="theora, vorbis"' /> </video> ]]) [/code]
[QUOTE=GARRYMODE;32960295]You can always use a HTML5 video. Just make a HTML panel, surround it with fancy borders and shit. Then do something like: [code] pnl:SetHTML([[ <video poster="star.png" autoplay="autoplay" loop="loop" controls="controls" tabindex="0"> <source src="movie.webm" type='video/webm; codecs="vp8, vorbis"' /> <source src="movie.ogv" type='video/ogg; codecs="theora, vorbis"' /> </video> ]]) [/code][/QUOTE] How are you going to send the video to the client? [editline]25th October 2011[/editline] I guess if it was on an external source it would work.
Is there any way to run it from the HUD?
Here: [lua] if SERVER then hook.Add("PlayerInitialSpawn", "VideoOnSpawn", function(ply) umsg.Start("YourVideo", ply) umsg.End() end) elseif CLIENT then usermessage.Hook("YourVideo", function() local pnl = vgui.Create ("HTML") pnl:SetSize(ScrW() / 2, ScrH() / 2) pnl:SetPos(ScrW() / 4, ScrH() / 4) pnl:SetHTML([[ <video poster="star.png" autoplay="autoplay" loop="loop" controls="controls" tabindex="0"> <source src="movie.webm" type='video/webm; codecs="vp8, vorbis"' /> <source src="movie.ogv" type='video/ogg; codecs="theora, vorbis"' /> </video> ]]) end) end [/lua]
[QUOTE=GARRYMODE;32960721]Here: [lua] if SERVER then hook.Add("PlayerInitialSpawn", "VideoOnSpawn", function(ply) umsg.Start("YourVideo", ply) umsg.End() end) elseif CLIENT then usermessage.Hook("YourVideo", function() local pnl = vgui.Create ("HTML") pnl:SetSize(ScrW() / 2, ScrH() / 2) pnl:SetPos(ScrW() / 4, ScrH() / 4) pnl:SetHTML([[ <video poster="star.png" autoplay="autoplay" loop="loop" controls="controls" tabindex="0"> <source src="movie.webm" type='video/webm; codecs="vp8, vorbis"' /> <source src="movie.ogv" type='video/ogg; codecs="theora, vorbis"' /> </video> ]]) end) end [/lua][/QUOTE] Im guessing that I replace "YourVideo" with the video url? (Does it work for youtube, im guessing not) and where does that go?
No, read the code and try again.
[QUOTE=GARRYMODE;32961491]No, read the code and try again.[/QUOTE] Do I replace movie.webm/movie.ogv?
Good job.
[QUOTE=GARRYMODE;32961604]Good job.[/QUOTE] Do I have to do both or can I choose which one I do?
[QUOTE=Dorkslayz;32961646]Do I have to do both or can I choose which one I do?[/QUOTE] You can probably get rid of one. Which ever webkit supports will work.
[QUOTE=GARRYMODE;32961673]You can probably get rid of one. Which ever webkit supports will work.[/QUOTE] and where do I place this? (init, cl_init or shared)
Okay stop with all the html video playing bs, this can EASILY be done with lua and hudpaint. You don't need a video to do this, take a look at how I did my introduction, this is definitely [b]not[/b] the best method of doing this, but it works perfectly. [code] cSleak.Introduction = { } cSleak.Introduction.Stages = { } cSleak.Introduction.Enabled = false; cSleak.Introduction.CurrentStage = 0 cSleak.Introduction.FadeMultiplier = 0.5 TEXT = "" X = 0 Y = 0 COLOR = 0 ALPHA = 0; STATUS = "" function cSleak.Introduction:newStage( text, x, y, color, onFrame) table.insert( self.Stages, { text, x, y, color, onFrame } ); end function cSleak.Introduction:begin() if ( self.Enabled ) then return end print("Introduction begun.") self.Enabled = true; self:nextStage(); end function cSleak.Introduction:genericFade() if ( STATUS == "fadingOut" ) then return 255 end ALPHA = ALPHA + cSleak.Introduction.FadeMultiplier if ( ALPHA > 255 ) then ALPHA = 0 end return ALPHA end function cSleak.Introduction:genericAlphaExit() ALPHA = ALPHA - cSleak.Introduction.FadeMultiplier if ( ALPHA < 0 ) then ALPHA = 0 end return ALPHA end function cSleak.Introduction:setFadeMultiplier( int ) if ( int > 0 ) then self.FadeMultiplier = int end end function cSleak.Introduction:genericSlide( axis, multiplier ) if ( string.lower(axis) == "x" ) then X = X + multiplier return X elseif( string.lower(axis) == "y" ) then Y = Y + multiplier return Y end end function cSleak.Introduction:complete() print( "Introduction completed!"); end function cSleak.Introduction:nextStage() if ( !self.Enabled ) then return end local predictedStage = self.CurrentStage + 1 if ( predictedStage > table.maxn( self.Stages ) ) then self.Enabled = false; self:complete(); return; end if ( self.Stages[ predictedStage ] ) then self.CurrentStage = self.CurrentStage + 1 TEXT = self.Stages[ self.CurrentStage ][1] X = self.Stages[ self.CurrentStage ][2] Y = self.Stages[ self.CurrentStage ][3] COLOR = self.Stages[ self.CurrentStage ][4] PrintTable( { TEXT, X, Y, COLOR } ); end end function cSleak.Introduction:setStatus( status ) if ( !status ) then return end STATUS = status end function cSleak.Introduction:delayStage( delay ) self:setStatus("hold"); timer.Simple( delay, function() ALPHA = 0; self:setStatus("pendingNext"); self:nextStage(); end); end cSleak.Introduction:newStage( "Welcome, to <city name>, <phrase>", -50, -50, { 255, 0, 0 }, function() if ( STATUS == "hold" ) then return end local alpha; if ( ALPHA < 255 ) then alpha = cSleak.Introduction:genericFade(); end if ( alpha == 30 ) then print("Alpha was at 30."); end if ( alpha == 255 ) then cSleak.Introduction:setStatus( "fadingOut" ); local exit = cSleak.Introduction:genericAlphaExit(); if ( exit <= 0 ) then cSleak.Introduction:delayStage( 2 ); end end end) cSleak.Introduction:newStage( "Made by lauScript...", 5, 5, { 255, 255, 255 }, function() if ( STATUS == "hold" ) then return end local alpha; if ( ALPHA < 255 ) then alpha = cSleak.Introduction:genericFade(); end if ( alpha == 30 ) then print("Alpha was at 30."); end if ( alpha == 255 ) then cSleak.Introduction:setStatus( "fadingOut" ); local exit = cSleak.Introduction:genericAlphaExit(); if ( exit <= 0 ) then cSleak.Introduction:delayStage( 1.5 ); end end end) cSleak.Introduction:newStage( "Roleplaying is fucking gay and smells like moose.", 5, 5, { 255, 255, 255 }, function() if ( STATUS == "hold" ) then return end local alpha; if ( ALPHA < 255 ) then alpha = cSleak.Introduction:genericFade(); end if ( alpha == 30 ) then print("Alpha was at 30."); end if ( alpha == 255 ) then cSleak.Introduction:setStatus( "fadingOut" ); local exit = cSleak.Introduction:genericAlphaExit(); if ( exit <= 0 ) then cSleak.Introduction:delayStage( 2 ); end end end) surface.CreateFont( "DefaultLarge", ScreenScale(20), 400, true, true, "IntroTextFont" ); function GM:HUDPaint() if ( cSleak.Introduction.Enabled ) then cSleak.Introduction.Stages[ cSleak.Introduction.CurrentStage ][5](); draw.DrawText( TEXT, "IntroTextFont", ScrW() / 2 + X, ScrH() / 2 + Y, Color( COLOR[1], COLOR[2], COLOR[3], ALPHA ) ,TEXT_ALIGN_CENTER) end end [/code]
Too bad if you read you would notice that he wants a video made by him done. One sec I will write you a mockup.
[QUOTE=zzaacckk;32967133]Too bad if you read you would notice that he wants a video made by him done. One sec I will write you a mockup.[/QUOTE] I know but after reading that one thing, If he just wants to do fading text, he can use what i posted to do that. I know he wants a video and I know the video he posted isn't what he's going to use, but I posted the text code if he happens to change his mind and only want to do text.
[QUOTE=LauScript;32967289]I know but after reading that one thing, If he just wants to do fading text, he can use what i posted to do that. I know he wants a video and I know the video he posted isn't what he's going to use, but I posted the text code if he happens to change his mind and only want to do text.[/QUOTE] Ah. Also OP you can use something similar to this to display the movie.. [lua] local pnl2 = vgui.Create("HTML") pnl2:SetSize(ScrW()+100,ScrH()+100) pnl2:SetPos(0,0) pnl2:SetHTML(string.format([[ <iframe width=%q height=%q src="http://www.youtube.com/embed/guXjvn4rmFU" frameborder="0" allowfullscreen></iframe> ]],ScrW(),ScrH())); [/lua]
To be honest. I doubt the OP has any knowledge of scripting; as simple variables confuse him. Heck, he doesn't even know about Lua states. I doubt he's going to be able to know what to do with the block of code you pasted LauScript.
[QUOTE=zzaacckk;32948779]The best if not only way to do it would be to upload it to be a youtube video and then play it, can you upload it and give us the link please.[/QUOTE] Hosting the content on a local server and displaying it with an HTML element would be the best way Using YouTube would be a bad idea, just host the content locally
Unless he has a dedi he will need an external web server to do that, and he wouldn't be able to index it on the GMod server so there isn't much he can do. [editline]26th October 2011[/editline] AFAIK
I think ill go with LauScript's kind of, idea with the text. Now all I gotta do is create a script for it.
Sorry, you need to Log In to post a reply to this thread.