• How to lua console log
    25 replies, posted
How do I put a console log in lua? (so it prints information to console)
You mean like print("Hello") ?
Serverside: [CODE] //Usage print( stringhere ) //Example print( "This message is printed in the server console")[/CODE] Example output in the console would be: This message is printed in the server console Anyway this stuff is very basic, are you sure you need to ask on facepunch for an answer?! Assuming this is what you wanted to know, if not, you need to re-word your question! EDIT: It's so basic it's something I can answer! :P Lol
[QUOTE=ms333;45598963]You mean like print("Hello") ?[/QUOTE] Well I want it print information about this code; [CODE]if SERVER then AddCSLuaFile() else local function donator() local frame = vgui.Create( "DFrame" ) frame:SetSize( 1001, 560 ) frame:SetTitle( "Donator features!" ) frame:SetVisible( true ) frame:SetDraggable( true ) frame:Center( true ) function frame:Paint() Derma_DrawBackgroundBlur(self) // Makes the derma panel rounded. draw.RoundedBox( 2, 0, 0, frame:GetWide(), frame:GetTall(), Color(0, 0, 0, 200) ) // Header Color. draw.RoundedBox( 2, 0, 0, frame:GetWide(), 23, Color(0,140,191,200) ) end frame:MakePopup() HTMLTest = vgui.Create("HTML", frame) HTMLTest:Dock( FILL ) HTMLTest:SetPos(50,50) HTMLTest:SetSize(ScrW() - 100, ScrH() - 100) HTMLTest:OpenURL("http://i.imgur.com/4FeLqeZ.png") end concommand.Add("DonatorFeatures", donator) hook.Add( "OnPlayerChat", "DonatorFeatures", function( ply, text ) if ( text == "!donatorfeatures" ) then RunConsoleCommand( "DonatorFeatures" ) end end ) end[/CODE] Because it works but only when alone on the server (if alive) or dead (if people are online) so I want to know where it's gone wrong since no one can/will help me with it ><.
What is it, that you're trying to print exactly?
[QUOTE=ms333;45598980]What is it, that you're trying to print exactly?[/QUOTE] Information about the coding I put above. Like I want it to tell me nay errors when the code is done in game (since it's a command !donatorfeatures).
It will automatically tell you the errors, but only if there is any.
In that case I'm really confused. Since I don't get any errors but it doesn't work. Like it works when no one else is on the server but when people join it doesn't work for anyone unless they are dead. ><
There's no need to make it into a console command when it's all in the same file and realm. [lua] if SERVER then AddCSLuaFile() else hook.Add( "OnPlayerChat", "DonatorFeatures", function( ply, text ) if ply == LocalPlayer() && text == "!donatorfeatures" then local frame = vgui.Create( "DFrame" ) frame:SetSize( 1001, 560 ) frame:SetTitle( "Donator features!" ) frame:SetVisible( true ) frame:SetDraggable( true ) frame:Center( true ) frame.Paint = function(panel, w, h) Derma_DrawBackgroundBlur(panel) // Makes the derma panel rounded. draw.RoundedBox( 2, 0, 0, w, h, Color(0, 0, 0, 200) ) // Header Color. draw.RoundedBox( 2, 0, 0, w, 23, Color(0,140,191,200) ) end frame:MakePopup() local HTMLTest = vgui.Create("HTML", frame) HTMLTest:Dock( FILL ) HTMLTest:SetPos(50,50) HTMLTest:SetSize(ScrW() - 100, ScrH() - 100) HTMLTest:OpenURL("http://i.imgur.com/4FeLqeZ.png") end end) end [/lua]
[QUOTE=Ganoal;45599039]In that case I'm really confused. Since I don't get any errors but it doesn't work. Like it works when no one else is on the server but when people join it doesn't work for anyone unless they are dead. ><[/QUOTE] Check if the ply argument of OnPlayerChat is equal to LocalPlayer()
[QUOTE=ms333;45599112]There's no need to make it into a console command when it's all in the same file and realm. [lua] if SERVER then AddCSLuaFile() else hook.Add( "OnPlayerChat", "DonatorFeatures", function( ply, text ) if ply == LocalPlayer() && text == "!donatorfeatures" then local frame = vgui.Create( "DFrame" ) frame:SetSize( 1001, 560 ) frame:SetTitle( "Donator features!" ) frame:SetVisible( true ) frame:SetDraggable( true ) frame:Center( true ) frame.Paint = function(panel, w, h) Derma_DrawBackgroundBlur(panel) // Makes the derma panel rounded. draw.RoundedBox( 2, 0, 0, w, h, Color(0, 0, 0, 200) ) // Header Color. draw.RoundedBox( 2, 0, 0, w, 23, Color(0,140,191,200) ) end frame:MakePopup() local HTMLTest = vgui.Create("HTML", frame) HTMLTest:Dock( FILL ) HTMLTest:SetPos(50,50) HTMLTest:SetSize(ScrW() - 100, ScrH() - 100) HTMLTest:OpenURL("http://i.imgur.com/4FeLqeZ.png") end end) end [/lua][/QUOTE] Doesn't work :\ [editline]5th August 2014[/editline] [QUOTE=HumbleTH;45599119]Check if the ply argument of OnPlayerChat is equal to LocalPlayer()[/QUOTE] Where's LocalPlayer?
What exactly are you trying to do?
[QUOTE=Lolm4te;45599329]What exactly are you trying to do?[/QUOTE] I want this [CODE]if SERVER then AddCSLuaFile() else local function donator() local frame = vgui.Create( "DFrame" ) frame:SetSize( 1001, 560 ) frame:SetTitle( "Donator features!" ) frame:SetVisible( true ) frame:SetDraggable( true ) frame:Center( true ) function frame:Paint() Derma_DrawBackgroundBlur(self) // Makes the derma panel rounded. draw.RoundedBox( 2, 0, 0, frame:GetWide(), frame:GetTall(), Color(0, 0, 0, 200) ) // Header Color. draw.RoundedBox( 2, 0, 0, frame:GetWide(), 23, Color(0,140,191,200) ) end frame:MakePopup() HTMLTest = vgui.Create("HTML", frame) HTMLTest:Dock( FILL ) HTMLTest:SetPos(50,50) HTMLTest:SetSize(ScrW() - 100, ScrH() - 100) HTMLTest:OpenURL("http://i.imgur.com/4FeLqeZ.png") end concommand.Add("DonatorFeatures", donator) hook.Add( "OnPlayerChat", "DonatorFeatures", function( ply, text ) if ( text == "!donatorfeatures" ) then RunConsoleCommand( "DonatorFeatures" ) end end ) end[/CODE] to work when people are alive and not dead (works when alone in server when alive too)
[CODE] hook.Add( "OnPlayerChat", "DonatorFeatures", function( ply, text ) if text == "!donatorfeatures" and ply == LocalPlayer() then RunConsoleCommand( "DonatorFeatures" ) end end ) end[/CODE]
[lua] hook.Add( "OnPlayerChat", "DonatorFeatures", function( ply, text ) if text == "!donatorfeatures" and ply == LocalPlayer() and ply:IsAlive() then RunConsoleCommand( "DonatorFeatures" ) end end ) end [/lua]
[QUOTE=HumbleTH;45599439][CODE] hook.Add( "OnPlayerChat", "DonatorFeatures", function( ply, text ) if text == "!donatorfeatures" and ply == LocalPlayer() then RunConsoleCommand( "DonatorFeatures" ) end end ) end[/CODE][/QUOTE] Doesn't work :\
The code I posted works just fine. [t]http://i.imgur.com/0lONixH.jpg[/t]
Mouse spasmed out and I posted this. Dunno how to remove a comment .-.
[QUOTE=ms333;45599777]The code I posted works just fine. [t]http://i.imgur.com/0lONixH.jpg[/t][/QUOTE] I'm putting mine in addons folder, should I put this somewhere else for it to work? Because it isn't working as an addon. [editline]5th August 2014[/editline] [IMG]http://i.imgur.com/4uY0KCs.jpg[/IMG]
[QUOTE=Ganoal;45599818]I'm putting mine in addons folder, should I put this somewhere else for it to work? Because it isn't working as an addon. [editline]5th August 2014[/editline] [IMG]http://i.imgur.com/4uY0KCs.jpg[/IMG][/QUOTE] It should be !donatorfeatures If you looked at the code you would have known that
Just put it in lua/autorun
[QUOTE=JasonMan34;45599881]It should be !donatorfeatures If you looked at the code you would have known that[/QUOTE] There's two which are basically the same, they just open different websites (images) and have a different command. (!donatorfeatures and !donatorinfo) Sorry I didn't state that, my bad. [editline]5th August 2014[/editline] [QUOTE=ms333;45599896]Just put it in lua/autorun[/QUOTE] Wouldn't addons/donatorperks/lua/autorun do the same thing? ><
[QUOTE=Ganoal;45599912]Wouldn't addons/donatorperks/lua/autorun do the same thing? ><[/QUOTE] Yes it would be the same. Regarding your "two doing basically the same", don't. You're the one messing things up here. Several people have provided you with working code for your request. [editline]5th August 2014[/editline] We can't really help when you provide us with a code you aren't even using.
[QUOTE=ms333;45599964]Yes it would be the same. Regarding your "two doing basically the same", don't. You're the one messing things up here. Several people have provided you with working code for your request. [editline]5th August 2014[/editline] We can't really help when you provide us with a code you aren't even using.[/QUOTE] I was, but now I'm using your exact code since it's doing the exactly same thing regardless just with a different url (an updated version of the image). Proof here; [IMG]http://i.imgur.com/KZm3DsX.png[/IMG]
So that's the only command you have now, or do you still have a !donatorinfo as well? Also, have you restarted? It does work fine, also with multiple players.
[QUOTE=ms333;45600033]So that's the only command you have now, or do you still have a !donatorinfo as well? Also, have you restarted? It does work fine, also with multiple players.[/QUOTE] It isn't the only one and I've tried it without !donatorinfo too (it's a seperate file) I've restarted. It doesn't for me ><.
Sorry, you need to Log In to post a reply to this thread.