Okay, I know this is pretty failure… But I am beginning a small project that may end up be too hard for me, but anyways… I have a major problem I’m not sure how to fix. I want a button to be made once when a player joins and never be removed till he leaves the server. I have it on the event “HUDPaint” which is not smart because it causes me to lose 50 fps at the least, going down to about 4 fps. If you require the code I will paste it, just don’t feel it necessary at the moment.

HUDPaint is a client side function. It is also called every frame, so you are creating a button every frame.

Use this for when to spawn the button: http://wiki.garrysmod.com/?title=Gamemode.PlayerInitialSpawn

And this for when to remove it: http://wiki.garrysmod.com/?title=Gamemode.PlayerDisconnected

Yah, I realized that it was doing it every frame. Thanks for answering what I wanted! :slight_smile:


Oh wait, I just remembered that is a server side event. How can I run this hook when this lua is all derma?

With “User Messages”

I don’t really get this, can you give me an example please?

I have this code and I don’t know how to implement user messages.

function ClientReport()
ClientPanel = vgui.Create( “DFrame” )
ClientPanel:SetSize( 300, 400 )
ClientPanel:SetPos( (ScrW()/2) - 150, (ScrH()/2) - 200 )
ClientPanel:ShowCloseButton( true )
ClientPanel:SetTitle( “Client -> Admin Report” )
ClientPanel:SetDraggable( true )
ClientPanel:SetVisible( false )

local ChatboxX, ChatBoxY = chat.GetChatBoxPos()
ClientButton = vgui.Create( "DButton" )
ClientButton:SetPos( 25, ScrH()*0.827 )
ClientButton:SetSize( 50, 20 )
ClientButton:SetText( "Report" )
ClientButton.DoClick = function()
	ClientPanel:SetVisible( true )

ClientChat = vgui.Create( "DTextEntry", ClientPanel )
ClientChat:SetPos( 10, 25 )
ClientChat:SetSize( 280, 330 )
ClientChat:SetEditable( false )
ClientChat:SetEnterAllowed( false )
ClientChat:SetMultiline( true )

ClientEnter = vgui.Create( "DTextEntry", ClientPanel )
ClientEnter:SetPos( 10, 365 )
ClientEnter:SetSize( 280, 25 )
ClientEnter:SetEnterAllowed( true )
ClientEnter:SetEditable( true )
ClientEnter:SetMultiline( false )
ClientEnter.OnEnter = function()
	ClientChat:SetValue( ClientChat:GetValue() .. LocalPlayer():GetName().. ": " .. ClientEnter:GetValue() .. "

" )
ClientEnter:SetValue( “” )

in client
[lua] usermessage.Hook( “ClientReportOrSomething”, ClientReport ) [/lua]
in server
umsg.Start( “ClientReportOrSomething” );


In PlayerInitialSpawn hook, I’m guessing. For usermessages, you have to read data in the same order you send it. Use datastream for sending clientdata to the server (which I doubt you’ll need, though, just sayin’ :3 )

But what do I do in the middle of the start and end?

Oh, and by doing this, I’m assuming I will no longer be able to test this on servers without Script Enforcer.

Nothing unless you want to send data, Server -> Client.

[lua] umsg.Start(“ClientReportOrSomething”);

umsg.String( “My string” ); --Sends a string.

umsg.End(); [/lua]

You then would need to add a data agrument to the client function receiving the umsg to read the data.

–Reads teh string!1!1!
print( "String: "…data:ReadString() )

[/lua] For example.

function ClientReport()
function ClientReport(data)

You put nothing between start and end since you only want the function to run.
And no, you won’t be to run this unless the server has the script to.

[editline]21st February 2011[/editline]


^ Hahaha.

okay, then last question. I realized that there is no function for DTextEntry:SetValue according to http://wiki.garrysmod.com/?title=DTextEntry Methods… Can somebody help me with that?


JUUUUUST KIDDINGGGGG - I derped and didn’t check the bottom for some reason. I looked over it like 10 times though. O.o