Yet another problem with my MOTD, but this time it's concerning tabs.
7 replies, posted
Yeah, I know I already posted a question concerning my MOTD today, but I've encountered yet another problem.
See, I managed to solve the issue I had, but it was just a plain gray derma menu with some text. So, I wanted to add some tabs, and this is where my issues started showing up...
I tried taking the text I already had, and making it into a tab, but it doesn't work the way I want it.
Here's the original MOTD, the one that worked:
[lua]local motd = {
"",
"",
"Welcome to the server! This server runs: ChromaScript 1.0",
"",
"[ Rules ]",
"- No prop surfing",
"- No prop spamming",
"- No metagaming (Metagaming = Using OOC information IC)",
"- No powergaming (Powergaming = Forcing your actions upon another player)",
"- No door hogging (Door hogging = Owning all the doors on the map)",
"- Play nicely, and respect your fellow roleplayers.",
"",
"[ Commands ]",
"F1 - Open this menu",
"F2 - Undecided",
"F3 - Undecided",
"F4 - Undecided",
"",
"/ooc or // - Speak out of character",
"/looc or .// - Speak out of character locally",
"/me - Perform an action, ex: /me picks up a flashlight",
"/y - Yell in-character",
"/w - Whisper in-character",
"",
"[ Notes ]",
"This is a serious RP server! If you are new to RP,",
"then feel free to contact an admin and he/she will tell you",
"the basics of it, and how you too can become a good RPer.",
"",
"Have fun!",
}
function ChromaMotd( ply, cmd, args )
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50, 50 )
DermaPanel:SetSize( 700, 700 )
DermaPanel:SetTitle( "ChromaScript - MOTD" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:SetBackgroundBlur( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
local Text = {}
local pos = 5
for k, v in pairs( motd ) do
Text[k] = vgui.Create( "DLabel", DermaPanel )
Text[k]:SetFont( "coolvetica" )
Text[k]:SetText( v )
Text[k]:SetPos( 5, pos )
Text[k]:SizeToContents()
pos = pos+10
end
end
concommand.Add( "chroma_motd", ChromaMotd )[/lua]
And here's the one with the tabs, the one that I'm trying to make work:
[lua]local motd = {
"",
"",
"Welcome to the server! This server runs: ChromaScript 1.0",
"",
"[ Rules ]",
"- No prop surfing",
"- No prop spamming",
"- No metagaming (Metagaming = Using OOC information IC)",
"- No powergaming (Powergaming = Forcing your actions upon another player)",
"- No door hogging (Door hogging = Owning all the doors on the map)",
"- Play nicely, and respect your fellow roleplayers.",
"",
"[ Commands ]",
"F1 - Open this menu",
"F2 - Undecided",
"F3 - Undecided",
"F4 - Undecided",
"",
"/ooc or // - Speak out of character",
"/looc or .// - Speak out of character locally",
"/me - Perform an action, ex: /me picks up a flashlight",
"/y - Yell in-character",
"/w - Whisper in-character",
"",
"[ Notes ]",
"This is a serious RP server! If you are new to RP,",
"then feel free to contact an admin and he/she will tell you",
"the basics of it, and how you too can become a good RPer.",
"",
"Have fun!",
}
function ChromaMotd( ply, cmd, args )
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50, 50 )
DermaPanel:SetSize( 700, 700 )
DermaPanel:SetTitle( "ChromaScript - MOTD" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:SetBackgroundBlur( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
local PropertySheet = vgui.Create( "DPropertySheet" )
PropertySheet:SetParent( DermaPanel )
PropertySheet:SetPos( 5, 30 )
PropertySheet:SetSize( 500, 500 )
local SheetItemOne = vgui.Create( "DLabel", DermaPanel )
for k, v in pairs( motd ) do
SheetItemOne:SetFont( "coolvetica" )
SheetItemOne:SetText( v )
SheetItemOne:SetPos( 5, pos )
SheetItemOne:SizeToContents()
local SheetItemTwo = vgui.Create( "DCheckBoxLabel" )
SheetItemTwo:SetText( "Use SENTs?" )
SheetItemTwo:SetConVar( "some_convar" )
SheetItemTwo:SetValue( 1 )
SheetItemTwo:SizeToContents()
PropertySheet:AddSheet( "MOTD", SheetItemOne, "gui/silkicons/user", false, false, "The server MOTD" )
PropertySheet:AddSheet( "Credits", SheetItemTwo, "gui/silkicons/group", false, false, "The people who made this possible" )
local Text = {}
local pos = 5
pos = pos+10
end
end
concommand.Add( "chroma_motd", ChromaMotd )[/lua]
I've tried experimenting with it, but now it just keeps spamming tabs rather than adding any text at all...
Any help would be appreciated, and sorry for this silly question. I'm still learning.
Your ending the for k,v in pairs(motd) too late.You ended it after PropterySheet:AddSheet which makes it add the same sheet for the amount of stuff in motd
cut the code
pos = pos+10
end
and paste it after
SheetItemTwo:SizeToContents()
so it looks like this
local SheetItemOne = vgui.Create( "DLabel", DermaPanel )
for k, v in pairs( motd ) do
SheetItemOne:SetFont( "coolvetica" )
SheetItemOne:SetText( v )
SheetItemOne:SetPos( 5, pos )
SheetItemOne:SizeToContents()
pos = pos+10
end
oh and I forgot
put for k,v in pairs(motd) above
local SheetItemOne = vgui.Create( "DLabel", DermaPanel )
also change
PropertySheet:AddSheet( "MOTD", SheetItemOne, "gui/silkicons/user", false, false, "The server MOTD" )
to
PropertySheet:AddSheet( "MOTD", DermaPanel, "gui/silkicons/user", false, false, "The server MOTD" )
Hey, thanks for the help, but after I did that the menu showed up blank, and the tabs weren't visible.
It also gave me this error:
[lua][gamemodes\chromascript\gamemode\motd_menu.lua:67] attempt to perform arithmetic on global 'pos' (a nil value)[/lua]
You haven't defined pos anywhere.
[QUOTE=Freze;26223632]You haven't defined pos anywhere.[/QUOTE]
I thought I had?
[lua] local pos = 5
pos = pos+10[/lua]
[QUOTE=iRzilla;26225068]Post your FULL script. So we can see an accurate line number.[/QUOTE]
[lua]--[[
ChromaScript - Made For Roleplayers, By Roleplayers!
Developed By Jocken
]]--
local motd = {
"",
"",
"Welcome to the server! This server runs: ChromaScript 1.0",
"",
"[ Rules ]",
"- No prop surfing",
"- No prop spamming",
"- No metagaming (Metagaming = Using OOC information IC)",
"- No powergaming (Powergaming = Forcing your actions upon another player)",
"- No door hogging (Door hogging = Owning all the doors on the map)",
"- Play nicely, and respect your fellow roleplayers.",
"",
"[ Commands ]",
"F1 - Open this menu",
"F2 - Undecided",
"F3 - Undecided",
"F4 - Undecided",
"",
"/ooc or // - Speak out of character",
"/looc or .// - Speak out of character locally",
"/me - Perform an action, ex: /me picks up a flashlight",
"/y - Yell in-character",
"/w - Whisper in-character",
"",
"[ Notes ]",
"This is a serious RP server! If you are new to RP,",
"then feel free to contact an admin and he/she will tell you",
"the basics of it, and how you too can become a good RPer.",
"",
"Have fun!",
}
function ChromaMotd( ply, cmd, args )
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50, 50 )
DermaPanel:SetSize( 700, 700 )
DermaPanel:SetTitle( "ChromaScript - MOTD" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:SetBackgroundBlur( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
local PropertySheet = vgui.Create( "DPropertySheet" )
PropertySheet:SetParent( DermaPanel )
PropertySheet:SetPos( 5, 30 )
PropertySheet:SetSize( 500, 500 )
for k, v in pairs( motd ) do
local SheetItemOne = vgui.Create( "DLabel", DermaPanel )
SheetItemOne:SetFont( "coolvetica" )
SheetItemOne:SetText( v )
SheetItemOne:SetPos( 5, pos )
SheetItemOne:SizeToContents()
pos = pos+10
end
local SheetItemTwo = vgui.Create( "DCheckBoxLabel" )
SheetItemTwo:SetText( "Use SENTs?" )
SheetItemTwo:SetConVar( "some_convar" )
SheetItemTwo:SetValue( 1 )
SheetItemTwo:SizeToContents()
PropertySheet:AddSheet( "MOTD", DermaPanel, "gui/silkicons/user", false, false, "The server MOTD" )
PropertySheet:AddSheet( "Credits", SheetItemTwo, "gui/silkicons/group", false, false, "The people who made this possible" )
local Text = {}
local pos = 5
end
concommand.Add( "chroma_motd", ChromaMotd )[/lua]
Sorry, you need to Log In to post a reply to this thread.