RP Name on first join Pdata help.

Hello guys.

I have created this code that should change your RP name if I coded it properly :slight_smile:

THIS IS IN CL_INIT.LUA (Correct me if I’m wrong. I still have problems understanding the whole client/server thing in a lua sense…

[LUA] function RPName()
local DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 40, 250 )
DermaPanel:SetTitle( “Please choose an appropriate Roleplay Name (ie: John Smith, Mary Simpson etc” ) // Name of Frame
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( false ) //Can the player drag the frame /True/False
DermaPanel:ShowCloseButton( false ) //Show the X (Close button) /True/False
DermaPanel:MakePopup() end

local DermaButton = vgui.Create( “DButton” )
DermaButton:SetParent( DermaPanel ) // Set parent to our “DermaPanel”
DermaButton:SetText( “Submit!” )
DermaButton:SetPos( 25, 300 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function ()
LocalPlayer():ConCommand("say /rpname " … tostring(DermaText:GetValue())) end

local DermaText = vgui.Create(“DTextEntry”, DermaPanel )
DermaText:SetPos( 20,25 )
DermaText:SetTall( 20 )
DermaText:SetWide( 250 )
DermaText:SetEnterAllowed( false )
DermaPanel:SetVisible( false )
end
usermessage.Hook( “rpnamebox”, RPName )[/LUA]

Problem is I need this to only show up if the player hasn’t joined the server. Someone in another thread suggest I use Pdata variables but I have never used them before. So basically I need this

  • When player hits submit RP name button it sets the pdata variable to 1.
  • On PlayerInitialSpawn it needs to check if that has been set to 1. If not then open the RP name derma.

Assuming this is darkrp, you don’t need PData necessarily for this to work. You can simply check if their Steam name is equal to their RPName, and if not, give them the popup. I forget what the DarkRP steam name function is, you can probably find it in player.lua or somewhere.

Serverside, just hook to PlayerInitialSpawn and check if the two names are equal. If not, send the “rpnamebox” usermessage.

The only problem about this is that, there are people who troll. Anyone can easily change their steam name to their rp name, which would result in your menu popping up.

A better way I would say to do this would be a clientside convar no one would think of resetting or changing.

lol, why is that his problem? If they want to be trolls and set their RPName to their steamname, the server suffers no ill effects… they just get irritated when they join the server.

I think I like the simpler way of doing it. They can change there name with a different letter or something if they want that steam name ;V

I believe you’re looking for something like this:

[lua]
hook.Add( “PlayerInitialSpawn”, “I’m not good with names”, function( ply )

if ply:GetPData( "rpnamecheck" ) != "1" then

	umsg.Start( "rpnamebox", ply )
	umsg.End()

	ply:SetPData( "rpnamecheck", 1 )

end

end )
[/lua]