• What do you need help with? V3
    6,419 replies, posted
  • Avatar of animorten
  • [QUOTE=|Royal|;34682828]Hey, How i get the sound duration of an "mp3" file, because [lua] SoundDuration() [/lua] works only for "wav" files ? best regards, |Royal|[/QUOTE] [url=http://code.google.com/p/animorten/source/browse/trunk/garrysmod/modules/duration/bin/gm_duration.dll]If a binary module is okay[/url]
  • Avatar of Gmod4ever
  • [QUOTE=Gmod4ever;34688995]Well, it's a minor issue, so if it's not really resolvable, it's no big deal. Does anyone know of a way to make the particles draw behind the box, though? The particles are being drawn in the ENT:Draw() code, and is right above the code for the box itself. This is how it looks now: [img]http://dl.dropbox.com/u/8416055/gm_construct0037.jpg[/img] As you can see, the particles are being drawn in front of the box.[/QUOTE] Reposting this, since I would like to know if anyone has any ideas. Thanks.
  • Avatar of JustSoFaded
  • [QUOTE=Gmod4ever;34704632]Reposting this, since I would like to know if anyone has any ideas. Thanks.[/QUOTE] Get rid of that ugly ass material and rounded box in the bottom left hand corner.
  • Avatar of Gmod4ever
  • [QUOTE=JustSoFaded;34704745]Get rid of that ugly ass material and rounded box in the bottom left hand corner.[/QUOTE] Thanks for the constructive feedback. Now how about the actual question?
  • Avatar of lorde banana
  • [QUOTE=Gmod4ever;34704794]Thanks for the constructive feedback. Now how about the actual question?[/QUOTE] Well he's right, the material still looks dumb and the bar just looks bad. Even if it didn't answer your question he was giving you the advice you need to hear.
  • Avatar of ralle105
  • [QUOTE=Gmod4ever;34704632]Reposting this, since I would like to know if anyone has any ideas. Thanks.[/QUOTE] Use the stencil buffer and draw the box first. Unless you want the particles to come out of the box rather than being behind it.
  • [QUOTE=Gmod4ever;34704632]Reposting this, since I would like to know if anyone has any ideas. Thanks.[/QUOTE] You should check if the particle material has ignorez in its vmt code.
  • Avatar of Gmod4ever
  • [QUOTE=ralle105;34708898]Use the stencil buffer and draw the box first. Unless you want the particles to come out of the box rather than being behind it.[/QUOTE] I would like the particles to be coming from inside the box if I can help it, but behind it is still better than in front of it. :v: [editline]15th February 2012[/editline] [QUOTE=SFArial;34709692]You should check if the particle material has ignorez in its vmt code.[/QUOTE] I'll check real fast. [code]"UnlitGeneric" { "$basetexture" "sprites/light_glow02" "$additive" "1" "$translucent" "1" "$vertexcolor" "1" } [/code] Doesn't seem like it. Anything else there that may be causing it?
  • Maybe it's just the way quads are rendered. Or you could try drawing it in another rendering hook.
  • I don't think there's a specific function for that. At least I didn't find it on the wiki. But you could probably do a simple detour. [lua] gui.ScreenClickerEnabled = false local EnableScreenClicker_Old = gui.EnableScreenClicker function gui.EnableScreenClicker( enable ) EnableScreenClicker_Old( enable ) gui.ScreenClickerEnabled = enable end function gui.ScreenClickerEnabled() return gui.ScreenClickerEnabled() end [/lua]
  • Avatar of CapsAdmin
  • [QUOTE=Gmod4ever;34704632]Reposting this, since I would like to know if anyone has any ideas. Thanks.[/QUOTE] For your previous question, even if you figured it out, I advice you to use a matrix and rotate the matrix instead of each face individually. It's cleaner and easier to manage. [lua] local mat = Matrix() mat:SetPos(box_pos) mat:SetAngles(box_ang) mat:Scale(box_scale) cam.PushModelMatrix(mat) *draw box with normals* cam.PopModelMatrix() [/lua] As for the emitter, do this [lua] local emitter = ParticleEmitter(vector_origin) emitter:SetNoDraw(true) function DrawBox(pos) emitter:SetPos(pos) emitter:Draw() *box draw code* end [/lua] would be behind of course [editline]16th February 2012[/editline] [QUOTE=shadowndacorner;34720604]Is there a way to detect if the mouse cursor is enabled?[/QUOTE] boolean vgui.CursorVisible() [editline]16th February 2012[/editline] [QUOTE=Gmod4ever;34711129]I would like the particles to be coming from inside the box if I can help it, but behind it is still better than in front of it. :v: [editline]15th February 2012[/editline] I'll check real fast. [code]"UnlitGeneric" { "$basetexture" "sprites/light_glow02" "$additive" "1" "$translucent" "1" "$vertexcolor" "1" } [/code] Doesn't seem like it. Anything else there that may be causing it?[/QUOTE] in what hook are you drawing it?
  • Avatar of maurits150
  • Is it possible to transmit bytecode (or whatever images use) over console commands? I'm trying to make a system that makes a screenshot using the jpeg command and uploads it to the server, but I'm getting incomplete data on the receiving end. I honesty can't wait for the net libary because concommands are terrible..
  • Avatar of ralle105
  • I tried making concommands handle binary data and trust me, it's not something you want to do. The overhead was like double the size of the actual data and even then it was not finished. I recon it'd have to be something like 5 times the size of the data in overhead for it to work fully. [editline]16th February 2012[/editline] So yeah, wait for the net library.
  • Avatar of CapsAdmin
  • [QUOTE=maurits150;34724735]Is it possible to transmit bytecode (or whatever images use) over console commands? I'm trying to make a system that makes a screenshot using the jpeg command and uploads it to the server, but I'm getting incomplete data on the receiving end. I honesty can't wait for the net libary because concommands are terrible..[/QUOTE] you can use http.Get and store the data in the header, and have a socket on the server which receives it if you don't wanna wait
  • Avatar of Kwaq
  • i havent really made anything in lua before i want to make it so if a player ducks whilst touching the ground its instant if pl:IsOnGround() then self:SetDuckSpeed(0) self:SetUnDuckSpeed(0) else self:SetDuckSpeed(0.4) self:SetUnDuckSpeed(0.3) end what am i doing wrong? its in player_extension on a blank fretta gamemode
  • Avatar of Kwaq
  • oh i just realised im putting it into function meta:OnSpawn() what kind of function do i make so that whenever a player touches the ground that gets called? and is that going to be a really dumb way to do it
  • For some reason I can't wrap my head around as to how to do this. I have a round system that I just finished but I want there to be a timer on the screen to count down the time between each round. I know it's with vgui I can do all that I just don't know how to get it to count down by minutes instead of numbers. I want: 1 : 30 seconds. Instead of 90 seconds. How would I do this? Right now I have a simple timer waiting to start the next round but I need to output the time in mnutes and seconds.
  • Avatar of HighVoltage
  • [QUOTE=BooTs;34735882]For some reason I can't wrap my head around as to how to do this. I have a round system that I just finished but I want there to be a timer on the screen to count down the time between each round. I know it's with vgui I can do all that I just don't know how to get it to count down by minutes instead of numbers. I want: 1 : 30 seconds. Instead of 90 seconds. How would I do this? Right now I have a simple timer waiting to start the next round but I need to output the time in mnutes and seconds.[/QUOTE] Here is basically what I use in my HUD: [lua]--time = the time left in the round local minutes = math.floor(time / 60); if (minutes < 1) then minutes = 0 end local seconds = math.floor(time % 60); if (seconds < 10) then seconds = "0"..seconds end local DisplayTime = minutes.." : "..seconds draw.SimpleTextOutlined(DisplayTime, "HUDNumber5",6, 6, Color(235, 235, 235, 255), 0, 0, 1, Color(25,25,25,255))[/lua]
  • [QUOTE=highvoltage;34736002]Here is basically what I use in my HUD: [lua]--time = the time left in the round local minutes = math.floor(time / 60); if (minutes < 1) then minutes = 0 end local seconds = math.floor(time % 60); if (seconds < 10) then seconds = "0"..seconds end local DisplayTime = minutes.." : "..seconds draw.SimpleTextOutlined(DisplayTime, "HUDNumber5",6, 6, Color(235, 235, 235, 255), 0, 0, 1, Color(25,25,25,255))[/lua][/QUOTE] I will try to work with this, thanks a lot dude.
  • Avatar of Gmod4ever
  • [QUOTE=BooTs;34735882]For some reason I can't wrap my head around as to how to do this. I have a round system that I just finished but I want there to be a timer on the screen to count down the time between each round. I know it's with vgui I can do all that I just don't know how to get it to count down by minutes instead of numbers. I want: 1 : 30 seconds. Instead of 90 seconds. How would I do this? Right now I have a simple timer waiting to start the next round but I need to output the time in mnutes and seconds.[/QUOTE] [lua]string.ToMinutesSeconds(time_in_seconds)[/lua] :v: [editline]17th February 2012[/editline] [QUOTE=CapsAdmin;34721936] As for the emitter, do this [lua] local emitter = ParticleEmitter(vector_origin) emitter:SetNoDraw(true) function DrawBox(pos) emitter:SetPos(pos) emitter:Draw() *box draw code* end [/lua] would be behind of course [editline]16th February 2012[/editline] in what hook are you drawing it?[/QUOTE] Drawing behind would be better than nothing. And the particles are being drawn in the ENT:Draw() hook. I tried setting the entity's render type to translucent and changing the Draw() to DrawTranslucent(), but it didn't really fix matters. The draw order is [code]function ENT:Draw() Particle Box end[/code]
  • Avatar of daranable
  • [QUOTE=BooTs;34735882]For some reason I can't wrap my head around as to how to do this. I have a round system that I just finished but I want there to be a timer on the screen to count down the time between each round. I know it's with vgui I can do all that I just don't know how to get it to count down by minutes instead of numbers. I want: 1 : 30 seconds. Instead of 90 seconds. How would I do this? Right now I have a simple timer waiting to start the next round but I need to output the time in mnutes and seconds.[/QUOTE] Another way to handle this is this: [CODE] output = string.format( "%02d:%02d", math.floor( seconds / 60 ), seconds % 60 ) [/CODE]
  • Avatar of Kogitsune
  • Another alternate: [code]output = os.date( "%M:%S", seconds )[/code] Putting in 90 would yield 1:30, for example.
  • Avatar of Kwaq
  • im trying to make a function where on func_door OnOpen set self (the door that has been opened) alpha 100 and set collision to passable for 5 seconds Basically I'm trying to fix doors in a map so that players can pass through it without getting stuck when it opens (when a player first touches it), then when it closes after 5 seconds it returns to normal state. I know the commands and stuff to do this but I have no idea how to structure that in lua, I tried a few different ways but I guess I just don't get it yet? I'm not sure how I can set the collision type of a door either so any help is greatly appreciated!
  • [QUOTE=brandonj4;34745956]I'm trying to make a round system but have no idea where to start..[/QUOTE] It'd help if you'd use the search... [url]http://www.facepunch.com/threads/1126182[/url] [url]http://www.facepunch.com/threads/1123520[/url] [url]http://www.facepunch.com/threads/1087805[/url] [url]http://www.facepunch.com/threads/1072934[/url]
  • Avatar of Fantym420
  • [QUOTE=brandonj4;34745956]I'm trying to make a round system but have no idea where to start..[/QUOTE] I made a round system that works off custom hooks, maybe this will give you some ideas feel free to use it, it works I used it in my Meteor defense game mode. [lua] -- Gamemode Base Functions -- Rounds -- ======================================================================================== -- Hooks: -- PreRound : This is called every 5 seconds before the round starts (setup for a round) -- Variables : Players (table) , TimeUntilStart (number) -- -- Hook Example: Will print the time till round start for every player. -- hook.Add("PreRound", "myPreRound", function ( plys, time ) for k, v in pairs(plys) do v:ChatPrint("Round Starting in " .. tostring(time)) end ) -- -- RoundStart : This is called once when the timer for the round starts -- Variables : Players -- -- Hook Example: Will print "Round Started!" for every player. -- hook.Add("RoundStart", "myRoundStart", function ( plys ) for k, v in pairs(plys) do v:ChatPrint("Round Started!") end ) -- -- RoundEnd : This is called once as the round ends (timer hits) -- Variables : Players -- -- Hook Example: Will print "Round Finished!" for every player. -- hook.Add("RoundEnd", "myRoundEnd", function ( plys ) for k, v in pairs(plys) do v:ChatPrint("Round Finished!") end ) -- -- PostRound : This is called every 5 seconds after the round has ended ( for score stuff) -- Variables : Players, TimeUntilEnd -- -- Hook Example: Will print the time till PreRound start for every player. -- hook.Add("PreRound", "myPreRound", function ( plys, time ) for k, v in pairs(plys) do v:ChatPrint("Pre Round Will start In " .. tostring(time)) end ) -- Functions: -- * All time is in seconds -- SetPreRoundTime( time ) - Sets the Current Length of the PreRound -- GetPreRoundTime() - Gets the Current Length of the PreRound -- -- SetPreRoundInterval( time) -- Sets the Callback Rate on the PreRound -- GetPreRoundInterval() -- Gets the Callback Rate on the PreRound -- -- SetRoundTime( time ) - Sets the Length of the round (must be set before the Round starts, if set durring the round it will affect the next round) -- GetRoundTime() - Gets the Current Round Length -- -- SetPostRoundTime( time ) - Sets the length of the PostRound -- GetPostRoundTime() - Gets the length of the PostRound -- -- SetPostRoundInterval( time ) - Set the Callback Rate on the PostRound -- GetPostRoundInterval() - Gets the Callback Rate on the PostRound -- -- DidPreOnce() - Returns true if the Current PreRound has been called once -- DidPostOnce() - Return true if the Current PostRound has been called once -- -- StartRound() - forces round to start -- EndRound() - forces end of round -- -- RoundTimeRemaining() - Returns the time left in the round, or -1 if no round is running. -- if !SERVER then return end -- Cleanup incase we are reloading the script if timer.IsTimer("iPreRoundTimer") then timer.Remove("iPreRoundTimer") end if timer.IsTimer("iRoundTimer") then timer.Remove("iRoundTimer") end if timer.IsTimer("iPostRoundTimer") then timer.Remove("iPostRoundTimer") end -- Internal Variables with Default Values iPreRoundTime = 90 iPreRoundInterval = 5 iRoundTime = 120 iRoundStarted = -1 iPostRoundTime = 90 iPostRoundInterval = 5 iPlayers = {} iPreRan = false iPostRan = false -- Exposed Functions function DidPreOnce() return iPreRan end -- Used to Check if it the first PreRound call function DidPostOnce() return iPostRan end -- Used to Check if it's the first PostRound call function RoundPercentComplete() return 1 - (RoundTimeRemaining() / iRoundTime) end -- Returns the percent in decimal form of the round that is completed function RoundPercentCompleteR() return (RoundTimeRemaining() / iRoundTime) end -- Returns the percent in decimal form of the round that is completed -- Force Round Start function StartRound() timer.Remove("iPreRoundTimer") iRoundStart() end -- Force Round End function EndRound() timer.Remove("iRoundTimer") iRoundEnd() end -- Set/Get the length of the PreRound function SetPreRoundTime( time ) if (time >= 0) and !(time == nil) then iPreRoundTime = time end end function GetPreRoundTime() return iPreRoundTime end -- Check Time Remaining in the Round function RoundTimeRemaining() if iRoundStarted == -1 then return 0 end return iRoundTime - (CurTime() - iRoundStarted) end -- Set/Get Pre Round Call Interval function SetPreRoundInterval( time ) if (time >= 0) and !(time == nil) then iPreRoundInterval = time end end function GetPreRoundInterval() return iPreRoundInterval end -- Set/Get Round Time function SetRoundTime( time ) if (time >= 0) and !(time == nil) then iRoundTime = time end end function GetRoundTime() return iRoundTime end -- Set/Get Length of the Post Round. function SetPostRoundTime( time ) if (time >= 0) and !(time == nil) then iPostRoundTime = time end end function GetPostRoundTime() return iPostRoundTime end -- Set/Get PostRound Call Interval function SetPostRoundInterval( time ) if (time >= 0) and !(time == nil) then iPostRoundInterval = time end end function GetPostRoundInterval() return iPostRoundInterval end -- Quick Hooks they keep track of the players playing --hook.Add( "PlayerAuthed", "fanRoundPlayerAuthed", function ( ply, stid, uid ) table.insert( iPlayers, ply ) end ) --hook.Add( "PlayerDisconnected", "fanRoundPlayerDisconnected", function ( ply ) table.remove(iPlayers, IndexFromValue(iPlayers, ply)) end ) -- Internal Functions -- Cleans Bad Entries From the player table function iCleanTable( tbl ) if table.Count(tbl) < 1 then return end for k, v in pairs(tbl) do if !v:IsValid() or (v == nil) or (v == NULL) then table.remove(tbl, k) end end end -- Get an Index from a table by value function IndexFromValue( tbl, value ) for k,v in pairs(tbl) do if v == value then return k end end return nil end function iPreRound( time ) iPostRan = false if time >= iPreRoundTime then time = 0 timer.Remove("iPreRoundTimer") iRoundStart() else iPlayers = player.GetHumans() hook.Call( "PreRound", nil, iPlayers, iPreRoundTime - time) iPreRan = true timer.Remove("iPreRoundTimer") timer.Create("iPreRoundTimer", iPreRoundInterval, 0, iPreRound, time + iPreRoundInterval ) end end function iRoundStart() iPreRan = false iRoundStarted = CurTime() if !timer.IsTimer("iRoundTimer") then timer.Create("iRoundTimer", iRoundTime, 0, iRoundEnd ) end iPlayers = player.GetHumans() hook.Call( "RoundStart", nil, iPlayers ) end function iRoundEnd() iRoundStarted = -1 timer.Remove("iRoundTimer") iPlayers = player.GetHumans() hook.Call( "RoundEnd", nil, iPlayers ) iPostRound( 0 ) end function iPostRound( time ) if time >= iPostRoundTime then time = 0 timer.Stop("iPostRoundTimer") iPreRound( 0 ) else iPlayers = player.GetHumans() hook.Call( "PostRound", nil, iPlayers, iPostRoundTime - time) iPostRan = true timer.Remove("iPostRoundTimer") timer.Create("iPostRoundTimer", iPostRoundInterval, 0, iPostRound, time + iPostRoundInterval) end end -- After Everything is loaded start the round cycle iPreRound( 0 ) [/lua] The code currently assumes that all players in the server are in the round, depending on what you are doing you will need to change the way players are managed.