Hello,
I have a small derma panel
function CasierAdmin()
FrameCasier = vgui.Create( "DFrame" )
FrameCasier:MoveTo( ScrW()/2.5, ScrH()/2.5, 0.5, 0, -1)
FrameCasier:SetSize( 300, 300 )
FrameCasier:SetTitle( "Casier administratif" )
FrameCasier:SetDraggable( false )
FrameCasier:ShowCloseButton( true )
FrameCasier:MakePopup()
FrameCasier.Paint = function()
draw.RoundedBox( 0, 0, 0, FrameCasier:GetWide(), FrameCasier:GetTall(), Color( 99, 147, 226, 150 ) )
end
local DComboBoxPlayer = vgui.Create( "DComboBox", FrameCasier )
DComboBoxPlayer:SetPos( 5, 25 )
DComboBoxPlayer:SetSize( 290, 20 )
DComboBoxPlayer:SetValue( "Joueurs" )
for k,v in pairs(player.GetAll()) do
DComboBoxPlayer:AddChoice( v:Nick() )
end
local InfractionList = vgui.Create( "DListView", FrameCasier )
InfractionList:SetPos( 5, 50 )
InfractionList:SetSize( 290, 240 )
InfractionList:SetMultiSelect( false )
InfractionList:AddColumn( "Infraction" )
for k,v in pairs(player.GetAll()) do
if v:Nick() == DComboBoxPlayer:GetSelected() then
//Code here
end
end
//InfractionList:AddLine( "PesterChum" )
//InfractionList:AddLine( "Lumitorch" )
//InfractionList:AddLine( "Troj-on" )
end
I want to read data from a file who will be registered in data folder.
Each player have a file with they SteamID and inside of the file there are somes line of text that i want to put in my DListView
I have searched but i have found only outdated function or sheet of code
for k,v in pairs(player.GetAll()) do
if v:Nick() == DComboBoxPlayer:GetSelected() then
//Code here
end
end
This is executing once.
You need to call it after every selection.
Also, you can change line upper to:
for k,v in pairs(player.GetAll()) do
DComboBoxPlayer:AddChoice(v:Nick(),v)
end
and then
DComboBoxPlayer.OnSelect = function( panel, index, value )
print(value) -- Player Entity
end
Okay thanks you, and do you know how i can read line from a data file ?
What data file is? Table, JSON, SQL, String?
Huummm... i don't know how it's called but it's file like that:
https://files.facepunch.com/forum/upload/157326/392204cf-cb7b-4e09-9148-e62846dc14ce/Screenshot_45.png
For each line i want to have a new line in the DListView
Ok. Your type: \n style
You need to convert text to table.
To do that use: string.Explode with \n separator
After convertation use for loop with pairs
Ok thanks you very much, now it's work perfectly
I have do it with another separator that i will never use in my string and that's work
Or you can use JSON functions
Sorry, you need to Log In to post a reply to this thread.