0% found this document useful (0 votes)
51 views19 pages

FiveM ConnectQueue Configuration Guide

This document defines functions for a virtual roleplay (vRP) system. It initializes vRP and tvRP interfaces, defines functions for getting user IDs, banning/unbanning players, and managing user data stored in memory and a MongoDB database. It also includes code for tracking server uptime and saving modified user data to the database.

Uploaded by

Salam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views19 pages

FiveM ConnectQueue Configuration Guide

This document defines functions for a virtual roleplay (vRP) system. It initializes vRP and tvRP interfaces, defines functions for getting user IDs, banning/unbanning players, and managing user data stored in memory and a MongoDB database. It also includes code for tracking server uptime and saving modified user data to the database.

Uploaded by

Salam
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

local Proxy = module("lib/Proxy")

local Tunnel = module("lib/Tunnel")


local config = module("cfg/base")

local whitelistUsers = [Link](LoadResourceFile("vrp", "[Link]")) or


{}

vRP = {}
[Link]("vRP",vRP)

tvRP = {}
[Link]("vRP",tvRP)

vRPclient = [Link]("vRP","vRP")

[Link] = {}
[Link] = {}
vRP.user_tables = {}
vRP.user_tmp_tables = {}
vRP.user_sources = {}

local hoursPlayed, lastHours, hoursInt = {}, {}, {}

[Link](function()
local uptimeMinute, uptimeHour = 0, 0
while true do
[Link](1000 * 60)
uptimeMinute = uptimeMinute + 1

if uptimeMinute == 60 then
uptimeMinute = 0
uptimeHour = uptimeHour + 1
end

ExecuteCommand([Link]("sets UpTime \"%02dh %02dm\"", uptimeHour,


uptimeMinute))
end
end)

function [Link](ids, cbr)


local function cbrWrapper(result)
if #result > 0 then
cbr(result[1].id, result[1])
else
cbr(nil)
end
end

if #ids > 0 then


local found = false
for _, identify in ipairs(ids) do
if [Link](identify, "license:") or [Link](identify,
"license2:") then
if not found then
[Link]:fetch('SELECT * FROM users WHERE accountLicense =
@accountLicense', {
['@accountLicense'] = identify
}, cbrWrapper)
found = true
end
end
end
else
cbr(nil) -- no ids, return nil
end
end

[Link](1000)

if not found then


[Link]:findOne({collection = "users", options = {sort = {id =
-1}, projection = {id = 1}}}, function(success, result)
if success then
local nextId = 1

if #result > 0 then


nextId = result[1].id + 1
end

local validIds = nil


for _, v in pairs(ids) do
if [Link](v, "license:") then
validIds = v
break
end
end

if validIds then
[Link]:insertOne({collection = "users", document =
{id = nextId, accountLicense = validIds, lastHours = 0.0, hoursPlayed = 0.0,
userJob = "Somer"}}, function(success)
if success then
task({nextId, {}})
end
end)
else
task({-1})
end
end
end)
end
end
end

function [Link](player)
return GetPlayerEndpoint(player) or "[Link]"
end

function [Link](player)
return GetPlayerName(player) or "Necunoscut"
end

function [Link](amount)
local left,num,right = [Link](tostring(amount),'^([^%d]*%d)(%d*)(.-)$')
return left..(num:reverse():gsub('(%d%d%d)','%1.'):reverse())..right
end

function [Link](user_id, text, type)


local logData = {
user_id = user_id,
text = text,
type = type,
time = [Link]()
}

[Link]:insertOne({collection = "userHistory", document = logData})


end

function [Link](user_id, cbr)


local task = Task(cbr, {false, {}})
[Link]:findOne({collection = "users", query = {id = user_id}, options =
{ projection = {_id = 0, userBans = 1} }}, function(success, rows)
if #rows > 0 then
local userBans = rows[1].userBans or {isBanned = false}

task({[Link], userBans})
else
task()
end
end)
end

function [Link](player, reason)


local user_id = [Link](player)
if user_id == 3 or user_id == 4 then
TriggerClientEvent('chatMessage', player, "^5FP-SYSTEM: ^7 Trebuia sa primesti
kick, motiv: \n"..reason)
else
DropPlayer(player, reason)
end
end

function [Link](admin, user_id, banDays, banReason, dreptPlata)


local target_src = [Link](user_id)
local chatString = "^8Ban: Adminul %s l-a banat pe %s (%d) timp de %s zile,
motiv: %s"
local adminTag = "FP-Guard"
local adminSrc = false
admin = parseInt(admin)

if (dreptPlata == nil) then


dreptPlata = true
end

if admin ~= 0 then
adminSrc = [Link](admin)
end

if adminSrc then
adminTag = (GetPlayerName(adminSrc) or "Necunoscut").. " ("..admin..")"
elseif admin ~= 0 then
local username = [Link]:findOne({collection = "users", query = {id =
admin}, options = { projection = {_id = 0, username = 1} }})
adminTag = ([Link] or "Necunoscut").. " ("..admin..")"
end

if banDays == -1 then
if target_src then
[Link](-1, {[Link](chatString, adminTag,
GetPlayerName(target_src) or "Necunoscut", user_id, 'permanent', banReason)})
else
local username = [Link]:findOne({collection = "users", query = {id =
user_id}, options = {projection = {_id = 0, username = 1}}})
local player_name = [Link] or "Necunoscut"

[Link](-1, {[Link](chatString, adminTag, player_name, user_id,


'permanent', banReason)})
end

local banData = {
isBanned = true,
expire = -1,
expireDate = 'never',
bannedDate = [Link]("%d/%m/%Y %H:%M"),
bannedBy = adminTag,
banReason = banReason,
banDate = [Link](),
dreptPlata = dreptPlata,
banDays = 'permanent',
}

[Link]:updateOne({collection = "users", query = {id = user_id}, update


= {
["$set"] = {userBans = banData}
}})

[Link]:update({collection = "userTokens", query = {user_id = user_id},


update = {['$set'] = {banned = true}}})

if target_src then
[Link](target_src, 'Ai fost banat pe server!\nMotiv: '..banReason)
end
else
local banTime = tonumber([Link]() + ((banDays or 1)*24*60*60))
if target_src then
[Link](-1, {[Link](chatString, adminTag,
GetPlayerName(target_src) or "Necunoscut", user_id, banDays, banReason)})
else
local username = [Link]:findOne({collection = "users", query = {id =
user_id}, options = {projection = {_id = 0, username = 1}}})
local player_name = [Link] or "Necunoscut"

[Link](-1, {[Link](chatString, adminTag, player_name, user_id,


banDays, banReason)})
end

local banData = {
isBanned = true,
expire = banTime,
expireDate = [Link]("%d/%m/%Y %H:%M", banTime),
bannedDate = [Link]("%d/%m/%Y %H:%M"),
bannedBy = adminTag,
banReason = banReason,
banDate = [Link](),
dreptPlata = dreptPlata,
banDays = banDays,
}

[Link]:updateOne({collection = "users", query = {id = user_id}, update


= {
["$set"] = {userBans = banData}
}})

[Link]:update({collection = "userTokens", query = {user_id = user_id},


update = {['$set'] = {banned = true}}})

if target_src then
[Link](target_src, 'Ai fost banat pe server!\nMotiv: '..banReason)
end
end
end

-- De modificat functia asta.


function [Link](admin, user_id)
local target_src = [Link](user_id)
local theDate = [Link]("%d/%m/%Y %H:%M")
local adminTag = "Consola"
local adminSrc = false

if admin ~= 0 then
adminSrc = [Link](admin)
end

if adminSrc then
adminTag = (GetPlayerName(adminSrc) or "Necunoscut").. " ("..admin..")"
elseif admin ~= 0 then
local username = [Link]:findOne({collection = "users", query = {id =
admin}, options = { projection = {_id = 0, username = 1} }})
adminTag = ([Link] or "Necunoscut").. " ("..admin..")"
end

[Link](-1, {"^8Unban: Adminul "..adminTag.." i-a dat unban la ID


"..user_id})

[Link]:updateOne({collection = "users", query = {id = user_id}, update =


{["$unset"] = {userBans = 1}}})

[Link]:update({collection = "userTokens", query = {user_id = user_id},


update = {['$set'] = {banned = false}}})
end

local userDatas = {}
local userDatasModified = {}

function [Link](user_id,key,value)
if not userDatas[user_id] then
userDatas[user_id] = {}
end

if not userDatasModified[user_id] then


userDatasModified[user_id] = {}
end

userDatasModified[user_id][key] = true
userDatas[user_id][key] = value
end

function [Link](user_id, key, cbr)


local task = Task(cbr, {""}, 120000)

if tostring(user_id) and tostring(key) then


if userDatas[user_id] ~= nil then
if userDatas[user_id][key] then
task({userDatas[user_id][key]})
else
task()
end
else
[Link]:find({collection = "uData", query = {user_id =
user_id}, options = {projection = {dkey = 1, _id = 0, dvalue = 1}}},
function(success, result)
if type(result) == "table" then
userDatas[user_id] = {}
for _, udata in pairs(result) do
userDatas[user_id][[Link]] = [Link]
end
if userDatas[user_id][key] then
task({userDatas[user_id][key]})
else
task()
end
end
end)
end
else
task()
end
end

function saveUDataInDb(user_id)
if userDatas[user_id] then
for key, _ in pairs(userDatasModified[user_id] or {}) do
[Link](500)
local value = userDatas[user_id][key]
[Link]:updateOne({collection = "uData", query = {user_id = user_id,
dkey = key}, update = {['$set'] = {user_id = user_id, dkey = key, dvalue = value}},
options = {upsert = 1}})
end
end
userDatas[user_id] = nil
userDatasModified[user_id] = nil
end

function task_save_oneUser(user_id)
[Link](user_id, "vRP:datatable", [Link](vRP.user_tables[user_id]))
end
[Link] = task_save_oneUser

local saveHourNum = 0

function task_save_datatables()
TriggerEvent("vRP:save")

for k,v in pairs(vRP.user_tables) do


[Link](k, "vRP:datatable", [Link](v))
if saveHourNum == 4 then
saveHoursPlayed(k)
end
end

if saveHourNum == 4 then
saveHourNum = 0
else
saveHourNum = saveHourNum + 1
end

SetTimeout(60000, task_save_datatables)
end
task_save_datatables()

function [Link](key,value)
[Link]:updateOne({collection = "sData", query = {dkey = key}, update =
{['$set'] = {dkey = key, dvalue = value}}, options = {upsert = 1}})
end

function [Link](key, cbr)


local task = Task(cbr,{""})

[Link]:findOne({collection = "sData", query = {dkey = key}},


function(success, result)
if #result > 0 then
task({result[1].dvalue})
else
task()
end
end)
end

function [Link](user_id, cbr)


local task = Task(cbr, {false})
task({whitelistUsers[tostring(user_id)] or false})
end

function [Link](user_id,whitelisted)
whitelistUsers[tostring(user_id)] = true
SaveResourceFile("vrp", "[Link]", [Link](whitelistUsers), -1)
ExecuteCommand("loadwhitelist")
end

function [Link](user_id, cbr)


local task = Task(cbr,{""})
[Link]:findOne({collection = "users", query = {id = user_id}, options =
{
projection = {_id = 0, last_login = 1}
}}, function(success, result)
if #result > 0 then
task({result[1].last_login})
else
task()
end
end)
end
function [Link](user_id)
return vRP.user_tables[user_id]
end

function [Link](user_id)
return vRP.user_tmp_tables[user_id]
end

function [Link](user_id, key, value)


vRP.user_tmp_tables[user_id][key] = value
end

function [Link](user_id)
return [Link][user_id] ~= nil
end

function [Link](user_id)
local tmp = [Link](user_id)
return tmp and [Link]
end

function [Link](user_id)
local tmp = [Link](user_id)
return tmp and [Link] == 1
end

function [Link](source)
if source then
local ids = GetPlayerIdentifiers(source)
if ids ~= nil and #ids > 0 then
return [Link][ids[1]]
end
end
end

exports("getUserId", [Link])

function [Link]()
local users = {}
for k,v in pairs(vRP.user_sources) do
users[k] = v
end

return users
end

staffUsers = {}

function [Link]()
return staffUsers
end

[Link] = [Link]

function [Link](user_id)
return vRP.user_sources[user_id]
end

exports("getUserSource", [Link])
function [Link](source,reason)
DropPlayer(source,reason)
end

function [Link](user_id)
if user_id then
if hoursInt[user_id] then
local diff = ([Link]() - hoursInt[user_id]) or 0
local hoursGained = diff / 3600

return [Link](((hoursPlayed[user_id] or 0) + hoursGained) * 100) /


100
else
return hoursPlayed[user_id] or 0
end
end
return 0
end

function [Link](user_id)
if user_id then
if hoursInt[user_id] then
local diff = ([Link]() - hoursInt[user_id]) or 0
local hoursGained = diff / 3600

return [Link](((lastHours[user_id] or 0) + hoursGained) * 100) / 100


else
return lastHours[user_id] or 0
end
end
return 0
end

function saveHoursPlayed(user_id)
local diff = [Link]() - (hoursInt[user_id] or [Link]())
local hoursGained = [Link]((diff / 3600) * 100) / 100
hoursInt[user_id] = [Link]()
[Link]:updateOne({collection = "users", query = {id = user_id}, update =
{
['$inc'] = {hoursPlayed = hoursGained, lastHours = hoursGained}
}})

local data = [Link](user_id)


if data then
local curDay = tonumber([Link]("%w"))

if curDay == 0 then
if not [Link] then
[Link] = true

[Link]:updateOne({collection = "users", query = {id = user_id},


update = {
["$set"] = {lastHours = 0.0}
}})
end
else
[Link] = false
end
end
end

local function checkTokens(user_id, player, cb)


local task = Task(cb, {false, 0}, 5000)
local numtokens = GetNumPlayerTokens(player)

for i = 1, numtokens do
local token = GetPlayerToken(player, i)

if token then
[Link]:findOne({collection = "userTokens", query = {token =
token}, options = {projection = {banned = 1, _id = 0, user_id = 1}}},
function(success, result)
if result[1] then
if result[1].banned == true then
task({true, result[1].user_id})
end
else
[Link]:insertOne({collection = "userTokens", document =
{
token = token,
banned = false,
user_id = user_id
}})
end
end)
end
end
end

function [Link](source)
local playerIp = [Link](source)
local name = GetPlayerName(source)
local ids = GetPlayerIdentifiers(source)
[Link](ids, function(user_id, rows)
if user_id ~= nil then

[Link][ids[1]] = user_id
[Link][user_id] = ids[1]
vRP.user_tables[user_id] = {}
vRP.user_tmp_tables[user_id] = {}
vRP.user_sources[user_id] = source
if ([Link] or 0) > 0 then
staffUsers[user_id] = {lvl = [Link], src = source}
end

[Link](user_id, "vRP:datatable", function(sdata)


local data = [Link](sdata)
if type(data) == "table" then vRP.user_tables[user_id] = data end

local tmpdata = [Link](user_id)


local nowTime = [Link]()

tmpdata.last_login = nowTime
[Link] = 0

[Link]:updateOne({collection = "users", query = {id =


user_id}, update = {
["$set"] = {username = name, last_login = nowTime}
}})

print("[FP:RP] "..name.." ("..playerIp..") joined (user_id =


"..user_id..")")

TriggerEvent("vRP:playerJoin", user_id, source, name, rows)


TriggerClientEvent("vRP:checkIDRegister", source)

for k,v in pairs(vRP.user_sources) do


if user_id ~= k then
TriggerClientEvent("id:initPlayer", source, v, k)
end
end

TriggerClientEvent("id:initPlayer", -1, source, user_id)


end)
end
end)
end

RegisterNetEvent("vRP:loadPlayer")
AddEventHandler("vRP:loadPlayer", function()
local user_id = [Link](source)
if not user_id then
[Link](source)
end
end)

local connectQueue = 0
local cancelQueue = false
RegisterCommand("queue", function(src)
if src == 0 then
return print("Queue-ul este acum de "..connectQueue.." (de) secunde!")
end

[Link](src, {"Queue-ul este acum de "..connectQueue.." (de)


secunde!"})
end)

RegisterCommand("cancelqueue", function(src)
if src ~= 0 then
local user_id = [Link](src)
if not [Link](user_id) then
return [Link](src)
end
end

cancelQueue = true
[Link](6500, function()
cancelQueue = false
end)

if src == 0 then
print("^5Info: ^0Queue-ul a fost anulat.")
else
[Link](src, {"Queue-ul a fost anulat."})
end
end)
AddEventHandler("playerConnecting",function(name, setMessage, game)
[Link]()
local source = source
local player = source
local playerIp = [Link](source)
local ids = GetPlayerIdentifiers(source)

if [Link](name, "[*%%'=`\"]") then


[Link]("[FP:RP] Nu acceptam caractere sau simboluri speciale in nume.
("..tostring([Link](name, "[*%%'=`\"]"))..") \nAcesta va trebui sa fie format
doar din litere si cifre ! \n\nDiscord: [Link]/fairplay")
CancelEvent()
return false
end

local userWait = connectQueue + 1


connectQueue = userWait

while userWait > 0 do


[Link]("Te conectezi in "..userWait.." secunde...")
userWait = userWait - 1

if cancelQueue then
break
end

[Link](1000)
end

connectQueue = connectQueue - 1
if connectQueue < 0 then
connectQueue = 0
end

if ids ~= nil and #ids > 0 then

if isServerRestarting() then
[Link]("\n[FP:RP] Serverul se restarteaza, incearca sa te conectezi in
cateva momente.\n\nDiscord: [Link]/fairplay")
return
end

[Link]("[FP:RP] Se verifica baza de date...\n\nDiscord:


[Link]/fairplay")
[Link](ids, function(user_id, rows)
if user_id then
if user_id == -1 then
print("[FP:RP] "..name.." ("..playerIp..") rejected: testing")
[Link]("\n[FP:RP] Testam ceva la server va rugam reveniti peste 5
minute...\nUser Id: "..user_id.."\n\nDiscord: [Link]/fairplay")
else
[Link]("[FP:RP] Se verifica ban-urile...\n\nDiscord:
[Link]/fairplay")
[Link](user_id, function(banned, banResult)
if not banned then
checkTokens(user_id, source, function(isTokenBanned, originalId)
if not isTokenBanned then
local possibleSrc = [Link](user_id)
if not possibleSrc then

[Link]("[FP:RP] Se verifica whitelist-ul...\n\nDiscord:


[Link]/fairplay")
[Link](user_id, function(whitelisted)
if not [Link] or whitelisted then
[Link][ids[1]] = user_id
[Link][user_id] = ids[1]
vRP.user_tables[user_id] = {}
vRP.user_tmp_tables[user_id] = {}
vRP.user_sources[user_id] = source

if ([Link] or 0) > 0 then


staffUsers[user_id] = {lvl = [Link], src =
source}
end

[Link]("[FP:RP] Se incarca datele personale...\n\


nDiscord: [Link]/fairplay")
[Link](user_id, "vRP:datatable", function(sdata)
local data = [Link](sdata)
if type(data) == "table" then
vRP.user_tables[user_id] = data
end

local tmpdata = [Link](user_id)


[Link]("[FP:RP] Se incarca ultima logare...\n\
nDiscord: [Link]/fairplay")

tmpdata.last_login = [Link]()
[Link] = 0

local last_login_stamp = [Link]()


print("[FP:RP] "..name.." ("..playerIp..") joined
(user_id = "..user_id..")")

[Link]:updateOne({collection = "users", query =


{id = user_id}, update = {
["$set"] = {
last_login = last_login_stamp,
username = name
}
}})

TriggerEvent("vRP:playerJoin", user_id, source, name,


rows)
[Link]()
end)
else
print("[FP:RP] "..name.." ("..playerIp..") rejected:
whitelist (user_id = "..user_id..")")
[Link]("\n[FP:RP] Nu esti pe lista alba.\nUser Id:
"..user_id.."\n\nDiscord: [Link]/fairplay")
end
end)

else
print("[FP:RP] "..name.." ("..playerIp..") rejected: fast relog
/ double account")
[Link]("FP:RP - Eroare la logare\n\nIncearca sa te conectezi
din nou in 30 de secunde.\n\nDiscord: [Link]/fairplay")
[Link](user_id)
end
else
[Link]("\n[FP:RP] Contul tau este banat.\nNu incerca sa scapi
singur de ban!\nID-ul tau original este: "..originalId.."\n\nDiscord:
[Link]/fairplay")
print("[FP:RP] "..name.." ("..playerIp..") rejected: ^3token
banat")
end
end)
else
local banReason = [Link] or ""
local bannedBy = [Link] or ""
local banDays = [Link] or 0

local banMsg = "\nEsti banat pe acest server!\nBanat de:


"..bannedBy.."\nMotiv: "..banReason.."\nID-ul Tau: ["..user_id.."]"
if banDays > 0 then
if banDays > [Link]() then
banMsg = banMsg .. "\nExpira in: "..[Link]("%d/%m/%Y %H:%M",
banDays)
else
[Link]("\n[FP:RP] Banul tau a expirat, reconecteaza-te si
citeste regulamentul serverului!\nPentru multe alte informatii utile poti intra pe
discordul comunitatii noastre: [Link]/fairplay")
[Link]:update({collection = "userTokens", query =
{user_id = user_id}, update = {['$set'] = {banned = false}}})
[Link]:updateOne({collection = "users", query = {id =
user_id}, update = {
["$unset"] = {userBans = 1}
}})
return
end
else
banMsg = banMsg .. "\nAcest ban nu expira niciodata !"
end
banMsg = banMsg .. "\n\nPentru unban intra pe Discord:
[Link]/fairplay"

print("[FP:RP] "..name.." ("..playerIp..") rejected: banned (user_id


= "..user_id..")\n^3FP-Guard - Detalii ban:^7\n|^1 "..banReason.."^7 | Admin:
"..bannedBy.." | Data banului: "..[Link].." | IP: "..playerIp.." |")
[Link](banMsg)
end
end)
end
else
print("[FP:RP] "..name.." ("..playerIp..") rejected: identification error")
[Link]("\n[FP:RP] Eroare la identificarea jucatorului.\n\nDiscord:
[Link]/fairplay")
end
end)
else
print("[FP:RP] "..name.." ("..playerIp..") rejected: missing identifiers")
[Link]("\n[FP:RP] Eroare la identifiere, nu au fost gasite.\n\nDiscord:
[Link]/fairplay")
end
end)

function [Link](user_id)
local source = [Link](user_id)

if source and [Link][user_id] then


TriggerEvent("vRP:playerLeave", user_id, source,
[Link](user_id))

print("[vRP] user deleted from online users (user_id = "..user_id..")")


[Link][[Link][user_id]] = nil
[Link][user_id] = nil
vRP.user_tables[user_id] = nil
vRP.user_tmp_tables[user_id] = nil
vRP.user_sources[user_id] = nil
staffUsers[user_id] = nil

hoursInt[user_id] = nil
end
end

AddEventHandler("playerDropped",function(reason)
local source = source
local name = [Link](source)

TriggerClientEvent("id:removePlayer", -1, source)

local user_id = [Link](source)

if user_id ~= nil then


TriggerEvent("vRP:playerLeave", user_id, source, [Link](user_id),
reason)

[Link](function()
saveUDataInDb(user_id)
end)

print("[vRP] "..name.." ("..[Link](source)..") disconnected


(user_id = ^1"..user_id.."^0) Reason: ^1"..reason.."^0")
[Link][[Link][user_id]] = nil
[Link][user_id] = nil
vRP.user_tables[user_id] = nil
vRP.user_tmp_tables[user_id] = nil
vRP.user_sources[user_id] = nil
staffUsers[user_id] = nil

local hoursGained = [Link]((([Link]() - (hoursInt[user_id] or


[Link]())) / 3600) * 100) / 100
[Link]:updateOne({collection = "users", query = {id = user_id}, update
= {['$inc'] = {hoursPlayed = hoursGained, lastHours = hoursGained}}})

hoursInt[user_id] = nil
end
end)

RegisterServerEvent("ples-idoverhead:setViewing")
AddEventHandler("ples-idoverhead:setViewing", function(val, activePlayers)
local player = source
for _, src in pairs(activePlayers) do
TriggerClientEvent("ples-idoverhead:setCViewing", src, player, val)
end
end)

RegisterServerEvent("vRPcli:playerSpawned")
AddEventHandler("vRPcli:playerSpawned", function()

local user_id = [Link](source)


local player = source
if user_id then
vRP.user_sources[user_id] = source

if staffUsers[user_id] then
staffUsers[user_id].src = source
end

local tmp = [Link](user_id)


[Link] = [Link]+1
local first_spawn = ([Link] == 1)

if first_spawn then
for k,v in pairs(vRP.user_sources) do
if user_id ~= k then
TriggerClientEvent("id:initPlayer", source, v, k)
end
end

TriggerClientEvent("id:initPlayer", -1, source, user_id)

[Link]:findOne({collection = "users", query = {id = user_id},


options = {projection = {_id = 0, hoursPlayed = 1, lastHours = 1}}},
function(success, result)
hoursPlayed[user_id] = tonumber(result[1].hoursPlayed)
lastHours[user_id] = tonumber(result[1].lastHours)

hoursInt[user_id] = [Link]()

local loginDetail = {
hoursPlayed = hoursPlayed[user_id] or 0,
lastHours = lastHours[user_id] or 0,
time = [Link](),
date = [Link]("%d/%m/%Y %H:%M:%S"),

economy = {
cashMoney = [Link](user_id) or 0,
bankMoney = [Link](user_id) or 0,
coins = [Link](user_id) or 0
},

connectionIp = GetPlayerEndpoint(player),
user_id = user_id,
}

[Link]:insertOne({collection = "serverLogins", document =


loginDetail})
end)
end
[Link](player, config.load_delay)

SetTimeout(2000, function()
if not first_spawn then
TriggerEvent("vRP:playerSpawn", user_id, player, false)
else
[Link]:findOne({collection = "users", query = {id = user_id}},
function(success, result)
if success then
TriggerEvent("vRP:playerSpawn", user_id, player, true, result[1])
[Link](10000)
[Link] = true
else
DropPlayer(player, "A aparut o eroare la incarcarea contului !\nError
Code: 408")
end
end, true)
end

SetTimeout(config.load_duration*1000, function()
[Link](player, config.global_delay)
end)
end)
end
end)

RegisterServerEvent("vRP:playerDied")

local restarting = false

function isServerRestarting()
return restarting
end

AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)

if [Link] <= 300 then


restarting = true
end

if [Link] == 60 then
[Link](function()
[Link](20000)
ExecuteCommand("kickall")
end)
end
end)

RegisterCommand('kickall', function(source, args, rawCommand)


if source == 0 or [Link]([Link](source)) then

TriggerEvent("vRP:onRestartingSoon")

[Link](function()
local usrr = [Link]()
for uid, src in pairs(usrr) do
[Link](50)
saveUDataInDb(uid)
end
end)

restarting = true

if(rawCommand:sub(9) == nil) or (rawCommand:sub(9) == "")then


reason = "FP: Restart-urile sunt date in spre binele jucatorilor, si acestea
dureaza in jur de 2-3 minute.\nPentru mai multe detalii poti intra pe discord:
[Link]/fairplay"
else
reason = rawCommand:sub(9)
end

TriggerClientEvent("vRP:adminAnnouncement", -1, "SERVER", "Atentie! Serverul se


restarteaza in 30 (de) secunde, va rugam sa folositi F8-Quit pentru a evita
posibile pierderi de date.")
print("30 DE SECUNDE PANA LA RESTART!")

SetTimeout(10000, function()
TriggerClientEvent("vRP:adminAnnouncement", -1, "SERVER", "Atentie! Serverul
se restarteaza in 20 (de) secunde, va rugam sa folositi F8-Quit pentru a evita
posibile pierderi de date.")
print("20 DE SECUNDE PANA LA RESTART!")

SetTimeout(10000, function()
TriggerClientEvent("vRP:adminAnnouncement", -1, "SERVER", "Atentie!
Serverul se restarteaza in 10 (de) secunde, va rugam sa folositi F8-Quit pentru a
evita posibile pierderi de date.")
print("10 DE SECUNDE PANA LA RESTART!")

SetTimeout(5000, function()
TriggerClientEvent("vRP:adminAnnouncement", -1, "SERVER", "Atentie!
Serverul se restarteaza in 5 (de) secunde, va rugam sa folositi F8-Quit pentru a
evita posibile pierderi de date.")
print("5 DE SECUNDE PANA LA RESTART!")

local users = [Link]()


for i, v in pairs(users) do
[Link](v,reason)
end

print("\n\n RESTART DONE \n\n")


end)
end)
end)
else
[Link](source)
end
end)

RegisterCommand("loadwhitelist", function(src)
if src == 0 then

whitelistUsers = [Link](LoadResourceFile("vrp", "[Link]")) or {}


print("[vRP] Whitelist reloaded ("..[Link](whitelistUsers).." users)!")

end
end)
RegisterCommand("togwhitelist", function(src)
if src == 0 then
[Link] = not [Link]
print("[vRP] Server under maintenance: "..([Link] and "^2YES^7" or
"^1NO^7"))
end
end)

RegisterCommand("listwhitelist", function(src)
if src == 0 then
print("Pe lista alba sunt in total " .. [Link](whitelistUsers) .. " (de)
jucatori")
print("---------------")
print("Nume ID Acceptat")
for user_id, state in pairs(whitelistUsers) do
local uSrc = [Link](tonumber(user_id))
print((uSrc and GetPlayerName(uSrc) or "Necunoscut").." ["..user_id.."] -
"..(state and "Da" or "Nu"))
end
print("---------------")
end
end)

RegisterCommand("logtunnel", function(player)
local user_id = [Link](player)
if not [Link]() then
return [Link](player)
end
TriggerClientEvent("tunnel:toggleLogs", player)
end)

SetMapName("FairPlay-RP")
SetGameType("Roleplay")

You might also like