Hello everybody, I'm working on my RolePlay gamemode who is called 24RP and I have a problem with a code.
So I want to edit a table in-game, I have a table who is called "CasierJudis" with one table per player in it.
For example : in "CasierJudis" we have one table which is called "John", one other "Jack" etc...
and I want to add a new table in the table CasierJudis.
This is my code for the table and the function :
[lua]CasierJudis = {
John = {
name = "John",
time = os.date(),
other = "Test 01"
},
Jack = {
name = "Jack",
time = os.date(),
other = "Test02"
}
}
function AddDetective()
CasierJudis2 = {
John2 = {
name = "John2",
time = os.date(),
other = "Test 03"
},
Jack2 = {
name = "Jack2",
time = os.date(),
other = "Test 03"
}
}
table.Add(CasierJudis, CasierJudis2)
end[/lua]
(CasierJudis is the main table and, in this table, I have one table per player with their name...I want to add in "CasierJudis" the table content in "CasierJudis2" the table called
"CasierJudis2". So if I enable the function AddDetective in-game, "CasierJudis" have to be modified.
(I hope my explanations are clear, I'm french, sorry for my english))
Can you explain to me what's wrong in my code, why it doesn't work ?
This is my panel code :
[lua]function CasierMenu()
local CasierMenu = vgui.Create('DFrame')
CasierMenu:SetSize(350, 326)
CasierMenu:Center()
CasierMenu:SetTitle('Casiers Judiciaires')
CasierMenu:SetSizable(false)
CasierMenu:MakePopup()
CasierMenu:SetSkin("24RP")
local sheet = vgui.Create("DPropertySheet")
sheet:SetParent(CasierMenu)
sheet:SetPos(5,25)
sheet:SetSize(330, 296)
sheet:SetSkin("24RP")
local InfoList = vgui.Create("DPanelList")
InfoList:SetSize(350, 326)
InfoList:SetSpacing( 5 )
InfoList:EnableHorizontal( false )
InfoList:EnableVerticalScrollbar( true )
for k, v in pairs( CasierJudis ) do
local info = CasierJudis[ k ]
local TargetName = vgui.Create("DCollapsibleCategory", InfoList)
TargetName:SetPos( 25,50 )
TargetName:SetSize( 200, 50 )
TargetName:SetExpanded( 0 )
TargetName:SetLabel( info.name )
CategoryList = vgui.Create( "DPanelList" )
CategoryList:SetAutoSize( true )
CategoryList:SetSpacing( 5 )
CategoryList:EnableHorizontal( false )
CategoryList:EnableVerticalScrollbar( true )
TargetName:SetContents( CategoryList )
local TargetRead = vgui.Create( "DLabel" )
TargetRead:SetText( info.time )
TargetRead:SizeToContents()
CategoryList:AddItem( TargetRead )
local TargetOther = vgui.Create( "DLabel" )
TargetOther:SetText( info.other )
TargetOther:SizeToContents()
CategoryList:AddItem( TargetOther )
InfoList:AddItem(TargetName)
end
sheet:AddSheet( "Casiers Judiciaires", InfoList, "gui/silkicons/user", false, false, "Casiers" )
end
usermessage.Hook("CasierMenu", CasierMenu)[/lua]
(I hope my explanations are clear, I'm french, sorry for my english))
Thank you very much for the next answers.
Have a good day.
Baker27.
Use table.insert
Sorry, you need to Log In to post a reply to this thread.