[Help] vRP - Trying to create a spawn ID system



So I’m 99% done with this for my next release to my pack ([vRP Framework]-[Dunko Edited V6.2 - FX Server] UPDATED 10/11/2017 - Supports 12 languages) but I’ve come across one issue that is driving me insane.

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.

I look forward to your responses.



Store it on the server? And, if you want it to persist through the server being restarted, store it (either in a file or, using a DB).


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.


Well, it would be something along the lines of

if playerID in database then
    -- they already joined
    -- first time

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)
local player = source
local data = vRP.getUserDataTable(user_id)
if first_spawn then
if user_id ~= nil then

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).


Sorry I believe I’ve overcomplicated this.

if first_spawn then

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.


Do what @Havoc said before.

-- Database check for user joining server

if  user found in database then
   -- do nothing
    -- show registration
    -- add to database