Hello,
On my build server we have 3 factions, namely XPDF, FRN and FBN to help make it a bit more fun. I was wondering if anyone could script a pop-up menu on your first visit to the server, which allows you to select a faction (changes your server rank to a certain rank, and your playermodel too.) or select no faction and stay as a guest as it gets difficult asking every individual player if they want to be in a faction. I guess you could say this is RP'ing.. but it's only to make the server a little more fun :smile:
If anyone could do this for me, i'd be extremely thankful and i'll put you in the server credits. :smile:
Just make a Derma menu and in the gamemode file put [lua]function GM:PlayerInitialSpawn( ply ) [/lua]
I havnt tested it but it might work. Ill update it when I do test it.
Go into your server and go to gamemodes, then go to sandbox, then go to gamemode, then find the files cl_init.lua, init.lua, and shared.lua.
In cl_init.lua add this code at the bottom.
[lua]function factionchoice()
facname = vgui.Create("DFrame")
facname:SetSize(191, 150)
facname:Center()
facname:SetTitle("Choose your faction")
facname:MakePopup()
xpdfpan = vgui.Create("DPanel")
xpdfpan:SetParent(facname)
xpdfpan:SetSize(92, 60)
xpdfpan:SetPos(2, 25)
roflmao = vgui.Create("DButton")
roflmao:SetParent(xpdfpan)
roflmao:SetSize(84, 53)
roflmao:SetPos(4, 3)
roflmao:SetText("XPDF")
roflmao.DoClick = function()
RunConsoleCommand("TeamSet_XPDF")
end
frnnnn = vgui.Create("DPanel")
frnnnn:SetParent(facname)
frnnnn:SetSize(92, 60)
frnnnn:SetPos(96, 25)
frnb = vgui.Create("DButton")
frnb:SetParent(frnnnn)
frnb:SetSize(84, 53)
frnb:SetPos(4, 3)
frnb:SetText("FRN")
frnb.DoClick = function()
RunConsoleCommand("TeamSet_FRN")
end
fbnnn = vgui.Create("DPanel")
fbnnn:SetParent(facname)
fbnnn:SetSize(186, 60)
fbnnn:SetPos(2, 88)
fbnb = vgui.Create("DButton")
fbnb:SetParent(fbnnn)
fbnb:SetSize(177, 52)
fbnb:SetPos(4, 4)
fbnb:SetText("FBN")
fbnb.DoClick = function()
RunConsoleCommand("TeamSet_FBN")
end
end
concommand.Add("team_choice", factionchoice)[/lua]
in shared.lua add this
[lua]
team.SetUp (1, "XPDF", Color (0, 0, 255, 255))
team.SetUp (2, "FRN", Color (255, 0, 0, 255))
team.SetUp (3, "GFBN", Color (128, 0, 128, 255))[/lua]
and in init.lua add this
[lua]
function GM:PlayerInitialSpawn( ply )
RunConsoleCommand("team_choice")
end
function xpdf()
ply:SetTeam( 1 )
ply:SetModel( "/* model path here */")
end
function FRN()
ply:SetTeam( 2 )
ply:SetModel( "/* model path here */")
end
function FBN()
ply:SetTeam( 3 )
ply:SetModel( "/* model path here */")
end
concommand.Add("TeamSet_XPDF", xpdf)
concommand.Add("TeamSet_FRN", FRN)
concommand.Add("TeamSet_FBN", FBN)
[/lua]
It [u][b]should[/b][/u] work, although it is untested.
[QUOTE=c-unit;26044033]:words:[/QUOTE]
Beat me to it. :P
[editline]13th November 2010[/editline]
/hijack
Is there a way to prompt a user to change their name using the same method? Just with DTextEntry?
no, setinfo got broken or something I tried it the other day and it didn't work. IF it did you could use this:
clientside
[lua]
nameframe = vgui.Create('DFrame')
nameframe:SetSize(343, 66)
nameframe:Center()
nameframe:SetTitle('Please change your name!')
nameframe:MakePopup()
namelab = vgui.Create('DLabel')
namelab:SetParent(nameframe)
namelab:SetPos(1, 29)
namelab:SetText('New Name:')
namelab:SizeToContents()
nametext = vgui.Create('DTextEntry')
nametext:SetParent(nameframe)
nametext:SetSize(282, 20)
nametext:SetPos(58, 26)
nametext.OnEnter = function()
RunConsoleCommand("setinfo", "name", nametext:GetValue())
end
namelab2 = vgui.Create('DLabel')
namelab2:SetParent(nameframe)
namelab2:SetPos(31, 49)
namelab2:SetText('An administrator has prompted you to change your name!')
namelab2:SizeToContents()[/lua]
I believe that is correct. Line 18 may be wrong though.
I'm also guessing you know how to set up that derma into a function with a concommand. Also, be sure to make sure only admins can run the console command rofl..
Woah. THANKS c-unit! I'll test this as soon as possible. :smile:
[QUOTE=Xenoyia v2;26044812]Woah. THANKS c-unit! I'll test this as soon as possible. :smile:[/QUOTE]
np =)
Hmm.. I put the code in, but nothing shows when I join the server. Is there anything else I have to do? :v:
[QUOTE=Xenoyia v2;26044992]Hmm.. I put the code in, but nothing shows when I join the server. Is there anything else I have to do? :v:[/QUOTE]
Did you restart your server? Did you make sure there are the returns in the code. Did you get any console errors?
C-unit how do I make it admin only? I suck at admin things.
[QUOTE=Mr.Macintosh;26045026]Did you restart your server? Did you make sure there are the returns in the code. Did you get any console errors?[/QUOTE]
Just the usual GMod spam I get on my server. And yes, I did a full restart.
What are returns?
[QUOTE=Xenoyia v2;26045033]Just the usual GMod spam I get on my server. And yes, I did a full restart.
What are returns?[/QUOTE]
I meant like things like [lua] function something
local something [/lua]
Aren't touching and are spaced correctly.
This is the console log if anyone can spot an error out: [url]http://pastebin.com/qAFtBs3W[/url]
[editline]14th November 2010[/editline]
[QUOTE=Mr.Macintosh;26045072]I meant like things like [lua] function something
local something [/lua]
Aren't touching and are spaced correctly.[/QUOTE]
Nothing is touching. I'm hoping I put the code snippets in the right place though, I put the first one at the very end of cl_init.lua, the second one near the top and the third one in the middle.
Xen, check the server log for errors not your game client.
Would you mind pasting your whole cl_init, init, and shared for us?
not at all.
cl_init.lua [url]http://pastebin.com/YzsXtkSS[/url]
shared.lua [url]http://pastebin.com/DgsVg1xi[/url]
init.lua [url]http://pastebin.com/mznnEnyf[/url]
[editline]14th November 2010[/editline]
[QUOTE=c-unit;26045278]Xen, check the server log for errors not your game client.[/QUOTE]
My server log only logs text, removed props, admin commands and spawned props for some reason, nothing special :frown:
Post it please.
[editline]13th November 2010[/editline]
Oh god heres Cubar, with his CUNIT IS WRONG.
[QUOTE=c-unit;26045420]Post it please.
[editline]13th November 2010[/editline]
Oh god heres Cubar, with his CUNIT IS WRONG.[/QUOTE]
Again how do I make the command admin only?
if ply:IsAdmin() then
[QUOTE=c-unit;26045420]Post it please.
[editline]13th November 2010[/editline]
Oh god heres Cubar, with his CUNIT IS WRONG.[/QUOTE]
Alrighty, here's the logs from the last server restart: [url]http://pastebin.com/1p22jThj[/url]
well it's not really that simple. I'm pretty sure you have to use arguments for making the local player run the console command to bring up the derma.
[editline]13th November 2010[/editline]
[QUOTE=Xenoyia v2;26045507]Alrighty, here's the logs from the last server restart: [url]http://pastebin.com/1p22jThj[/url][/QUOTE]
Can you please add a password to the server so no one joins for a couple minutes, then restart it and show me the logs then. I can't see shit with all the people interacting.
[11/14/10 04:01:16] == Started in map 'gm_flatgrass' and gamemode 'Sandbox' ==
is all it says
Why not just add it like this:
[lua]
function GM:PlayerInitialSpawn( ply ) --"When the player first joins the server and spawns" function
RunConsoleCommand( "your menu name here" ) --Run the console command when the player first spawns
end
[/lua]
I think that's what you mean?
You do not use RunConsoleCommand on the server to run something on a client, you only want the command to run on one player, you use ply:ConCommand()
Yeah, exactly.
Sorry, you need to Log In to post a reply to this thread.