Message when player joins

Message appears in the middle of the screen when player joins.

I wanted to know if there is a way to when a player joins the server a big message pops in the middle of the screen saying something or welcome I don’t know I just need to find a way to how to make when someone joins appears a big message with a text with text like the one I made on photoshop.

When they join the server they will start dead/unspawned and when they press Close to play they will spawn.

I still learning lua, I just need help with the basics like, Spawn dead, Opens when soemoen joins the server and the Close button so the Welcome message will close when they press it.

It doesnt really need the logo part but if you want you can add it.

  1. We won’t make the code for you.
  2. You might find these useful:

Player:Kill,

GM/PlayerInitialSpawn, http://wiki.garrysmod.com/page/Category:Panel, http://wiki.garrysmod.com/page/Category:DLabel, http://wiki.garrysmod.com/page/Category:DButton,

surface.SetDrawColor and

surface.DrawRect.

[editline]asdasdsad[/editline]
You’ll also need

draw.SimpleText

I know how to make the DButton, the surface, DLabel and stuff I just don’t know how to start, what comes first like the one to start dead and to open when someone joins.

I know its not part of the thread but you from Brazil ?

You’ll have to do this:

  1. Serverside, use the hook to see when the player spawns
  2. Kill the player and in some way prevent spawning until the button is pressed
  3. Send a message through the net library
  4. Clientside, upon receiving the message, create the panel, add the DLabels and the DButton and use the <element>:Paint function to decorate stuff
  5. When the button is pressed, remove the panel and send a net message to the server
  6. Serverside, remove the block on spawning and spawn the player

(yes, I’m from Brazil)

And I didn’t want you to make the code for me just to tell me how to start it.

For a player to spawn dead you might wanna look at player:KillSilent() (or just :Kill() if better). Use the PlayerInitialSpawn to do this kill. Use a InitPostEntity hook client side to open the panel with text, and make the button send a net message to the server, which then spawns the player.

Thats why I need help I just started coding I don’t know how to make Serverside stuff, Do I create a new file or I just use a (server) function, How to make the prevent spawning until they press the button, send message through net library and send a net message to the server because the rest I know.

( You the first person from Brazil I’ve ever saw in the facepunch forums in the garrys mod section after me :P)

Good idea, better than using a net message on PlayerInitialSpawn to open the menu.

[editline]13th February 2016[/editline]

The file structure I recommend you to use is something like this:



<addon folder>
    |
    |_ lua
         |\_ autorun
         |        \_ sh_joinscreen.lua
         \_ joinscreen
                       |_ cl_menu.lua
                        \_ sv_killing.lua


(+1 for perfect ascii art? :v:)

In sh_<addon name>.lua you’d do something like this to load the files on their respective realms:
[lua]
if SERVER then
AddCSLuaFile(‘joinscreen/cl_menu.lua’)
include(‘joinscreen/sv_killing.lua’)
else
include(‘joinscreen/cl_menu.lua’)
end
[/lua]

On the cl_menu.lua you’d use the InitPostEntity hook and then use the Derma controls to create the said screen and button

On the sv_killing.lua you’d use the PlayerInitialSpawn hook to kill the player and prevent them from spawning (overwriting the ply:Spawn() function might be an option, but wouldn’t work out very well).

Do I need to restart my game everytime to reload the code or when I save it will appears automaticly ( I will test it first on singleplayer, or do I need to do directly in the server?)

In the sh_<addon name>.lua is the sh.joinscreen.lua you did on the file structure right ?

(Nice file structure explanation)

Ok So I made everything but, What do I make so when someone press the button it closes the panel and make the player respawn and my panel didn’t open but i can move only press ESC and stuff.



button.DoClick = function()
    somepanel:Close()
end


?

Yeah so i was right about closing the panel, but I still need help about when they press the button they spawn too

I am guessing you didn’t do panel:MakePopup()? This is what lets the player use their mouse on the panel

send a net message from the client -> server, then from there kill the player or whatever you want to do

So u want an MOTD??? Im sure you could find a basic one somewhere or Host a website make it in HTML and them Upload it to a MOTD like FancyMOTD on scriptfodder and it will display clearly when they first join

I did its like I can’t like move my cam and stuff like that my mouse doesnt appear too only when I press ESC it appears

[editline]14th February 2016[/editline]

Lol no I don’t want a motd

[editline]14th February 2016[/editline]


 util.AddNetworkString('joinscreen_spawn')
 
hook.Add('PlayerInitialSpawn', 'JoinScreen', function( ply )
    ply:KillSilent()
end)
 
local spawned = {}
net.Receive('joinscreen_spawn', function( len, ply )
    if not spawned[ply] then
        ply:Spawn()
        spawned[ply] = true
    end
end)

   

I tested that on singleplayer ( thats on a sv_ file)

you just posted a PIC of what a cheap MOTD would look like…

Man I just said I don’t want a motd… thats not a pic of a motd, I did that on photoshop, if you here to say " Oh so you just posted a motd" or “Oh thats a motd” don’t bother yourself replying the thread because I don’t want a motd I clearly said what I wanted and I know what a motd is…

Dont think you understand my point… I was saying you can easily just ask for an MOTD that can do this and have it custom made in the jobs section of scriptfodder.

Man I not just doing that to make it and put on my server but to learn more about lua. And I know thats not too difficult to pay for it.