checking if player joined first time

I only have one idea in mind how to check if a player has joined the server or spawned in it for the first time, but its complicated.

I imagined creating a file for each player and check when a file is created, if the player had a file made for him he will get a certain menu popup, if he had it popup once already he wont see the menu popup or maybe a different menu. I seriously dont know how to do that though,

maybe there is some other method?

Make a

GM:PlayerInitialSpawn hook and check if they have any

Player:SetPData. If they don’t then set a value and send a net message to the client to open the menu.

[editline]16th September 2017[/editline]

hook.Add("PlayerInitialSpawn", "JoinedBefore", function(ply)
	if !(ply:GetPData("JoinedBefore", false)) then
		ply:SetPData("JoinedBefore", true)
		-- first time joiner
		-- do stuff here
		-- joined before
		-- do other stuff here

do I receive “OpenMenu” on the client side or “JoinedBefore” ?

Txike I’m pretty sure you made a mistake though, you’re telling it to set to True when it’s already set to True. I’m pretty sure you intended to move that a few lines up.

That’s entirely up to you but I’d suggest doing it on the client because the vgui library doesn’t exist in the server realm.

[editline]16th September 2017[/editline]

I don’t need to move anything, I just missed a not operator.

well I failed to do it right off the batch, I made an addon folder:

net.Receive ("RegisterMenuOpen" , function()
	local ply = net.ReadEntity()
	chat.AddText( ply, Color(255,255,255,255), "is not registered.")
end )



hook.Add("PlayerInitialSpawn", "JoinedBefore", function(ply)
    if (ply:GetPData("JoinedBefore", false)) then
     ply:SetPData("JoinedBefore", false) --so I can test it again after reloading

any clue what i do wrong?

I can see 3 things wrong.

You call ReadEntity clientside, but never wrote an entity serverside.

[editline]16th September 2017[/editline]

Also, your if-statement conditions should be reversed.

i assume I can remove it completely since it calls the player in the function anyway?

You’d need to call LocalPlayer, but you don’t need to put the player object in chat.AddText anyway so it’d be pointless.

Actually I still think there’s something wrong with it txike

Didn’t even notice that else statement. :disappoint:

Don’t worry bro got your back

This should literally be copy and paste for you MGFear, I wrote basically everything you need on the serverside, on the clientside net.Receive( “MGF_PopupMenu” ) and do some Derma magic

util.AddNetworkString( "MGF_PopupMenuOnClient" )

hook.Add( "PlayerInitialSpawn", "MGF_JoinedBefore", function( ply )
	if not ply:GetPData( "MGF_JoinedBefore", false ) then
		net.Start( "MGF_PopupMenuOnClient" )
		net.Send( ply )
		ply:SetPData( "MGF_JoinedBefore", true )
end )

[editline]17th September 2017[/editline]

Garry’s Mod should automatically store if the player has joined before and should have a function for it but we don’t so we need to do it this way I guess

This is not how people learn!!! Don’t be a spoonfeeder!!!

Calm your tits man, it’s relatively simple and he might understand how to do it now. It’s not like I wrote the entirety of VCMod and spoonfed it. Plus there is a good part on the clientside missing which I won’t even bother with.

thanks alot you are very helpful!