• Bunch of problems
    16 replies, posted
Hello Facepunch, My server used to have a lua code that opened a derma frame which would allow people to join other servers of my community. The code was NOT made by me (As you can clearly see in the code), but it had the connect command in it (Which is blocked). So, after I stumbled on to [URL="http://facepunch.com/showthread.php?t=1415135"]THIS[/URL] thread, I decided to modify it, along with some knowledge I have aquired through Facepunch. Here's the current version: [CODE]--This is a menu for our [Community name] servers. Made by Christian. local function ServersMenu() local BackGround = vgui.Create( "DFrame" ) BackGround:SetSize( 570, 330 ) BackGround:SetPos( 10, 10 ) BackGround:SetTitle( "TechSource Servers" ) BackGround:SetVisible( true ) BackGround:SetDraggable( true ) BackGround:ShowCloseButton( true ) BackGround:MakePopup() BackGround.Paint = function() draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(51,51,51,255)) draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(165,0,0,255)) end local AButton = vgui.Create( "DButton", BackGround ) AButton:SetSize( 160, 40 ) AButton:SetText( "Reconnect to TTT" ) AButton:SetPos( 20, 30 ) AButton.DoClick = function(ply) ply:SendLua("LocalPlayer():ConCommand(connect [The IP])") end local AButton = vgui.Create( "DButton", BackGround ) AButton:SetSize( 160, 40 ) AButton:SetText( "Join DarkRP" ) AButton:SetPos( 20, 80 ) AButton.DoClick = function(ply) ply:SendLua("LocalPlayer():ConCommand(connect [The IP])") end local AButton = vgui.Create( "DButton", BackGround ) AButton:SetSize( 160, 40 ) AButton:SetText( "Join Prophunt" ) AButton:SetPos( 20, 130 ) AButton.DoClick = function(ply) ply:SendLua("LocalPlayer():ConCommand(connect [The IP])") end local AButton = vgui.Create( "DButton", BackGround ) AButton:SetSize( 160, 40 ) AButton:SetText( "Join Melonbomber" ) AButton:SetPos( 20, 180 ) AButton.DoClick = function(ply) ply:SendLua("LocalPlayer():ConCommand(connect [The IP])") end local AButton = vgui.Create( "DButton", BackGround ) AButton:SetSize( 160, 40 ) AButton:SetText( "Join Murder" ) AButton:SetPos( 20, 230 ) AButton.DoClick = function(ply) ply:SendLua("LocalPlayer():ConCommand(connect [The IP])") end local AButton = vgui.Create( "DButton", BackGround ) AButton:SetSize( 160, 40 ) AButton:SetText( "Join Sandbox" ) AButton:SetPos( 20, 280 ) AButton.DoClick = function(ply) ply:SendLua("LocalPlayer():ConCommand(connect [The IP])") end end hook.Add( "OnPlayerChat", "Servers", function( ply, text ) if ( ply == LocalPlayer() && text == "/servers") then ServersMenu() end end )[/CODE] Problem is, the derma frame is not even showing up.... No console errors, nothing .-. The second thing is a known pointshop bug. The bug is where if you buy a weapon and you already have a weapon in the same slot, the points are wasted but you don't get the gun. I posted this in a lot of tiny problems threads but I kept getting ignored, so here it is :P [CODE]ITEM.Name = 'm16' ITEM.Price = 300 ITEM.Model = 'models/weapons/w_rif_m4a1.mdl' ITEM.WeaponClass = 'weapon_ttt_m16' ITEM.Kind = WEAPON_PRIMARY ITEM.SingleUse = true local ids = { weapon_ttt_m16 = "M16", weapon_zm_rifle = "rifle_name", weapon_zm_shotgun = "shotgun_name", weapon_zm_sledge = "H.U.G.E-249", weapon_zm_mac10 = "MAC10" } function ITEM:OnBuy(ply) for k, v in pairs( ply:GetWeapons() ) do if v.Kind == self.Kind then ply:StripWeapon( v.ClassName ) ply:PS_HolsterItem( ids[v.ClassName] ) end end ply:Give(self.WeaponClass) ply:SelectWeapon(self.WeaponClass) end function ITEM:OnSell(ply) ply:StripWeapon(self.WeaponClass) end[/CODE] I'm not quite good with this, this code is litteraly just a bunch of facepunch users telling me bits of what to put in, but again, it doesn't work, there are no console errors. I assume that there's a bunch of stuff wrong with it, I just don't know what :P
[CODE] function chatCommand( ply, text, public ) if (string.sub(text, 1, 8) == "/servers") then -- If in chat the ply says /servers ply:ServersMenu() -- Open the menu for that player return(false) -- Hide it from chat. end end hook.Add( "PlayerSay", "chatCommand", chatCommand );[/CODE] Will test your code in game.
[QUOTE=AIX-Who;45614165][CODE] function chatCommand( ply, text, public ) if (string.sub(text, 1, 8) == "/servers") then -- If in chat the ply says /servers ply:ServersMenu() -- Open the menu for that player return(false) -- Hide it from chat. end end hook.Add( "PlayerSay", "chatCommand", chatCommand );[/CODE][/QUOTE] I've been told not to use PlayerSay because it's serverside
-snip-
It's fine, just use net messages: Client: [CODE]--This is a menu for our [Community name] servers. Made by Christian. local function ServersMenu() local BackGround = vgui.Create( "DFrame" ) BackGround:SetSize( 570, 330 ) BackGround:SetPos( 10, 10 ) BackGround:SetTitle( "TechSource Servers" ) BackGround:SetVisible( true ) BackGround:SetDraggable( true ) BackGround:ShowCloseButton( true ) BackGround:MakePopup() BackGround.Paint = function() draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(51,51,51,255)) draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(165,0,0,255)) end local AButton = vgui.Create( "DButton", BackGround ) AButton:SetSize( 160, 40 ) AButton:SetText( "Reconnect to TTT" ) AButton:SetPos( 20, 30 ) AButton.DoClick = function(ply) ply:SendLua("LocalPlayer():ConCommand(connect [The IP])") end local AButton = vgui.Create( "DButton", BackGround ) AButton:SetSize( 160, 40 ) AButton:SetText( "Join DarkRP" ) AButton:SetPos( 20, 80 ) AButton.DoClick = function(ply) ply:SendLua("LocalPlayer():ConCommand(connect [The IP])") end local AButton = vgui.Create( "DButton", BackGround ) AButton:SetSize( 160, 40 ) AButton:SetText( "Join Prophunt" ) AButton:SetPos( 20, 130 ) AButton.DoClick = function(ply) ply:SendLua("LocalPlayer():ConCommand(connect [The IP])") end local AButton = vgui.Create( "DButton", BackGround ) AButton:SetSize( 160, 40 ) AButton:SetText( "Join Melonbomber" ) AButton:SetPos( 20, 180 ) AButton.DoClick = function(ply) ply:SendLua("LocalPlayer():ConCommand(connect [The IP])") end local AButton = vgui.Create( "DButton", BackGround ) AButton:SetSize( 160, 40 ) AButton:SetText( "Join Murder" ) AButton:SetPos( 20, 230 ) AButton.DoClick = function(ply) ply:SendLua("LocalPlayer():ConCommand(connect [The IP])") end local AButton = vgui.Create( "DButton", BackGround ) AButton:SetSize( 160, 40 ) AButton:SetText( "Join Sandbox" ) AButton:SetPos( 20, 280 ) AButton.DoClick = function(ply) ply:SendLua("LocalPlayer():ConCommand(connect [The IP])") end end net.Receive( 'open_servermenu', ServersMenu )[/CODE] Server: [CODE] util.AddNetworkString( 'open_servermenu' ) function chatCommand( ply, text, public ) if (string.sub(text, 1, 8) == "/servers") then -- If in chat the ply says /servers net.Start( 'open_servermenu' ) net.Send( ply ) -- Open the menu for that player return(false) -- Hide it from chat. end end hook.Add( "PlayerSay", "chatCommand", chatCommand ); [/CODE] As for that pointshop thing, For the weapon you are buying find its slot, then you want to strip the weapon that is in the slot and give him the one he purchased. ( You can make him drop it too i guess )
[QUOTE=AIX-Who;45614248]It's fine, just use net messages: Client: [CODE]Blah blah blah code[/CODE] Server: [CODE]Blah blah blah code[/CODE] [/QUOTE] Sorry for my stupidity but when you say that, do you mean I should split the file into 2 files with the same name, and put one in autorun/server and one in autorun/client? Or split it to "if CLIENT then" and "if SERVER then", (which I doubt would be the case but still asking)? Or something else? :P
Put client in autorun/client and server in autorun/server.
Alright so AIX-Who, I did exactly what you told me, the panel opens, everything's great... Except for the fact that you can't actually connect to the servers :P Getting this error: [CODE][ERROR] lua/autorun/client/servers_menu.lua:61: attempt to call method 'SendLua' (a nil value) 1. DoClick - lua/autorun/client/servers_menu.lua:61 2. unknown - lua/vgui/dlabel.lua:206[/CODE] And I assume I would get the same error with a different line if I would test it on another server
I'm pretty sure you don't need the ply:SendLua. I've never needed it before, but again, I don't know if that's a part of your way of bypassing the connect command.
[QUOTE=Lolm4te;45614479]I'm pretty sure you don't need the ply:SendLua. I've never needed it before, but again, I don't know if that's a part of your way of bypassing the connect command.[/QUOTE] It is :P
- snip - I see another problem, you have [lua]ply:SendLua("LocalPlayer():ConCommand(connect [The IP])")[/lua] It is suppose to be [lua] ply:SendLua("LocalPlayer():ConCommand("connect", "youriphere")") [/lua] If that doesn't work, try this: [lua] ply:SendLua("LocalPlayer():RunConsoleCommand("connect", "youriphere")") [/lua] But if that fails, removethe ply:SendLua and try above again.
[QUOTE=Lolm4te;45614782]- snip - I see another problem, you have [lua]ply:SendLua("LocalPlayer():ConCommand(connect [The IP])")[/lua] It is suppose to be [lua] ply:SendLua("LocalPlayer():ConCommand("connect", "youriphere")") [/lua] If that doesn't work, try this: [lua] ply:SendLua("LocalPlayer():RunConsoleCommand("connect", "youriphere")") [/lua] But if that fails, removethe ply:SendLua and try above again.[/QUOTE] I think Willox has some workaround to blocked commands on his profile. [code] LocalPlayer():ConCommand( string.rep( "\n", 1024 ) .. " connect [ip]" ) [/code]
[QUOTE=Lolm4te;45614782]- snip - I see another problem, you have [lua]ply:SendLua("LocalPlayer():ConCommand(connect [The IP])")[/lua] It is suppose to be [lua] ply:SendLua("LocalPlayer():ConCommand("connect", "youriphere")") [/lua] If that doesn't work, try this: [lua] ply:SendLua("LocalPlayer():RunConsoleCommand("connect", "youriphere")") [/lua] But if that fails, removethe ply:SendLua and try above again.[/QUOTE] I already tried RunConsoleCommand and it doesn't work (I tested it with and without a comma, both generated errors before the player even used /servers) Also that's not a mistake, concommand doesn't need commas, it's clearly stated here: [url]http://wiki.garrysmod.com/page/Global/RunConsoleCommand[/url]
Yes, concommand does infact need commas. You linked me to ply:RunConsoleCommand, not ply:concommand which are two different things. (Both of them need commas however)
[QUOTE=HumbleTH;45615016]I think Willox has some workaround to blocked commands on his profile. [code] LocalPlayer():ConCommand( string.rep( "\n", 1024 ) .. " connect [ip]" ) [/code][/QUOTE] It worked!! Thanks a lot man :) Now I just need help with the pointshop thing. I really didn't get how I find the weapon slot he's using and strip it ._.
That exploit definitely doesn't work any more :v: The secret behind your success is that connect is not a blocked command when ran from the client.
[QUOTE=Willox;45615212]That exploit definitely doesn't work any more :v: The secret behind your success is that connect is not a blocked command when ran from the client.[/QUOTE] Well either way it's working and I'm happy about it :P
Sorry, you need to Log In to post a reply to this thread.