• Help with Derma Stuff
    12 replies, posted
Pic: [img]http://img682.imageshack.us/img682/5469/mayoropstionsderma.jpg[/img] [lua] local W,H = 400, 400 local MOPanelL function AddApp( Text ) local MOApp = vgui.Create('DPanel') MOApp:SetPos( 1, 1 ) MOApp:SetSize( W - 2, 60 ) local MOLabel = vgui.Create('DLabel', MOApp) MOLabel:SetPos( 10, 10 ) MOLabel:SetSize( W - 20, 40 ) MOLabel:SetText(Text) MOPanelL:AddItem(MOApp) local MOAccept = vgui.Create('DButton', MOApp) MOAccept:SetPos( MOApp:GetWide() - 51, MOApp:GetTall() - 42 ) MOAccept:SetSize( 50, 20 ) MOAccept:SetText('Accept') MOAccept.DoClick = function() MOApp:Remove() for k,v in pairs(player.GetByUniqueID()) do end end local MODecline = vgui.Create('DButton', MOApp) MODecline:SetPos( MOApp:GetWide() - 51, MOApp:GetTall() - 21 ) MODecline:SetSize( 50, 20 ) MODecline:SetText('Decline') end function MayorOptions() local MOFrame = vgui.Create('DFrame') MOFrame:SetPos(ScrW() * .5 - W * .5, ScrH() * .5 - H * .5) MOFrame:SetSize( 400, 400 ) MOFrame:MakePopup() MOFrame:SetTitle('Mayor Options') MOFrame.Paint = function() surface.SetDrawColor( 0,0,0,125 ) surface.DrawRect( 0, 0, MOFrame:GetWide(), MOFrame:GetTall() ) end MOPanelL = vgui.Create('DPanelList', MOFrame) MOPanelL:SetPos( 1, 25 ) MOPanelL:SetSpacing( 2 ) MOPanelL:EnableHorizontal( false ) MOPanelL:EnableVerticalScrollbar( true ) MOPanelL:SetSize( W - 2, H - 26 ) MOPanelL.Paint = function() surface.SetDrawColor( 125, 125, 125, 125 ) surface.DrawRect( 0, 0, MOPanelL:GetWide(), MOPanelL:GetTall() ) end // Below this line is all stuff that will be on a different menu when i get this all figured out. local MOFrame1 = vgui.Create('DFrame') MOFrame1:SetPos(ScrW() * .8 - W * .5, ScrH() * .5 - H * .5) MOFrame1:SetSize( 400, 400 ) MOFrame1:MakePopup() MOFrame1:SetTitle('TESTING') MOFrame1.Paint = function() surface.SetDrawColor( 0,0,0,125 ) surface.DrawRect( 0, 0, MOFrame1:GetWide(), MOFrame1:GetTall() ) end local MOPanel1 = vgui.Create('DPanel', MOFrame1) MOPanel1:SetPos( 1, 25 ) MOPanel1:SetSize( W - 2, H - 26 ) MOPanel1.Paint = function() surface.SetDrawColor( 125, 125, 125, 125 ) surface.DrawRect( 0, 0, MOPanel1:GetWide(), MOPanel1:GetTall() ) end local MOEntry = vgui.Create('DTextEntry', MOPanel1) MOEntry:SetPos( 10, 40 ) MOEntry:SetSize( 100, 20 ) local MOButton = vgui.Create('DButton', MOPanel1) MOButton:SetPos( 10, 60 ) MOButton:SetSize( 50, 25 ) MOButton:SetText('Confirm') MOButton.DoClick = function() for k,v in pairs(player.GetAll()) do AddApp("" .. v:Nick() .. "'s reason for unemployment:\nI need unemployment because " .. MOEntry:GetValue() .. "") end end end concommand.Add('pgrp_test', MayorOptions) [/lua] So basically when someone signs up for unemployment they type in there reason that must be accepted by the mayor. My problem is that when you close the Mayor Options frame and reopen it, it doesn't save those reasons. The frame is blank. So how would I make it so that every time you open that frame it loads the reasons. Also I am confused on how I would run a console command on the player that the mayor accepted. Any help is appreciated. I just noticed I put this in the wrong place. Don't ban me plox just move it.
Have them send the unemployment reason to the server via concommand, and then add that reason to a table, and when the derma panel is opened, have the server send the data to the client via datastream
To the wiki!
Unless you don't have character restriction on your fields you should probably be fine with usermessages. To send a console command from the client use RunConsoleCommand. And just a note, if there's something you can't find in the wiki (or is not clear enough) please do mention it on the stickied documentation thread on the Lua Scripting forum so we can improve it! :smile:
Giving me a dumb is stupid. I gave him a quick suggestion.
[QUOTE=Skapocalypse;18208609]Giving me a dumb is stupid. I gave him a quick suggestion.[/QUOTE] You mind a dumb here, on Facepunch? For all you know maybe some 12 years old kid gave you one just to see if you would get angry. These ratings mean nothing and you really should ignore them.. and definitely not post based on the ratings you receive. :ninja:
I assumed it was you :3 and also, the reason I say datastream is for tables (Not sure if usermessages do that lol) The only reason for that is, what if they mayor leaves, or changes jobs, etc. Then the new mayor wouldn't have received those usermessages. Unless you send them to everyone. *shrug*
[QUOTE=Skapocalypse;18208891]I assumed it was you :3 and also, the reason I say datastream is for tables (Not sure if usermessages do that lol) The only reason for that is, what if they mayor leaves, or changes jobs, etc. Then the new mayor wouldn't have received those usermessages. Unless you send them to everyone. *shrug*[/QUOTE] Oh that makes sense. And I would've rated myself dumb? :v:
[QUOTE=Crazy Quebec;18208544]Unless you don't have character restriction on your fields you should probably be fine with usermessages. To send a console command from the client use RunConsoleCommand. And just a note, if there's something you can't find in the wiki (or is not clear enough) please do mention it on the stickied documentation thread on the Lua Scripting forum so we can improve it! :smile:[/QUOTE] RunConsoleCommand would run the command on the mayor. I need it to run the command on who is accepted for unemployment.
[QUOTE=Skapocalypse;18207856]Have them send the unemployment reason to the server via concommand, and then add that reason to a table, and when the derma panel is opened, have the server send the data to the client via datastream[/QUOTE] If the data needed to be sent can be sent via a concommand it can be sent back using usermessages, datastream isn't a good idea if you don't really need it.
But by sending the data each time someone goes unemployed to every player would be less efficient than datastreaming a table only when the mayor opens the window. Edit: Thanks for the new avatar admins? :D
[QUOTE=Skapocalypse;18215086]But by sending the data each time someone goes unemployed to every player would be less efficient than datastreaming a table only when the mayor opens the window. Edit: Thanks for the new avatar admins? :D[/QUOTE] I hope you realize that datastream works off of usermessages and concommands anyways. It's only a utility function of which it's main purpose was to send tables. And what do you mean by sending it to every player? Usermessages can go to only one player at a time you know.
Oh sorry, I had no idea :P Do what Nori said then. Sorry if I put you in the wrong direction D=
Sorry, you need to Log In to post a reply to this thread.