How do I change a players Nick to a RP name? I have it where when you first join, a menu comes up telling you to choose a RP name. I have two text fields, one for First name and one for Last name. How do I set the players name to the value of those two fields?
Using networked variables.
Make a console command that is run on the client after they enter in the name and click submit.
On the server you can have the command do something like:
And then can get the values clientside.
Ok. Also, how can I have more than one arg in a concommand?
Ok, I can’t get it to work. Here is my serverside code:
[lua]function SetRPName( pl, First, Last )
pl:SetNWString( “FirstName”, First )
pl:SetNWString( “LastName”, Last )
concommand.Add( “skyrp_nc”, First, Last )[/lua]
And here is the submit button code:
[lua] local Submit = vgui.Create( “DButton”, InfoPanel )
Submit:SetPos( 80, 30 )
Submit:SetSize( 100, 20 )
Submit:SetText( “Next Stop - Model” )
Submit.DoClick = function()
FirstName = FName:GetValue()
LastName = LName:GetValue()
RunConsoleCommand( “skyrp_nc”, FirstName, LastName )[/lua]
When I hit the button, it prints: Unknown Command: ‘skyrp_nc’
That should be this:
[lua]function SetRPName( pl, cmd, args)
pl:SetNWString( “FirstName”, args )
pl:SetNWString( “LastName”, args )
concommand.Add( “skyrp_nc”, SetRPName )[/lua]
the syntax for concommands is, function SetRPName(pl,cmd,args)
and use args, args.
Oh, I never knew that. Thanks, it works. See, you learn something new everyday. Thanks again.