It pops up to give the user an option to enter their ID but I need it to only show the very first time they’ve ever joined the server only, yet I can’t figure out that command. I’m currently using “if first_spawn then” but it pops up every time I rejoin the server, which isn’t the idea here.
Sorry I didn’t explain it very well, it saves to the DB fine, it’s just he menu pops up every time I join the server again as first_spawn is for just that, the first time they spawn into the server. Now I need it to pop up on the very first time they join the server only (the time when it creates their ID in the database), then if they relog, it doesn’t pop up again, I simply don’t know the if statement for that to happen.
if playerID in database then
-- they already joined
else
-- first time
end
This is the gist of what needs to be done, obviously I can’t tell you exactly how to do it (too little information).
To get if a player is in the DB, just run a simple query (e.g. select) with their ID (or whatever your primary key is) and see if it returns anything, if it doesn’t they don’t exist yet.
This is what I’ve got so far, to give you a bit more info.
AddEventHandler(“vRP:playerSpawn”, function(user_id, source, first_spawn)
Debug.pbegin(“playerSpawned_player_state”)
local player = source
local data = vRP.getUserDataTable(user_id)
if first_spawn then
if user_id ~= nil then
vRP.openMenu(source,{cityhall_menu},function()
end
There are additional lines hence the lack of ends, though they aren’t relating to what I’m talking about so I’ve left them out.
Um… Ok? I mean… I’ve given you some information to help you figure out how to implement it, are you wanting me to write it for you to? Because I’m not… I don’t believe in spoon-feeding people code just so they can copy-paste it… I don’t think anyone learns anything that way…
I’m not going to dive into your code (you don’t even have it on Github) just to figure out what this does so, I’ll ask you. What does this return when the player isn’t in the database? Does it return nil or an empty table? If so, you can check that.
Also, I suggested that you move the checking to the server (since you can execute DB queries on here) so, do that (I’m saying this because this looks like it’s client-side code).
is the only statement I need to change to make this work, there are servers which when you first login, you will out a “passport” type feature, this runs only on the initial connection, I need someone who uses something similar to that to let me know what the initial connection if statement is. I’ll do the rest.