• What do you need help with? V3
    6,419 replies, posted
[QUOTE=luavirusfree;39649322]So what is the proper console command to use when trying to retrieve the tick rate, and how do I get its value using Lua?[/QUOTE] Can I ask why you need the tick rate? I don't think I can help with your question but I might be able to help with your problem.
[QUOTE=jaooe;39650874]Can I ask why you need the tick rate? I don't think I can help with your question but I might be able to help with your problem.[/QUOTE] The server uptades the game world every 1 x 'tickrates' per seconds. [url]http://game.kingj.net/pages/extra-tickrate[/url]
Not really a coding question, but I think a lot of people here would know the answer to it: What's the command to make your server stop automatically updating your gamemode? I remember it being something like sv_gamemodeupdate or something
[B][U][I]How do I make it so in DarkRP, only certain classes can see the Demote Vote, or at least restrict who can vote?[/I][/U][/B]
How do I edit what items can be bought from the F4 menu depending on what class you are.
Any idea why [url=http://wiki.garrysmod.com/page/Classes/Player/SprintEnable]SprintEnable[/url]/Disable aren't working and/or any workarounds?
[QUOTE=Agent766;39653218]Any idea why [URL="http://wiki.garrysmod.com/page/Classes/Player/SprintEnable"]SprintEnable[/URL]/Disable aren't working and/or any workarounds?[/QUOTE] As a workaroud you can set same speed for both sprint and run.
Im trying to use the render library to draw lines, i used this code: [lua] chat.AddText("Running") pos = LocalPlayer():GetPos() pos1 = pos pos2 = pos + Vector(0,0,80) render.DrawLine(pos1,pos2,Color(255,0,0)) [/lua] Problem's its not doing anything, I expected it to draw a line from my feet to above my head edit: why isnt this working? [lua] chat.AddText(Color(255,0,0),"Running") pos = LocalPlayer():GetPos() pos1 = pos pos2 = pos + Vector(0,0,80) hook.Add("HUDPaint","crashty",function() render.DrawLine(pos1,pos2,Color(255,0,0)) end) [/lua]
[QUOTE=Crashty;39654167]Im trying to use the render library to draw lines, i used this code: [lua] chat.AddText("Running") pos = LocalPlayer():GetPos() pos1 = pos pos2 = pos + Vector(0,0,80) render.DrawLine(pos1,pos2,Color(255,0,0)) [/lua] Problem's its not doing anything, I expected it to draw a line from my feet to above my head[/QUOTE] You can only draw in render hooks like HUDPaint, HUDPaintBackground, Pre/Post*Draw* and in ENT/SWEP:Draw
[QUOTE=jaooe;39650874]Can I ask why you need the tick rate? I don't think I can help with your question but I might be able to help with your problem.[/QUOTE] I know I can set a think rate, but what if I want something to update at every single frame instead of every tenth or 5 hundredths of a second? That's why I want the tick rate. I need something to either get its velocity set, or get moved at that rate until some variables say that you should no longer be able to. I suppose I could just use a variable for the last update time and use the Tick command to update and after I get the time, update the last time to CurTime(). I'd rather have a constant time between fires, but I'd like it to update every time the server updates. [editline]20th February 2013[/editline] [QUOTE=Robertbrownlo;39653160][B][U][I]How do I make it so in DarkRP, only certain classes can see the Demote Vote, or at least restrict who can vote?[/I][/U][/B][/QUOTE] I think you would check to see if the LocalPlayer() has the networked variable that says whether or not you can vote that, OR see if they are admin with [URL="http://wiki.garrysmod.com/page/Classes/Player/IsAdmin"]LocalPlayer():IsAdmin()[/URL] or if they are a [URL="http://wiki.garrysmod.com/page/Classes/Player/IsSuperAdmin"]Super Admin[/URL]. You might also be able to use [URL="http://wiki.garrysmod.com/page/Classes/Player/IsUserGroup"]this[/URL]!
I came up with the idea of making a HTML panel that streams radio. Got that working but now i want to make it so that the streams volume can be changed. I take it you need javascript and use the p.RunJavascript, but the thing is i have no idea about javascript. Anyway the page that streams music is :[url]http://ng.net84.net/radio/Radio.html[/url]. How would i got about creating a clientside command that changes the volume of the stream? Is that possible? Some examples would be most welcome or at least some pointers.
[QUOTE=Crashty;39654167]Im trying to use the render library to draw lines, i used this code: [lua] chat.AddText("Running") pos = LocalPlayer():GetPos() pos1 = pos pos2 = pos + Vector(0,0,80) render.DrawLine(pos1,pos2,Color(255,0,0)) [/lua] Problem's its not doing anything, I expected it to draw a line from my feet to above my head edit: why isnt this working? [lua] chat.AddText(Color(255,0,0),"Running") pos = LocalPlayer():GetPos() pos1 = pos pos2 = pos + Vector(0,0,80) hook.Add("HUDPaint","crashty",function() render.DrawLine(pos1,pos2,Color(255,0,0)) end) [/lua][/QUOTE] You're using a 2D hook, that will make the coordinates relative to screen, so from top left corner. You have to use a 3D hook, "PostDrawOpaqueRenderables" should work
How would I go about changing a shedule on a DModelPanels entity?
So, could anyone tell me how I'd get a variable from the server to the client? This is in shared.lua [lua] // Enemy HitBox // if SERVER then shouldDrawHud = false function DamageTaken( target, dmginfo ) if( target:IsPlayer() == false ) then shouldShowHud = true Msg( target:GetName(), " Took Damage" ) end end hook.Add("EntityTakeDamage", "HitDetection", DamageTaken) end if CLIENT then function Hitbox() if ( shoulderDrawHud ) then // Top line draw.RoundedBox( 0, (ScrW() / 2) - 10, (ScrH() / 2) - 15, 20, 3, Color( 255, 255, 255, 150 ) ) // Bottom line draw.RoundedBox( 0, (ScrW() / 2) - 10, (ScrH() / 2) + 15, 20, 3, Color( 255, 255, 255, 150 ) ) end end hook.Add("HUDPaint", "HUD", Hitbox) end [/lua]
[QUOTE=DoubleElite;39656580]So, could anyone tell me how I'd get a variable from the server to the client? This is in shared.lua [lua] // Enemy HitBox // if SERVER then shouldDrawHud = false function DamageTaken( target, dmginfo ) if( target:IsPlayer() == false ) then shouldShowHud = true Msg( target:GetName(), " Took Damage" ) end end hook.Add("EntityTakeDamage", "HitDetection", DamageTaken) end if CLIENT then function Hitbox() if ( shoulderDrawHud ) then // Top line draw.RoundedBox( 0, (ScrW() / 2) - 10, (ScrH() / 2) - 15, 20, 3, Color( 255, 255, 255, 150 ) ) // Bottom line draw.RoundedBox( 0, (ScrW() / 2) - 10, (ScrH() / 2) + 15, 20, 3, Color( 255, 255, 255, 150 ) ) end end hook.Add("HUDPaint", "HUD", Hitbox) end [/lua][/QUOTE] Are you trying to make a hit marker for when you shoot someone?
[QUOTE=brandonj4;39656717]Are you trying to make a hit marker for when you shoot someone?[/QUOTE] Yeah. But obviously the functionality and such isn't there right now. I'm coming from years of work with Unity, so this isn't something new to me, in fact it should've been really simple. But I'm not used to the way Gmod does it's Server and Client file setup.
How does one control the width of the line drawn with render.DrawLine?
[QUOTE=DoubleElite;39656787]Yeah. But obviously the functionality and such isn't there right now. I'm coming from years of work with Unity, so this isn't something new to me, in fact it should've been really simple. But I'm not used to the way Gmod does it's Server and Client file setup.[/QUOTE] PMed you about it.
Okay so I made a custom HUD as part of my "Learning Lua By Messing With DarkRP" project. This is the job box. Simple. : [IMG]http://puu.sh/25H7I[/IMG] How can I make the shaded box resize to fit the number of letters. Here is the code that sets it up: [lua] draw.RoundedBox( 6, midx - 64, hudypos2, (hudwidth + 60) / 2, hudheight / 2, Color( 50, 50, 50, 120 ) ) draw.SimpleText( ": " .. (LocalPlayer().DarkRPVars.job or ""), "HUDMainTwo", //midx - (hudwidth / 4), hudypos + 30, midx - 44, hudypos2 + 3, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT ) surface.SetDrawColor(255,255,255,255) surface.SetTexture(usersuit) surface.DrawTexturedRect(midx - 61,hudypos2 + 3,16,16) [/lua] The set up integers are: [code] local hudwidth = 256 local hudheight = 48 local sleft = 1 local sright = ScrW() - 1 local hudypos = ScrH() - hudheight local hudypos2 = ScrH() - (hudheight / 2) local midx = ScrW() / 2 [/code]
[QUOTE=thejjokerr;39657601]Use surface.GetTextSize to get the width and height of the text beforehand, after that draw the rounded box with that information.[/QUOTE] Don't forget, before the surface.GetTextSize you need to do surface.SetFont, to set the font so it knows how big the text is. [QUOTE=DoubleElite;39656580]So, could anyone tell me how I'd get a variable from the server to the client? This is in shared.lua [lua] // Enemy HitBox // if SERVER then shouldDrawHud = false function DamageTaken( target, dmginfo ) if( target:IsPlayer() == false ) then shouldShowHud = true Msg( target:GetName(), " Took Damage" ) end end hook.Add("EntityTakeDamage", "HitDetection", DamageTaken) end if CLIENT then function Hitbox() if ( shoulderDrawHud ) then // Top line draw.RoundedBox( 0, (ScrW() / 2) - 10, (ScrH() / 2) - 15, 20, 3, Color( 255, 255, 255, 150 ) ) // Bottom line draw.RoundedBox( 0, (ScrW() / 2) - 10, (ScrH() / 2) + 15, 20, 3, Color( 255, 255, 255, 150 ) ) end end hook.Add("HUDPaint", "HUD", Hitbox) end [/lua][/QUOTE] Use net messages or umsg. Net is probably better, but you have to do util.AddNetworkString( "NetMsg" ) server side every time you make a net. To send a net message you can do... [lua] -- Server side: net.Start( "NetMsg" ) -- Start the net message. net.WriteFloat( 1 ) -- Our variable we're syncing. net.Send( ply ) -- Send it to our player. -- Client side: net.Receive( "NetMsg", function() LocalPlayer().MyVariable = net.ReadFloat() end) [/lua] And because net is so awesome, you can even send from client side to server side by doing this (You still need to do the util.AddNetworkString though)... [lua] -- Server side. net.Receive( "NetMsg", function() -- Code here. end) -- Client side. net.Start( "NetMsg" ) net.WriteString( "I'm writing something to send to the server!" ) net.SendToServer() [/lua]
What is the work around for this in TTT? [code]ERROR: Trying to derive entity ttt_melon from non existant entity base_gmodentity! [/code] I have tried removing the ENT.Base line, changing it to ttt_c4, setting it to "" and nil but still nothing. Any help?
Uh, I struck onto a weird ass error with my http.Fetch.. [lua] local banCache = {} function getBans(callb) http.Fetch("http://www.globalartsgaming.org/apocrpg.php?a=banlist", function onSuccess(str,length,headers,httpcode) str = string.Trim(str) banCache = {} if string.find(str,"|") then local t = string.Explode("|",str) for k,v in pairs(t) do local tbl = string.Explode("/",v) if tbl[1] && tbl[2] then local name = tbl[1] local steamid = tbl[2] table.insert(banCache,{name,steamid}) end end else local tbl = string.Explode("/",str) if tbl[1] && tbl[2] then local name = tbl[1] local steamid = tbl[2] table.insert(banCache,{name,steamid}) end end if callb then callb() end, function onFailure(ERR) print("Something went wrong!") print("ErrCode: "..ERR) end ) end getBans() [/lua] '(' expected near 'onSuccess' Any ideas?
Do [lua] http.Fetch("http://www.globalartsgaming.org/apocrpg.php?a=banlist", function(str,length,headers,httpcode)[/lua]
unexpected symbol near ','
You are creating a function inside of http.fetch instead of returning one, try removing onSuccess and onFailure and just leave the ()s. (sorry ninja'd)
Made a function outside of the fetch, that worked.. Thanks tho.
[QUOTE=Charrax;39657564]Okay so I made a custom HUD as part of my "Learning Lua By Messing With DarkRP" project. This is the job box. Simple. : [IMG]http://puu.sh/25H7I[/IMG] How can I make the shaded box resize to fit the number of letters. Here is the code that sets it up: The set up integers are: [code] local hudwidth = 256 local hudheight = 48 local sleft = 1 local sright = ScrW() - 1 local hudypos = ScrH() - hudheight local hudypos2 = ScrH() - (hudheight / 2) local midx = ScrW() / 2 [/code][/QUOTE] You can get the width and length of a text by using [lua] surface.SetFont( "HUDMainTwo" ) local w,h = surface.GetTextSize( "MyText" ) [/lua] You have to set which font to use before, else it might not return any values or return the wrong ones. [editline]20th February 2013[/editline] [QUOTE=Science;39658244]What is the work around for this in TTT? [code]ERROR: Trying to derive entity ttt_melon from non existant entity base_gmodentity! [/code] I have tried removing the ENT.Base line, changing it to ttt_c4, setting it to "" and nil but still nothing. Any help?[/QUOTE] Post your code.
[QUOTE=CrashLemon;39658722] Post your code.[/QUOTE] [lua]ENT.Type = "anim" ENT.Base = "base_gmodentity" ENT.PrintName = "Melon" ENT.Author = "AScience" ENT.Contact = "" ENT.Purpose = "" ENT.Instructions = "" function ENT:SpawnFunction( ply, tr, ClassName ) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 16 local ent = ents.Create( ClassName ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() return ent end [/lua]
[QUOTE=Science;39659069][lua]ENT.Type = "anim" ENT.Base = "base_gmodentity" ENT.PrintName = "Melon" ENT.Author = "AScience" ENT.Contact = "" ENT.Purpose = "" ENT.Instructions = "" function ENT:SpawnFunction( ply, tr, ClassName ) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 16 local ent = ents.Create( ClassName ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() return ent end [/lua][/QUOTE] [lua] ENT.Type = "anim" ENT.Base = "base_anim"[/lua]
[QUOTE=CrashLemon;39659219][lua] ENT.Type = "anim" ENT.Base = "base_anim"[/lua][/QUOTE]Thanks
Sorry, you need to Log In to post a reply to this thread.