General > Developers Corner
DListView
Bite That Apple:
It slightly, worked. Hopefully, I can understand this more later. Though, I ended up changing a few things, and as you said, it was untested, and I wasn't expecting you to give such a great detailed example. Though, server side disliked this code:
--- Code: ---// Server Side Menu
function ISaid( ply, saywhat )
local name = ply:Nick()
if string.find(saywhat, "!tdm") == 1 then
umsg.Start( "MyMenu", ply )
umsg.String(ply:Nick())
umsg.End()
/*
local GetPlayers = player.GetAll()
for k,v in pairs(GetPlayers) do
if v:IsValid() then
local GetScore4File = file.Read("TDM/GoalLimit/GoalLimit.txt")
v:SetPData("TDM_Total_Score_Ok", GetScore4File)
umsg.Start("PlaceScoreForMenu")
umsg.Short(k)
umsg.Short(GetScore4File)
umsg.End()
end
end
*/
end
end
hook.Add( "PlayerSay", "ISaid", ISaid );
function MyMenu( ply )
umsg.Start( "MyMenu", ply )
umsg.String(ply:Nick())
umsg.End()
/*
local GetPlayers = player.GetAll()
for k,v in pairs(GetPlayers) do
if v:IsValid() then
local GetScore4File = file.Read("TDM/GoalLimit/GoalLimit.txt")
v:SetPData("TDM_Total_Score_Ok", GetScore4File)
umsg.Start("PlaceScoreForMenu")
umsg.Short(k)
umsg.Short(GetScore4File)
umsg.End()
end
end
*/
end
hook.Add("ShowTeam", "MyHook", MyMenu)
/*
function MyShopMenu( ply )
umsg.Start( "ShowShopMenuXP", ply )
umsg.End()
end
hook.Add("ShowHelp", "MyShopMenu", MyShopMenu)
*/
function tdm_help_message( ply )
umsg.Start( "TDM_HELP_CONSOLE", ply )
umsg.End()
end
concommand.Add( "tdm_help_message", tdm_help_message )
--- End code ---
Bite That Apple:
Alright, I'm going to have to dig up some old threads. Though, this is important to me now. I've been remaking my gamemode from scratch again, and I created all the commands and such, but now I kinda want to make the menu act like xgui. Basically, what I'm requesting is that when you press F2 (is possible), it opens my menu, and when you press F2 again, it goes away. Can you explain this in the best way you can do Sticky?
I believe the code to do that would be like this
--- Code: ---hook.Add("ShowTeam", "MyHook", MyMenu)
--- End code ---
Bite That Apple:
Alright, so I found out how to do everything.. except update like as in when a player joins it would update the listing. Any suggestions?
Stickly Man!:
How XGUI does the show/hide menu window is just to call :show() and :hide() on the base frame. You can then use isVisible() to check whether or not it's opened and closed.
I can't remember what the hook is for player joins, but the easiest way would be to create a "refresh" function- it would first clear the list of stuff then readd things based on available information. Have the player join and player leave hooks call that refresh button, and it should keep your information up-to-date.
Bite That Apple:
Fantastic, thank you sir. Everything works, I basically followed what you said, I had to jimmy-rig some things here and there, but still works like how I want it to work. Though, now I have two questions.
For a DListView, is it possible to have it select a line, like as in when you open the menu, it already has a selected line selected, via listingID?
Secondly, how does one get a listing of all the current models in the server? Because I'm pretty sure it's possible?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version