• I need some help <3
    14 replies, posted
[lua]function Playermenu() DermaPanel1 = vgui.Create( "DFrame" ) DermaPanel1:SetPos( 50,25 ) DermaPanel1:SetSize( 500, 500 ) DermaPanel1:SetTitle( "Items" ) DermaPanel1:SetVisible( true ) DermaPanel1:SetDraggable( true ) DermaPanel1:ShowCloseButton( true ) DermaPanel1:MakePopup() local DermaButton1 = vgui.Create( "DButton", DermaPanel1 ) DermaButton1:SetText( "Join our DarkRP" ) DermaButton1:SetPos( 12.5, 30 ) DermaButton1:SetSize( 100, 25 ) DermaButton1.DoClick = function() RunConsoleCommand("connect","00.00.00.000:00000") end local DermaButton2 = vgui.Create( "DButton", DermaPanel1 ) DermaButton2:SetText( "Baseball Bat" ) DermaButton2:SetPos( 125.5, 30 ) DermaButton2:SetSize( 100, 25 ) DermaButton2.DoClick = function() RunConsoleCommand( "give", "weapon_bat" ) end end concommand.Add("servers", Playermenu)[/lua] Just a little thing i coppied, How would i make when players type !servers it opens? and how would i make so people press connect, they join, Because it doesnt work, when i press it says: Disconnected Server shut down succesfully so WTF, it didnt shut down, but it wont let me connect via my menu :/ also how i make like -500 money from a player.
You would probably get more attention if you posted this in LUA Scripting. For your !servers command in chat, something like this should do [code] if SERVER then hook.Add("PlayerSay", "ChatHook", function(Player, Text, Public) if Text[1] == "!" then Text = Text:lower() if Text == "!servers" then Player:ConCommand("servers") return "" end end end) end [/code]
It doesnt really work, i placed it TOP of my script, nothing happends when i type !servers also need help with the other things <33
I'd suggest you to make such threads in the lua forum instead of posting here when the description pretty clearly says: If you're having problems PLAYING GMod then this is the place for you.
Try changing the name of your console command. I had some issues with the server not being able to run the command so I changed the name and it worked. Try something with an uppercase letter and a unique name. Something like this [code] concommand.Add("LeviServers",Playermenu) [/code] If that still doesn't work, try added a MsgN("text") line into the Playermenu function to see if it's actually getting run. This will print the text in the console.
Ok it works, but the connetc thing doesnt work, i get this error: RunConsoleCommand: Command has invalid characters! (connect:178.239.170.173:27017 (':')) The first parameter of this function should contain only the command, the second parameter should contain arguments
try game.ConsoleCommand instead It's a little easier to format the command. Here is the wiki page [url]http://wiki.garrysmod.com/page/Libraries/game/ConsoleCommand[/url] e.x. [code] game.ConsoleCommand("connect 000.000.000.000:00000\n") [/code]
[ERROR] lua/autorun/client/shared.lua:29: attempt to call field 'ConsoleCommand' (a nil value) 1. DoClick - lua/autorun/client/shared.lua:29 2. unknown - lua/vgui/dlabel.lua:206
[QUOTE=levicheater;39254410][ERROR] lua/autorun/client/shared.lua:29: attempt to call field 'ConsoleCommand' (a nil value) 1. DoClick - lua/autorun/client/shared.lua:29 2. unknown - lua/vgui/dlabel.lua:206[/QUOTE] Post an updated version of your code
[lua]if SERVER then hook.Add("PlayerSay", "ChatHook", function(Player, Text, Public) if Text[1] == "!" then Text = Text:lower() if Text == "!servers" then Player:ConCommand("noshit") return "" end end end) end function Playermenu() DermaPanel1 = vgui.Create( "DFrame" ) DermaPanel1:SetPos( 50,25 ) DermaPanel1:SetSize( 500, 500 ) DermaPanel1:SetTitle( "Items" ) DermaPanel1:SetVisible( true ) DermaPanel1:SetDraggable( true ) DermaPanel1:ShowCloseButton( true ) DermaPanel1:MakePopup() local DermaButton1 = vgui.Create( "DButton", DermaPanel1 ) DermaButton1:SetText( "Join our DarkRP" ) DermaButton1:SetPos( 12.5, 30 ) DermaButton1:SetSize( 100, 25 ) DermaButton1.DoClick = function() game.ConsoleCommand( "connect 178.239.170.173:27017\n" ) end local DermaButton2 = vgui.Create( "DButton", DermaPanel1 ) DermaButton2:SetText( "Baseball Bat" ) DermaButton2:SetPos( 125.5, 30 ) DermaButton2:SetSize( 100, 25 ) DermaButton2.DoClick = function() RunConsoleCommand( "give", "weapon_bat" ) end end concommand.Add("noshit", Playermenu) [/lua] Posted in client and server(same code) [editline]17th January 2013[/editline] at. [ERROR] lua/autorun/client/shared.lua:29: attempt to call field 'ConsoleCommand' (a nil value) 1. DoClick - lua/autorun/client/shared.lua:29 2. unknown - lua/vgui/dlabel.lua:206
I added an if to check if they are a CLIENT. Also you should only have one lua file located in lua\autorun on your server. This is will automatically run on both the client and server Give that a try [code] if SERVER then hook.Add("PlayerSay", "ChatHook", function(Player, Text, Public) if Text[1] == "!" then Text = Text:lower() if Text == "!servers" then Player:ConCommand("noshit") return "" end end end) end if CLIENT then concommand.Add("noshit", Playermenu) function Playermenu() DermaPanel1 = vgui.Create( "DFrame" ) DermaPanel1:SetPos( 50,25 ) DermaPanel1:SetSize( 500, 500 ) DermaPanel1:SetTitle( "Items" ) DermaPanel1:SetVisible( true ) DermaPanel1:SetDraggable( true ) DermaPanel1:ShowCloseButton( true ) DermaPanel1:MakePopup() local DermaButton1 = vgui.Create( "DButton", DermaPanel1 ) DermaButton1:SetText( "Join our DarkRP" ) DermaButton1:SetPos( 12.5, 30 ) DermaButton1:SetSize( 100, 25 ) DermaButton1.DoClick = function() game.ConsoleCommand("connect 178.239.170.173:27017\n") end local DermaButton2 = vgui.Create( "DButton", DermaPanel1 ) DermaButton2:SetText( "Baseball Bat" ) DermaButton2:SetPos( 125.5, 30 ) DermaButton2:SetSize( 100, 25 ) DermaButton2.DoClick = function() game.ConsoleCommand( "give weapon_bat" ) end end end [/code]
It works, But your Console commands doesnt work, when i press it it says this .. [lua][ERROR] lua/autorun/drpshared.lua:32: attempt to call field 'ConsoleCommand' (a nil value) 1. DoClick - lua/autorun/drpshared.lua:32 2. unknown - lua/vgui/dlabel.lua:206 [/lua]
[QUOTE=levicheater;39254515]It works, But your Console commands doesnt work, when i press it it says this .. [lua][ERROR] lua/autorun/drpshared.lua:32: attempt to call field 'ConsoleCommand' (a nil value) 1. DoClick - lua/autorun/drpshared.lua:32 2. unknown - lua/vgui/dlabel.lua:206 [/lua][/QUOTE] Not sure why it's saying that. Are there any other errors in the console after you hit the button? I guess you can try the other code again. [code] RunConsoleCommand("connect", "178.239.170.173:27017") RunConsoleCommand( "give", "weapon_bat" ) [/code]
Network: IP 192.168.1.13, mode MP, dedicated No, ports 27015 SV / 27005 CL Bad server address ("178.239.170.173:27017") ServerLog: Server succesfully shut down. Dropped levicheater from server (Server shutting down) says it when i press. No it didnt shut down... [editline]17th January 2013[/editline] No other errors also.
From the looks of it, the "connect" command might be blocked from running. [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexcfcc.html[/url] There may be ways around it but I'm not sure
Sorry, you need to Log In to post a reply to this thread.