Exports#
All exports below are server-side.
Use them from another resource like this:
local data = exports['0r-soccer']:GetLeaderboard(10, 'goals')
Make sure 0r-soccer is started before your script calls these exports.
Stats and leaderboard#
GetLeaderboard(limit?, orderBy?)#
Returns raw leaderboard rows from the database.
| Argument | Type | Default | Description |
|---|---|---|---|
limit | number | config default | Max rows |
orderBy | string | "goals" | "goals", "assists", or "matches" |
local rows = exports['0r-soccer']:GetLeaderboard(10, 'goals')
-- each row: identifier, name, goals, assists, matches
GetLeaderboardTable(limit?, orderBy?)#
Same data, but formatted as a table for UIs:
local tableData = exports['0r-soccer']:GetLeaderboardTable(10, 'assists')
-- tableData.columns, tableData.rows, tableData.rowCount
GetPlayerStats(identifierOrSource)#
Get one player’s total stats.
You can pass:
- a player server id (source), or
- a full identifier string (example:
license:...)
local stats = exports['0r-soccer']:GetPlayerStats(source)
-- or
local stats = exports['0r-soccer']:GetPlayerStats('license:abcd...')
Returns nil if not found.
GetPlayerMatchHistory(identifierOrSource, limit?, offset?)#
Formatted match history for one player (wins/losses, goals in match, etc.).
local history = exports['0r-soccer']:GetPlayerMatchHistory(source, 15, 0)
GetPlayerMatchHistoryRaw(identifierOrSource, limit?, offset?)#
Same query, raw SQL-style fields.
GetPlayerMatchHistoryTable(identifierOrSource, limit?, offset?)#
History packed as { columns, rows, rowCount } for tablets / NUI tables.
GetRecentTopScorers(days?, limit?)#
Top scorers in the last X days (from match history).
local top = exports['0r-soccer']:GetRecentTopScorers(7, 10)
GetMatchById(matchId)#
Returns one finished match + participants.
local match = exports['0r-soccer']:GetMatchById(42)
Live pitches and lobbies#
GetPitchOverview()#
List of configured pitches and whether they are busy.
local pitches = exports['0r-soccer']:GetPitchOverview()
-- pitchId, pitchName, isBusy, state, playerCount, lobby, coords, ...
GetPitchOverviewTable()#
Same overview in table format (columns + rows).
GetActiveLobbies()#
All active lobbies (waiting, warmup, playing, paused, …).
local lobbies = exports['0r-soccer']:GetActiveLobbies()
GetActiveLobbiesTable()#
Active lobbies in table format.
GetServerSummary()#
Quick server snapshot:
local summary = exports['0r-soccer']:GetServerSummary()
--[[
activeLobbyCount
activeMatchCount
waitingLobbyCount
playersInSoccer
pitchCount
busyPitchCount
generatedAt
]]
GetTabletBridgeSnapshot()#
One call for tablets / dashboards:
local snap = exports['0r-soccer']:GetTabletBridgeSnapshot()
-- snap.pitchOverview
-- snap.activeLobbies
-- snap.serverSummary
Player match state#
IsPlayerInMatch(source)#
Returns true if the player is currently in a soccer lobby/match.
if exports['0r-soccer']:IsPlayerInMatch(source) then
-- block other activities, etc.
end
GetPlayerLobbyId(source)#
Returns the lobby id, or nil.
local lobbyId = exports['0r-soccer']:GetPlayerLobbyId(source)
Stadium scoreboard (DUI)#
These control the in-world scoreboard display.
With the default driver (ScoreboardDriver = "soccer"), lobbies already update the board. Use these exports mainly for custom / external integrations.
StartFootballMatch(payload)#
Start / show a match on the stadium board.
exports['0r-soccer']:StartFootballMatch({
homeName = 'Red Team',
awayName = 'Blue Team',
homeScore = 0,
awayScore = 0,
minutes = 20, -- or totalSeconds / elapsedSeconds
state = 'playing',
status = 'LIVE',
})
UpdateFootballScore(payload)#
exports['0r-soccer']:UpdateFootballScore({
homeScore = 2,
awayScore = 1,
homeName = 'Red Team',
awayName = 'Blue Team',
})
UpdateFootballTime(payload)#
exports['0r-soccer']:UpdateFootballTime({
elapsedSeconds = 600,
totalSeconds = 1200,
-- or timeLeft = 600
})
GoalScored(payload)#
Shows a goal overlay and can bump the score.
exports['0r-soccer']:GoalScored({
scoringTeam = 1, -- 1 = home, 2 = away
scorerName = 'Alex',
isOwnGoal = false,
-- optional: homeScore / awayScore to set exact score
})
GetFootballMatchState()#
Returns the current stadium board snapshot.
local state = exports['0r-soccer']:GetFootballMatchState()
Optional server events#
If Config.API.EnableServerEvents is enabled, you can also use event-style queries:
local requestId = 'my-request-1'
TriggerEvent('0r-soccer:server:ApiQuery', 'leaderboard', { limit = 10 }, requestId)
AddEventHandler('0r-soccer:server:ApiQueryResult', function(rid, ok, payload)
if rid ~= requestId then return end
if not ok then return end
print(json.encode(payload))
end)
When a match is saved to the database, this event is fired:
AddEventHandler('0r-soccer:matchSaved', function(matchId, lobbyId, endReason, info)
-- info.pitchId, info.score1, info.score2, info.winnerTeam, ...
end)
Example: tablet leaderboard#
RegisterCommand('soccer_top', function(source)
local tableData = exports['0r-soccer']:GetLeaderboardTable(10, 'goals')
for _, row in ipairs(tableData.rows or {}) do
print(('#%s %s — %s goals'):format(row.rank, row.name, row.goals))
end
end, true)