Using PData with derma.

So I know you can’t use PData clientside, so what I need to do is find a way to use my functions on the client. So here’s a function I created, ( and this is also the function I want to call on the client, through derma. )

[lua]
function PMeta:GetUsername()
local data = tostring( self:GetPData(“Username”) );

if ( data == nil ) then
ErrorNoHalt( "SOVIET - PMeta:GetUsername was called, but failed due to the field being nil.
" )
else
return data
end
end
[/lua]

And basically I need a way to call that function through a derma button, but I’m pretty sure I can’t call it directly because it has something to do with PData inside of it, how can I call it through my menu? A quick response would be great, thanks!

Here’s how I would need to call it,

[lua]
function Initial_Menu()

if ( !GetUsername() == nil ) then – How would I call getusername here?
Initial_Menu = vgui.Create( “DFrame” )
Initial_Menu:SetPos( 50,50 )
Initial_Menu:SetSize( 1000, 900 )
Initial_Menu:SetTitle( “Soviet: Initial Creation” )
Initial_Menu:SetVisible( true )
Initial_Menu::SetBackgroundBlur( true )
Initial_Menu:SetDraggable( true )
Initial_Menu:ShowCloseButton( true )
Initial_Menu:MakePopup()
else
end
end
[/lua]

you can use COOKIE_S clientside

[editline]12:35AM[/editline]

use a USER_MESSAGE

[editline]12:35AM[/editline]

Not the question, and I can’t use cookies, I need to use PData, this is for a roleplay gamemode and you can edit cookies easily, aka making money, names etc. hackable. I need a way to use PData, could I use concommands.

[editline]12:36AM[/editline]

oh thats what you want make the client run a command to change their name

Well, no but I need to be able to get and set the PData fields.

Also can you give me an example with umsg? I’ve never really used it, surprisingly.

Read the wiki, it’s quite clear.

**[Umsg

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Umsg)**

This the easiest most safest way your most likely gonna get. PData also saves in the format sql lite. Which is okay but I personally hate it.