• What do you need help with? V3
    6,419 replies, posted
I own my own Garry's Mod 13 TTT server, and I seem to be running into the obvious problem of RDM. Again, I know this is going to happen, but it pisses me off a little. I'm looking for a ULX command to respawn people. Actually, I have one for Garry's Mod 12: [code]function ulx.cc_respawn( ply, command, argv, args ) if #argv < 1 then ULib.tsay( ply, ulx.LOW_ARGS, true ) return end local targets, err = ULib.getUsers( argv[ 1 ], _, true, ply ) -- Enable keywords if not targets then ULib.tsay( ply, err, true ) return end for _, v in ipairs( targets ) do ulx.logUserAct( ply, v, "#A respawned #T" ) v:SpawnForRound(true) end end ulx.concommand( "respawn", ulx.cc_respawn, "<user(s)> - Respawns target(s).", ULib.ACCESS_ADMIN, "!respawn", _, ulx.ID_PLAYER_HELP ) ulx.addToMenu( ulx.ID_MCLIENT, "Respawn", "ulx respawn" )[/code] It would be great if this code was compatible with Garry's Mod 13, but of course it's not. Could anyone help me out? NOTE: I did not create this code. I used Google, found this, didn't work; looked for a GMod 13 one, couldn't find one. I know the location of it is garrysmod\addons\ulx\lua\ulx\modules\sh then make a new lua called TTT or something of the sort and BAM I have a new ULX section of commands. EDIT: These are less important, but I also have a force traitor, detective, and innocent commands. They all cause errors in the same way as the respawn commands. If you feel so inclined...... [code]function ulx.cc_traitor( ply, command, argv, args ) if #argv < 1 then ULib.tsay( ply, ulx.LOW_ARGS, true ) return end local targets, err = ULib.getUsers( argv[ 1 ], _, true, ply ) -- Enable keywords if not targets then ULib.tsay( ply, err, true ) return end for _, v in ipairs( targets ) do ulx.logUserAct( ply, v, "#A turned #T into a traitor" ) v:SetRole(ROLE_TRAITOR) SendFullStateUpdate() end end ulx.concommand( "traitor", ulx.cc_traitor, "<user(s)> - Turns target(s) into traitors.", ULib.ACCESS_ADMIN, "!traitor", _, ulx.ID_PLAYER_HELP ) ulx.addToMenu( ulx.ID_MCLIENT, "Traitor", "ulx traitor" ) function ulx.cc_detective( ply, command, argv, args ) if #argv < 1 then ULib.tsay( ply, ulx.LOW_ARGS, true ) return end local targets, err = ULib.getUsers( argv[ 1 ], _, true, ply ) -- Enable keywords if not targets then ULib.tsay( ply, err, true ) return end for _, v in ipairs( targets ) do ulx.logUserAct( ply, v, "#A turned #T into a detective" ) v:SetRole(ROLE_DETECTIVE) SendFullStateUpdate() end end ulx.concommand( "detective", ulx.cc_detective, "<user(s)> - Turns target(s) into detectives.", ULib.ACCESS_ADMIN, "!detective", _, ulx.ID_PLAYER_HELP ) ulx.addToMenu( ulx.ID_MCLIENT, "Detective", "ulx detective" ) function ulx.cc_innocent( ply, command, argv, args ) if #argv < 1 then ULib.tsay( ply, ulx.LOW_ARGS, true ) return end local targets, err = ULib.getUsers( argv[ 1 ], _, true, ply ) -- Enable keywords if not targets then ULib.tsay( ply, err, true ) return end for _, v in ipairs( targets ) do ulx.logUserAct( ply, v, "#A turned #T into an innocent" ) v:SetRole(ROLE_INNOCENT) SendFullStateUpdate() end end ulx.concommand( "innocent", ulx.cc_innocent, "<user(s)> - Turns target(s) into innocents.", ULib.ACCESS_ADMIN, "!innocent", _, ulx.ID_PLAYER_HELP ) ulx.addToMenu( ulx.ID_MCLIENT, "Innocent", "ulx innocent" )[/code]
Hi There's this DPanel that's been annoying me for awhile now, so I thought I'd try posting here. I'm trying to replicate some of the functionality from the Sandbox context menu, I've read through that sandbox code, but it's still very confusing as to why this doesn't work. I have an EditablePanel that's stretched across the screen ( Width is ScrW() and height is ScrH() ) to open it, I run [lua]CloseDermaMenus() CreateContextScreen() InteractMenu:MakePopup() InteractMenu:SetVisible(true) InteractMenu:SetKeyboardInputEnabled(false) InteractMenu:SetMouseInputEnabled(true) RestoreCursorPosition() [/lua] and to close it: [lua] RememberCursorPosition() CloseDermaMenus() InteractMenu:SetKeyboardInputEnabled(false) InteractMenu:SetMouseInputEnabled(false) InteractMenu:SetVisible(false) [/lua] During the creation of the panel I run SetWorldClicker(true) on it so when it's active, you're able to right click on world-entities. Part of the problem is, what I want to happen is, in the game when you get a trade request, a little notification pops up in the corner and alerts you to open this context menu to either accept or decline the trade, this is so it doesn't annoy you if you're in the middle of something. The accept and decline buttons are a child of a DPanel which is a child of InteractMenu, an EditablePanel. The problem is, when I open the InteractMenu and the trade request window is there, it doesn't accept mouse input, even though I've ran InteractMenu:SetMouseInputEnabled(true) on it's parent. I'm not quite sure what's causing this, it's weirder even when sometimes it actually does seem to accept mouse input but -only- for the first trade request, and no others.
Hey I am trying to convert this to use in Gmod 13. [URL]http://www.garrysmod.org/downloads/?a=view&id=107384[/URL] I did the change of renaming info.txt into addon.txt and it seems to have lua errors, as to be expected. The props still work and seem to still stick together as intended, except for a jeep seat that shows up. [CODE][ERROR] addons/odst_drop_pod/lua/entities/odst_drop_pod/init.lua:34: bad argument #2 to '__add' (Angle expected, got userdata) 1. __add - [C]:-1 2. unknown - addons/odst_drop_pod/lua/entities/odst_drop_pod/init.lua:34 3. Spawn - [C]:-1 4. unknown - ...ns/odst_drop_pod/lua/entities/odst_pod_launcher/init.lua:64 [/CODE] Is what I get and I don't know a single thing on lua coding so I was wondering if you guys could help me. MY theory is that gmod 13 changed some seating code or something causing the jeep seat to show up instead of placing the seat in the pod itself. But again I don't know much.
I'm new to LUA, and the problem I'm having is not knowing where to put things (tutorials don't give you directories). I run a TTT server.. where do I put the code for connecting to a MySQL Database and querying it?
Hey guys, some people posted about this many pages back and it was never answered. I'm having problems getting the HTML function FinishedURL to call properly. [CODE] local HTMLTest = vgui.Create("HTML", DP) HTMLTest:SetPos(50,50) HTMLTest:SetSize(ScrW() - 200, ScrH() - 300) HTMLTest:OpenURL("http://www.google.com/") function HTMLTest:FinishedURL(url) print(url) end [/CODE] Nothing prints to the console regardless of how many pages I load. Anyone know the issue?
[QUOTE=DarthTealc;38546388]Is it possible to display .vtf images (inside a DImage element) when they don't have a corresponding .vmt? I'm trying to display "temp/2edebb34.vtf" but it gives the black/pink error checkerboard. However when I give it a vmt it displays fine.[/QUOTE] I *think* you can sort of replicate the .vmt in Lua, something to do with the IMaterial object iirc
[QUOTE=`impulse;38544755] It's probably being resized because it's an odd resolution - all images that you want to use have to have a width and height that are powers of two.[/QUOTE] Great! ill try this, thanks for the response, `impulse!
Quick and simple question. I'm not entirely sure the proper way to do this but my question is, I am looping through a tables in tables using pairs() but how can I prevent it from throwing an error when it hits things like userdata?
[QUOTE=Kidd;38550420]Quick and simple question. I'm not entirely sure the proper way to do this but my question is, I am looping through a tables in tables using pairs() but how can I prevent it from throwing an error when it hits things like userdata?[/QUOTE] Just make sure it's a table before you use pairs. Hint: [sp]Use if type(t) == "table" then ... [/sp]
[QUOTE=Darkwater124;38550452]Just make sure it's a table before you use pairs. Hint: [sp]Use if type(t) == "table" then ... [/sp][/QUOTE] Yeah. I wasn't thinking and knew this. Now I just feel stupid asking. Thanks though.
I get the following error: [lua] Timer Failed! [Simple][@addons/cauztik's simple chatbox/lua/cauztik_chatbox/vgui/cauztik_chatbox_panels.lua (line 138)] [/lua] Here's the code: [lua] function TEXT_ENTRY_PANEL:OnKeyCodeTyped( code ) local chatbox = self:GetParent() local text = self:GetValue() if code == KEY_ENTER then if string.Trim(text) != "" then local match = string.match(text, "^!%s*(.+)$") if match then match = CP.SplitArgs( match ) if CP.GetCommand(match[1]) then RunConsoleCommand( "CP", unpack(match) ) end end if chatbox.TeamChat then RunConsoleCommand("say_team", text) else RunConsoleCommand("say", text) end end chatbox:Close() elseif code == KEY_ESCAPE then chatbox:Close() timer.Simple(0, RunConsoleCommand, "cancelselect") - - - Error on this line end [/lua] I appreciate all help; Thanks in advance.
[QUOTE=Apozen;38551316]I get the following error: [lua] Timer Failed! [Simple][@addons/cauztik's simple chatbox/lua/cauztik_chatbox/vgui/cauztik_chatbox_panels.lua (line 138)] [/lua] Here's the code: [lua] function TEXT_ENTRY_PANEL:OnKeyCodeTyped( code ) local chatbox = self:GetParent() local text = self:GetValue() if code == KEY_ENTER then if string.Trim(text) != "" then local match = string.match(text, "^!%s*(.+)$") if match then match = CP.SplitArgs( match ) if CP.GetCommand(match[1]) then RunConsoleCommand( "CP", unpack(match) ) end end if chatbox.TeamChat then RunConsoleCommand("say_team", text) else RunConsoleCommand("say", text) end end chatbox:Close() elseif code == KEY_ESCAPE then chatbox:Close() timer.Simple(0, RunConsoleCommand, "cancelselect") - - - Error on this line end [/lua] I appreciate all help; Thanks in advance.[/QUOTE] change to [lua] timer.Simple(0, function() RunConsoleCommand("cancelselect") end) [/lua]
I didn't get an answer before so I'll try again: [QUOTE=Martti010;38544374]When I save my GMod Lua file that is running in-game a few times, the game crashes. It's tedious to reconnect every time I need to test the code. Does anyone know how to fix this?[/QUOTE] I tried to fix it by disabling add-ons (also unloaded everything from addons folder) and configs. Nothing worked :suicide: recently before that didn't happen, I did put model quality to low, color correction off, maybe something else I can't remember. Although this is nonsensical, can this cause the problem? I also tried to search from a lot of places for a solution. Please help!
How many 3D2D planes should be able to be drawn while not causing lag on the average gaming PC? [editline]22nd November 2012[/editline] Also, how do I check if someone has godmode? (With :GodEnable()) [editline]22nd November 2012[/editline] And is there a quick way to convert any var to a string for debugging?
[QUOTE=Ghor;38546374]I think what you are trying to do is beyond the bounds of clientside Lua alone. In Source, the client is only informed of the existence of entities when the server decides it is appropriate; this is usually only when the player and the entity enter a region of the map where they could potentially see one another. You can transmit this kind of information to the client with serverside code, but you would need to write it and then have the server owner install it on the server. You were able to do what you did in E2 because E2's server code did most of that work. Clientside Lua is very limited. [/QUOTE] I had the fear that would be the case. However if I would call the OnPlayerChat on a Serverside Script would that trigger for every Player chat command (also hidden onesl ike DarkRP or E2-Hidden ones with "hideChat(1)")? Or are there Other hooks for this kind of event ? Also how do I make this information accessible for a client script ? would that be like creating my own hook ? and furthermore how do i keep other players from using this as I only want Amdinstrators or Mods to be able to do it ?
So I have 2 dumb questions. First one, are DTVars networked (will Entity:SetDTBlah set the DTVar type on the client too, without needing to be force with a net message). Second one, how can I draw a PNG image? [QUOTE=Darkwater124;38551673]How many 3D2D planes should be able to be drawn while not causing lag on the average gaming PC? [editline]22nd November 2012[/editline] Also, how do I check if someone has godmode? (With :GodEnable()) [editline]22nd November 2012[/editline] And is there a quick way to convert any var to a string for debugging?[/QUOTE] Well I have drawn up to 5 without any FPS drop, my PC sucks ass though.
Hello all, I have a rather simple problem today: [lua] function ENT:Draw() self:DrawModel() local FixAngles = self:GetAngles() local FixRotation = Vector(0, 270, 0) FixAngles:RotateAroundAxis(FixAngles:Right(), FixRotation.x) FixAngles:RotateAroundAxis(FixAngles:Up(), FixRotation.y) FixAngles:RotateAroundAxis(FixAngles:Forward(), FixRotation.z) local TargetPos = self:GetPos() + (self:GetUp() * 9) local _,_,_,a = self:GetColor() if self.DrawText then cam.Start3D2D(TargetPos, FixAngles, 0.15) draw.SimpleText(">_<", "HUDNumber5", TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, Color(255,0,0,a),1,1) cam.End3D2D() end end [/lua] It's not displaying the ">_<" on the entity. HUDNumber5 isn't a real font anymore, but if I add: [lua] if CLIENT then surface.CreateFont("HUDNumber5", {font="Trebuchet MS", size=45, weight=900}) [/lua] Then it just messes up the entire entity, causing it to error out. All help is appreciated, thanks.
is their anyway to make this: [QUOTE] Jumping aboard this skypaint train with some ~creepy~ and ~realistic~ halloweeny fog. It was a bit of a kerfuffle to get it working on downtown, but this seems to do the trick [IMG]http://i.imgur.com/g9gqM.jpg[/IMG] hook.Add("Initialize", "skypaaaint", function() env_skypaint = ents.Create('env_skypaint') env_skypaint:Spawn(); env_skypaint:Activate(); game.ConsoleCommand("sv_skyname painted\n"); fog = ents.Create('env_fog_controller'); fog:Spawn(); fog:Activate(); end) [/QUOTE] into something with snow?
Does anyone know of any documentation/examples of adding creation tabs to the Q-Menu?
I need to hard code a map fix, how do I do like if map = gm_map then ent.create endbutton pos xyz ?
[QUOTE=Darkwater124;38551673] Also, how do I check if someone has godmode? (With :GodEnable()) [/QUOTE] I'm not sure if there is a way to check if it's enabled, but couldn't you set a boolean which determines if a player has godmode or not? So whenever you call pl:GodEnable() just set pl.GodMode = true, same thing when you disable it. [lua]local meta = FindMetaTable("Player") if not meta then return end function meta:HasGodMode() if self.GodMode then return true end return false end function meta:SetGodMode(bool) if self:HasGodMode() == bool then return end local condition = (bool and self:GodEnable()) or self:GodDisable() self.GodMode = bool end [/lua] [QUOTE=Kwaq;38554974]I need to hard code a map fix, how do I do like if map = gm_map then ent.create endbutton pos xyz ?[/QUOTE] Not entirely sure what you're asking for, but is this helpful? [lua]if string.lower(game.GetMap()) == "text" then (assign offset) end[/lua] If you're going to have more than one map, create a table for the offsets.
[QUOTE=Kwaq;38554974]I need to hard code a map fix, how do I do like if map = gm_map then ent.create endbutton pos xyz ?[/QUOTE] [lua] if game.GetMap() == "gm_mapname" then local enti = ents.Create("prop_physics") enti:SetPos(Vector(0,0,0)) enti:SetModel("modelgoeshere") enti:Spawn() end [/lua]
Hey guys, have a new script that I need to use to admin on my new PERP server, but every time I run, it, I get this error: [CODE][ERROR] LuaCmd:1: bad argument #1 to 'RunString' (string expected, got no value) 1. RunString - [C]:-1 2. unknown - LuaCmd:1 [/CODE] Any idea why? Thanks.
Based on the immense amounts of information you have provided I have come to the conclusion that it's because there's something wrong with your script.
Hello everyone, my entity isn't drawing like it is supposed to [lua] function ENT:Draw() self:DrawModel() local FixAngles = self:GetAngles() local FixRotation = Vector(0, 270, 0) FixAngles:RotateAroundAxis(FixAngles:Right(), FixRotation.x) FixAngles:RotateAroundAxis(FixAngles:Up(), FixRotation.y) FixAngles:RotateAroundAxis(FixAngles:Forward(), FixRotation.z) local TargetPos = self:GetPos() + (self:GetUp() * 9) local _,_,_,a = self:GetColor() if self.DrawText then cam.Start3D2D(TargetPos, FixAngles, 0.15) draw.SimpleText(">_<", "HUDNumber5", TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, Color(255,0,0,a),1,1) cam.End3D2D() end end [/lua] I have a separate surface.CreateFont that creates "HUDNumber5", but nothing works. Even with default fonts it still won't show the ">_<" on the entity.
[QUOTE=Apozen;38558163]Hello everyone, my entity isn't drawing like it is supposed to I have a separate surface.CreateFont that creates "HUDNumber5", but nothing works. Even with default fonts it still won't show the ">_<" on the entity.[/QUOTE] [LUA] function ENT:Draw() self:DrawModel() local FixAngles = self:GetAngles() local FixRotation = Vector(0, 270, 0) FixAngles:RotateAroundAxis(FixAngles:Right(), FixRotation.x) FixAngles:RotateAroundAxis(FixAngles:Up(), FixRotation.y) FixAngles:RotateAroundAxis(FixAngles:Forward(), FixRotation.z) surface.SetFont("HUDNumber5") txt = ">_<" local TextWidth = surface.GetTextSize(txt) local TargetPos = self:GetPos() + self:GetUp() * 11.5 local a = self:GetColor().a if self.DrawText then cam.Start3D2D(TargetPos, FixAngles, 0.15) draw.DrawText(txt, "HUDNumber5", 0, 32, Color(255,0,0,a),TEXT_ALIGN_CENTER) cam.End3D2D() end end [/Lua] I changed your simple text to drawtext, the variable 'a' was nil and TEXT_ALIGN_CENTER does not do what you think it does
[QUOTE=KatNotDinner;38553093]So I have 2 dumb questions. First one, are DTVars networked (will Entity:SetDTBlah set the DTVar type on the client too, without needing to be force with a net message). Second one, how can I draw a PNG image? [/QUOTE] Sorry for asking again but it's really urgent.
[QUOTE=KatNotDinner;38560534]Sorry for asking again but it's really urgent.[/QUOTE] Yes, and: surface.GetTextureID( material ) = Material( material ) surface.SetTexture = surface.SetMaterial
Ok, thanks. I was worried that doing myent:SetDTFloat(1, 2.3) serverside won't set the dt float on the client. And thanks for showing me how to draw PNG images on the screen :)
[QUOTE=Grondo4;38558471][LUA] function ENT:Draw() self:DrawModel() local FixAngles = self:GetAngles() local FixRotation = Vector(0, 270, 0) FixAngles:RotateAroundAxis(FixAngles:Right(), FixRotation.x) FixAngles:RotateAroundAxis(FixAngles:Up(), FixRotation.y) FixAngles:RotateAroundAxis(FixAngles:Forward(), FixRotation.z) surface.SetFont("HUDNumber5") txt = ">_<" local TextWidth = surface.GetTextSize(txt) local TargetPos = self:GetPos() + self:GetUp() * 11.5 local a = self:GetColor().a if self.DrawText then cam.Start3D2D(TargetPos, FixAngles, 0.15) draw.DrawText(txt, "HUDNumber5", 0, 32, Color(255,0,0,a),TEXT_ALIGN_CENTER) cam.End3D2D() end end [/Lua] I changed your simple text to drawtext, the variable 'a' was nil and TEXT_ALIGN_CENTER does not do what you think it does[/QUOTE] Unfortunately that does not work either :I Even when trying with different fonts.
Sorry, you need to Log In to post a reply to this thread.