• What do you need help with? V3
    6,419 replies, posted
[QUOTE=nick_9_8;39386840]I've been trying to make a [B]clientside[/B] command where I can activate a console command with a chat command. Let me show you what I mean: [CODE]test_chicken pizza [/CODE] How can I make it so I can type !testcommand chicken pizza and then my chosen first half of the console command runs (chosenfirsthalfconsolecommand)_chicken pizza Thanks for any help, hope this made sense.[/QUOTE] I don't quite understand what you're asking for but I came up with this: [lua] hook.Add("OnPlayerChat", "ChatCommands", function(ply, text, teamChat, plyIsDead) local txtTbl = string.Explode(" ", text) if #txtTbl != 3 then return end if txtTbl[1] != "!run" then return end RunConsoleCommand(txtTbl[2], txtTbl[3]) end) concommand.Add("ChatCommandTest", function(ply, cmd, args) local num = tonumber(args[1]) if !num then return end print(num) end) [/lua]
hello buddies, im having a problem setting the position of my "Global Options" text on derma, the text no matter what position i set, keep appearing at the middle of the derma. [lua]function MyMenu2() // MyMenu2: Menu activated by pressing F1 // The Frame local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetSize( 800, 600 ) DermaPanel:Center() DermaPanel:SetTitle( "Lua Derma Menu" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( false ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() //Tab Frame local PropertySheet = vgui.Create( "DPropertySheet" ) PropertySheet:SetParent( DermaPanel ) PropertySheet:SetPos( 5, 30 ) PropertySheet:SetSize( 790, 565 ) local ML = vgui.Create( "DLabel" ) ML:SetPos(50, 25) ML:SetColor(Color(29,0,255,255)) // Color ML:SetFont("default") ML:SetText("Global Option") // Text ML:SizeToContents() PropertySheet:AddSheet( "Global Options", ML, "gui/silkicons/world", false, false, "Modify your options here" ) end[/lua]
[QUOTE=Mecha;39387097]hello buddies, im having a problem setting the position of my "Global Options" text on derma, the text no matter what position i set, keep appearing at the middle of the derma. [CODE]function MyMenu2() // MyMenu2: Menu activated by pressing F1 // The Frame local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetSize( 800, 600 ) DermaPanel:Center() DermaPanel:SetTitle( "Lua Derma Menu" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( false ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() //Tab Frame local PropertySheet = vgui.Create( "DPropertySheet" ) PropertySheet:SetParent( DermaPanel ) PropertySheet:SetPos( 5, 30 ) PropertySheet:SetSize( 790, 565 ) local ML = vgui.Create( "DLabel" ) ML:SetPos(50, 25) ML:SetColor(Color(29,0,255,255)) // Color ML:SetFont("default") ML:SetText("Global Option") // Text ML:SizeToContents() PropertySheet:AddSheet( "Global Options", ML, "gui/silkicons/world", false, false, "Modify your options here" ) end[/CODE][/QUOTE] Edit your post and use [.lua][./lua] without the '.' tags.
I'm kind of new to derma and I'm having some trouble. Here's what my current menu looks like [img]http://puu.sh/1TPRi[/img] I want the "Hats" to be like a sub of "Store" but it's a little off and I can't figure out what I'm doing wrong. Here is my current code: [url]http://pastebin.com/TMbHLYYC[/url]
[QUOTE=Mecha;39387097]hello buddies, im having a problem setting the position of my "Global Options" text on derma, the text no matter what position i set, keep appearing at the middle of the derma. [/QUOTE] Fixed it up: [lua] function ShowScore2() local DMain = vgui.Create( "DFrame" ) DMain:SetSize(800,600) DMain:Center() DMain:SetTitle("Lua Derma Menu") DMain:SetVisible(true) DMain:SetDraggable(false) DMain:ShowCloseButton(true) DMain:MakePopup() local PropertySheet = vgui.Create("DPropertySheet", DMain) PropertySheet:SetPos(5,30) PropertySheet:SetSize(790,565) local Panel = vgui.Create("DPanel") Panel:SetPos(25, 50) Panel:SetSize(250, 250) local ML = vgui.Create("DLabel", Panel) ML:SetPos(50,75) ML:SetColor(Color(29,0,255,255)) ML:SetFont("default") ML:SetText("Global Option") ML:SizeToContents() PropertySheet:AddSheet("Global Options", Panel, "gui/silkicons/world", false, false, "Modify your options here") end [/lua] Use this as a reference: [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index595b.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index595b.html[/URL]
[QUOTE=brandonj4;39387132]Fixed it up: [lua] function ShowScore2() local DMain = vgui.Create( "DFrame" ) DMain:SetSize(800,600) DMain:Center() DMain:SetTitle("Lua Derma Menu") DMain:SetVisible(true) DMain:SetDraggable(false) DMain:ShowCloseButton(true) DMain:MakePopup() local PropertySheet = vgui.Create("DPropertySheet", DMain) PropertySheet:SetPos(5,30) PropertySheet:SetSize(790,565) local Panel = vgui.Create("DPanel") Panel:SetPos(25, 50) Panel:SetSize(250, 250) local ML = vgui.Create("DLabel", Panel) ML:SetPos(50,75) ML:SetColor(Color(29,0,255,255)) ML:SetFont("default") ML:SetText("Global Option") ML:SizeToContents() PropertySheet:AddSheet("Global Options", Panel, "gui/silkicons/world", false, false, "Modify your options here") end [/lua] Use this as a reference: [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index595b.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index595b.html[/URL][/QUOTE] Soo the fix was only to add a Dpanel? wow im really blind, thank you!
[QUOTE=Mecha;39387148]Soo the fix was only to add a Dpanel? wow im really blind, thank you![/QUOTE] Yep :P To parent derma items you dont have to do PANEL:SetParent(otherpanel), you can easily just do: [code]local panel = vgui.Create("Panel", parentingpanel)[/code]
[QUOTE=havejack;39384795]Ok Heres the new working code but gives me this error: [LUA] local function BuyCar( ply, args, args2 ) if not args2[1] or args2[1] == "" then return "" end if args2[1] == "jeep" then local car = ents.Create( "jeep" ) car:SetPos( Vector( -2629, 2304, 139 ) ) car:Spawn() chat.AddText(Color(255,255,128), "Merchant: ",Color(255,255,255), "Welcome to my shop, how can I help you?" ) GAMEMODE:Notify(ply, 1, 4, "You've bought a jeep!"); else chat.AddText(Color(255,255,128), "Merchant: ",Color(255,255,255), "Failed" ) end end concommand.Add( "rp_buycar", BuyCar) [/LUA] /npc_car/cl_init.lua:43: attempt to call field 'Create' (a nil value) 1. unknown - gamemodes/darkrp/entities/entities/npc_car/cl_init.lua:43 2. unknown - l[/QUOTE]Once again... Jeep is not a valid entity. It is prop_vehicle_jeep or something like that. Not 100% sure.
[QUOTE=Gamz365;39387121]I'm kind of new to derma and I'm having some trouble. Here's what my current menu looks like [img]http://puu.sh/1TPRi[/img] I want the "Hats" to be like a sub of "Store" but it's a little off and I can't figure out what I'm doing wrong. Here is my current code: [url]http://pastebin.com/TMbHLYYC[/url][/QUOTE] This is how: [lua] function StoreMenu() if ValidPanel(DMain) then DMain:Remove() end local DMain = vgui.Create( "DFrame" ) DMain:SetPos( 50, 50 ) DMain:SetSize( 900, 450 ) DMain:SetTitle("Gamz Server V0.1") DMain:SetVisible( true ) DMain:SetDraggable( true ) DMain:ShowCloseButton( true ) DMain:MakePopup() DMain:Center() local PSheet = vgui.Create("DPropertySheet", DMain) PSheet:SetPos(5, 30) PSheet:SetSize(875, 400) local StoreSheet = vgui.Create("DPropertySheet") StoreSheet:SetPos(5,30) StoreSheet:SetSize(875,400) local PHome = vgui.Create("DPanel") PHome:SetPos(5,5) PHome:SizeToContents() function PHome.Paint(self,w,h) surface.SetDrawColor(50, 50, 50, 255) surface.DrawRect(0, 0, w, h) end local PHats = vgui.Create("DPanel") PHats:SetPos(5,5) PHats:SizeToContents() function PHats.Paint(self,w,h) surface.SetDrawColor( 50, 50, 50, 255 ) surface.DrawRect(0, 0, w, h) end local lblHome = vgui.Create("DLabel", PHome) lblHome:SetPos(5,5) lblHome:SetColor(Color(15,15,15,255)) lblHome:SetFont("default") lblHome:SetText("Welcome to Gamz's Sexy Server") lblHome:SizeToContents() PSheet:AddSheet("Home", PHome, "gui/silkicons/world", false, false) PSheet:AddSheet("Store", StoreSheet, "gui/silkicons/bomb", false, false) StoreSheet:AddSheet("Hats", PHats, "gui/silkicons/emoticon_smile", false, false) end StoreMenu() [/lua]
[QUOTE=brandonj4;39387085]I don't quite understand what you're asking for but I came up with this: [lua] hook.Add("OnPlayerChat", "ChatCommands", function(ply, text, teamChat, plyIsDead) local txtTbl = string.Explode(" ", text) if #txtTbl != 3 then return end if txtTbl[1] != "!run" then return end RunConsoleCommand(txtTbl[2], txtTbl[3]) end) concommand.Add("ChatCommandTest", function(ply, cmd, args) local num = tonumber(args[1]) if !num then return end print(num) end) [/lua][/QUOTE] I explained it like an idiot. Basically, I play on a server that uses custom commands to force a player to a team. For example: [CODE]team_terrorist [player][/CODE] puts the player to terrorist, [CODE]team_betrayer [player][/CODE] puts the player to betrayer, etc etc. So I want to be able to type in my chat !team terrorist exampleplayer and it will run that console command clientside. Sorry about my awful explaining and thanks so much for your help :D
Bump, seeing as though 90% of the time my questions and problems go unanswered, read my post above.
[QUOTE=NintendoEKS;39387534]Bump, seeing as though 90% of the time my questions and problems go unanswered, read my post above.[/QUOTE] I would help you but I don't know SQL sorry.
[QUOTE=Science;39380903]I think the function is Player:GetRoleString() Try implementing it, and get back to me, ill tell you if your correct.[/QUOTE] [CODE]hook.Add("PlayerDeath", "DeathInform", function(vic, wea, kill, player)CustomMsg(vic, "You were killed by "..kill:Nick(), Player:GetRoleString(), Color(255,0,0)) end)[/CODE] is this right?
Anyone help me with this error? It's a fallout SWEP pack I'm at least trying to get these to shoot but I'm having some troubles [CODE][ERROR] lua/weapons/fo3_plasmarifle/shared.lua:63: attempt to call method 'CanPrimaryAttack' (a nil value) 1. unknown - lua/weapons/fo3_plasmarifle/shared.lua:63[/CODE] This happens for every one of them btw, just with each weapon's respectable name. I'm also getting an error for all of the weapons coming from a base file I believe. [CODE]SWEP (fo3_alienblaster) is derived from non existant SWEP (fo3_stef_base) - Expect errors! [/CODE]
[QUOTE=NintendoEKS;39387534]Bump, seeing as though 90% of the time my questions and problems go unanswered, read my post above.[/QUOTE] Your issue is that the player is removed before the next query is running, calling the player object. If you set any variables you need in locals outside of the query it will work fine. [editline]28th January 2013[/editline] [QUOTE=thejjokerr;39388512]You can't maintain the player object, just maintain the values you want to use later. So in the PlayerDisconnect hook you would do something like savePlayerData(steamid, ip, money, etc) Also I don't really get why you would SELECT the players' row every time you save, as you don't seem to be doing anything with the retrieved data.[/QUOTE] Thanks for ninjaing me, but regarding the SELECT statement, it looks like he's doing it to prevent 3 SQL errors if the user isn't in the database (which they could technically all be combined into one query, and an ON DUPLICATE KEY UPDATE)
COuld someone tell me where i would put the function ents.Create(), in init.lua or cl_init.lua or shared.lua, No matter where i put it, it wont work, in init.lua it returns nothing period
[QUOTE=havejack;39390390]COuld someone tell me where i would put the function ents.Create(), in init.lua or cl_init.lua or shared.lua, No matter where i put it, it wont work, in init.lua it returns nothing period[/QUOTE] Try to take a look at these: [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index22ac.html[/url] [url]http://wiki.garrysmod.com/page/Libraries/ents/Create[/url] It's serverside.
It depends how you are using it. If you are simply typing ents.Create() into a file. You wont get anything.
I have it setup to do local buy = ents.Create("<Jeep Class") , even my print i put in there for debuging do nothing when its in the init.lua
[QUOTE=havejack;39390517]I have it setup to do local buy = ents.Create("<Jeep Class") , even my print i put in there for debuging do nothing when its in the init.lua[/QUOTE] Post all the code you're use to do this with lua tags.
[editline]28th January 2013[/editline] Pretty crapy code, i know, im still new to lua xD
You could tell us some of the many errors you're console is telling you, I can see so many clientside functions used in the serverside code. You're also doing: [lua]icon.DoClick = function() LocalPlayer():ConCommand("say "..command) end[/lua] which in no way will even get close to calling the serverside function: [lua]concommand.Add("rp_buycar",BuyVehicle)[/lua]
I know, im gonna change that, its the concommand that is not working period. [editline]28th January 2013[/editline] [QUOTE=Matt-;39390715]You could tell us some of the many errors you're console is telling you, I can see so many clientside functions used in the serverside code. You're also doing: [lua]icon.DoClick = function() LocalPlayer():ConCommand("say "..command) end[/lua] which in no way will even get close to calling the serverside function: [lua]concommand.Add("rp_buycar",BuyVehicle)[/lua][/QUOTE] I plan on useing [LUA] icon.DoClick = function() LocalPlayer():ConCommand("rp_buycar "..command) end [/LUA]
ents.Create( "vehicle_jeep" ) will not work, as that's not a real entity, your console is also probably telling you that. should be "prop_vehicle_jeep"
I can't make my entity transparent after using it, I've set the rendermode to TRANS_ALPHA and I am doing self:SetColor(Color(255,255,255,255-Clr.a)) where Clr.a starts with 255 on init and is being reduced by 25 each usage.
[QUOTE=Science;39390438]It depends how you are using it. If you are simply typing ents.Create() into a file. You wont get anything.[/QUOTE] Well, sorry I just tried to not give you trouble, the truth is, I know nothing about lua
Ok, got the code working but when jeep is spawned, it doesn show up and spamms console with [code] GetSequenceLinearMotion()! Bad pstudiohdr in GetSequenceLinearMotion()! Bad pstudiohdr in GetSequenceLinearMotion()! Bad pstudiohdr in GetSequenceLinearMotion()! Bad pstudiohdr in GetSequenceLinearMotion()! Bad pstudiohdr in GetSequenceLinearMotion()! Bad pstudiohdr in GetSequenceLinearMotion()! Bad pstudiohdr in GetSequenceLinearMotion()! Bad pstudiohdr in GetSequenceLinearMotion()! Bad pstudiohdr in [/code]
[QUOTE=hellguy;39391040]Well, sorry I just tried to not give you trouble, the truth is, I know nothing about lua[/QUOTE]We are here for your troubles. We would much rather you be nice, take our advice, and tell us the full story. That way we can address and solve the issue quicker. Heres some things for you to read to get start: [url]http://www.lua.org/pil/[/url] [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4875.html[/url] [url]http://wiki.garrysmod.com/page/Main_Page[/url]
Never mind got it fixed !
[QUOTE=Science;39391552]We are here for your troubles. We would much rather you be nice, take our advice, and tell us the full story. That way we can address and solve the issue quicker. Heres some things for you to read to get start: [url]http://www.lua.org/pil/[/url] [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4875.html[/url] [url]http://wiki.garrysmod.com/page/Main_Page[/url][/QUOTE] All I need is a global message that tells who killed you(only you and not the living players) and if he was a traitor or innocent : ) I will read that tuts! thank you a lot
Sorry, you need to Log In to post a reply to this thread.