Elite NetworkElite SaaS · Docsv0.1
GitHubPainel

functions/player_search.lua

Adapter de busca + perfil agregado. Onde mais provável você vai precisar mexer ao trocar de framework.

Global exposto

Define a tabela EliteSaaSPlayerSearch com os métodos:

  • search(query) — devolve até 20 matches
  • getIdentity(userId)
  • getMoney(userId)
  • getProperties(userId) — delega para getUserProperties
  • getVehicles(userId) — delega para getUserVehicles
  • getRelationships(userId)
  • getFines(userId)
  • getJobs(userId)

Tabelas SQL assumidas (vRP)

  • vrp_user_identities(user_id, firstname, name, registration, phone, dateofbirth, sex, nationality)
  • vrp_users(id, whitelisted, banned, reason_ban, last_login, discord_id)
  • vrp_user_ids(user_id, identifier) (steam, discord, fivem, license)
  • bank_fines / bank_fines_paid (id, user_id, description, amount, created_at)
Outro framework?
Se o servidor não usa vRP, reescreva apenas as funções dessa tabela — contanto que o retorno respeite a shape, todo o painel funciona.

search(query) — assinatura

functions/player_search.lua·lua
function EliteSaaSPlayerSearch.search(query)
  -- query é string: nome, userId numérico ou CPF
  -- DEVE retornar array de:
  -- { userId, name, document, isOnline, serverId }
  -- Até 20 items, ordenado pelo melhor match.

  local results = exports.oxmysql:query_async([[
    SELECT ui.user_id, ui.firstname, ui.name, ui.registration AS document
    FROM vrp_user_identities ui
    WHERE ui.firstname LIKE ?
       OR ui.name LIKE ?
       OR ui.registration LIKE ?
       OR ui.user_id = ?
    LIMIT 20
  ]], { "%"..query.."%", "%"..query.."%", "%"..query.."%", tonumber(query) or 0 })

  local out = {}
  for _, row in ipairs(results or {}) do
    local src = vRP.getUserSource(row.user_id)
    out[#out+1] = {
      userId = row.user_id,
      name = (row.name or "")..' '..(row.firstname or ""),
      document = row.document,
      isOnline = src ~= nil,
      serverId = src
    }
  end
  return out
end

getIdentity(userId) — shape esperada

lua
return {
  name        = "João Pereira",
  document    = "123.456.789-00",
  phone       = "(11) 99999-1234",
  dateOfBirth = "1995-03-12",         -- string ISO
  sex         = "M",                  -- M | F | outro
  nationality = "BR",
  licenses    = {                     -- chaves arbitrárias
    steam   = "steam:1100001...",
    discord = "discord:18...",
    fivem   = "fivem:42...",
    license = "license:abc..."
  },
  whitelisted = true,
  banned      = false,
  banReason   = nil,
  firstSeen   = "2024-01-10T03:14:00Z",
  lastSeen    = "2026-05-24T21:50:11Z"
}

getMoney(userId) — shape esperada

lua
return {
  wallet = 12450,
  bank   = 850000,
  paypal = 0
  -- Chaves extras são aceitas e aparecem no painel automaticamente.
}

Stubs e fallback gracioso

Funções não implementadas devem retornar erro via error() — o painel mostra na seção partialErrors e omite a parte relevante do perfil. Não devolva dados falsos.

lua
function EliteSaaSPlayerSearch.getRelationships(userId)
  -- Não implementado neste servidor — devolva erro descritivo.
  error("getRelationships não implementado (sem tabela de família neste schema)")
end

Erros de carregamento

Se o resource não conseguir carregar este adapter (sintaxe errada), todas as rotas player-* devolvem 503 com a mensagem: EliteSaaSPlayerSearch não carregado (verifique functions/player_search.lua).

Elite Network — Command Center