[Help] How to get the connected player for the first time?

Hello guys,

I’m doing a script that will get the player logged for the first time on the server and open a menu in which he will be able to change his appearance. This is when the player is connected for the first time.
I want to know what is the event to get the player connected for the first time in the server ?

PS : Sorry for my bad english.

Cordially,
DeadOps

You need to keep track of this yourself in some way, you can save users to a database or a file and add them once they connect. If they are already there do nothing but if they aren’t you can trigger anything you’d like.

I understand. I think i have to get the player in database when he spawn for the first time on the map and if is not in database I have to display the menu. I think this is a way to do this ? Are you agree ?

Cordially,
DeadOps

Here’s an example:

		local executed_query = MySQL:executeQuery("SELECT identifier FROM modelmenu WHERE identifier = '@name'", {['@name'] = target.identifier})
		local result = MySQL:getResults(executed_query, {'identifier'}, "identifier")

		if(result[1] == nil) then
			local executed_query2 = MySQL:executeQuery("INSERT INTO modelmenu(identifier) VALUES ('@name')",{['@name']= target.identifier})
			TriggerClientEvent("mm:firstspawn", source)

Thank you man.
I’m trying to do something like this :slight_smile:

Cordially,
DeadOps

Why would you need to store this in a database? Are you trying to keep track of when they join the server for the very first time (since the server was created) or, just the first time they join the server?

If the latter then you could literally just have a boolean on the client, when the player spawns check if it’s true… If not, then they’ve just connected…

bool firstConnect = true
AddEventHandler("playerSpawn", function(spawn)
    if firstConnect then
        -- Do stuff to player who's just connected.. This is their "first" time spawning
       firstConnect = false
    end
end)
2 Likes

Thank you for your script but…
I built the same script and it does not work because it requires a database that allows me to know who is connected for the first time. It is impossible to do this without a database. Once the player is connected for the first time on the server, I want to open a menu where you can change appearance.

Cordially,
DeadOps

I don’t reccomend this as this is a synchronous mysql call which pauses the server and causes player instancing

This work really nice :slight_smile:
Thank you man !

Cordially,
DeadOps

Hello man,
I have to ask you a question.
It is possible to change the character exacly like the gta 5 online.
For example when I’m connected on my server for the first time and i want to choose my face.
Can we choose eyebrow, skin color like this picture : http://cdn.gta5cheats.com/wp-content/uploads/2015/11/char3.jpg

Cordially,
DeadOps

How can I close this function?