MySQL.createCommand("vRP/get_user_identities", "SELECT * FROM vrp_user_identities WHERE user_id in (@user_ids)")
function vRP.getUserIdentities(arr_user_ids, cbr)
if cbr == nil then
return
end
local task = Task(cbr)
if arr_user_ids == nil or #arr_user_ids <= 0 then
task({})
return
end
MySQL.query(
"vRP/get_user_identities",
{user_ids = arr_user_ids},
function(rows, affected)
if rows == nil then
task({})
else
task({rows})
end
end
)
end
function GetJobType(user_id)
local jobType = nil
if vRP.hasPermission(user_id, "cop.whitelisted") then
jobType = "cop"
elseif vRP.hasPermission(user_id, "ems.whitelisted") then
jobType = "ems"
elseif vRP.hasPermission(user_id, "uber.whitelisted") then
jobType = "uber"
elseif vRP.hasPermission(user_id, "repair.whitelisted") then
jobType = "repair"
elseif vRP.hasPermission(user_id, "shh.whitelisted") then
jobType = "shh"
elseif vRP.hasPermission(user_id, "mafia.whitelisted") then
jobType = "mafia"
elseif vRP.hasPermission(user_id, "gm.whitelisted") then
jobType = "gm"
elseif vRP.hasPermission(user_id, "tow.whitelisted") then
jobType = "tow"
elseif vRP.hasPermission(user_id, "cbs.whitelisted") then
jobType = "cbs"
elseif vRP.hasPermission(user_id, "kys.whitelisted") then
jobType = "kys"
elseif vRP.hasPermission(user_id, "helper.whitelisted") then
jobType = "helper"
elseif vRP.hasPermission(user_id, "inspector.whitelisted") then
jobType = "inspector"
elseif vRP.hasPermission(user_id, "admin.whitelisted") then
jobType = "admin"
end
return jobType
end
function GetArrUserGroups(user_id)
local tmpGroups = vRP.getUserGroups(user_id)
local arrGroups = {}
for k2, v2 in pairs(tmpGroups) do
if v2 == true then
table.insert(arrGroups, k2)
end
end
return arrGroups
end
local userList = {}
local user_ids = {}
local playerInfo = {}
function makeUserListTask()
userList = {}
user_ids = {}
for _, v in ipairs(GetPlayers()) do
playerInfo = {
source = v,
user_id = vRP.getUserId(v) or "",
nickname = GetPlayerName(v) or "",
name = "",
job = "",
jobType = ""
}
userList[playerInfo.user_id] = playerInfo
table.insert(user_ids, playerInfo.user_id)
end
vRP.getUserIdentities(
user_ids,
function(identities)
if identities == nil then
SetTimeout(20000, makeUserListTask)
return
end
for _, v in ipairs(identities) do
if userList[v.user_id] then
if v.firstname and v.name then
userList[v.user_id].name = htmlEntities.encode(v.firstname) .. " " .. htmlEntities.encode(v.name)
end
userList[v.user_id].job = vRP.getUserGroupByType(userList[v.user_id].user_id, "job") or ""
userList[v.user_id].jobType = GetJobType(userList[v.user_id].user_id) or ""
userList[v.user_id].groups = GetArrUserGroups(v.user_id)
userList[v.user_id].phone = v.phone
if _ >= #identities then
SetTimeout(20000, makeUserListTask)
end
end
end
end
)
user_ids = nil
end
makeUserListTask()
function vRP.getUserList(cbr)
if cbr == nil then
return
end
local task = Task(cbr)
task({userList})
end