Glitched Scripts
Racing

Exports

Client and server exports and state bags for gs_racing.

Use these from other resources to open GS Racing or check whether a player is racing, in a lobby, or building a track.

Client

openRacingTablet

Opens GS Racing for the local player.

exports['gs_racing']:openRacingTablet()

IsInRace

Returns true while the local player is in an active race session (countdown through finish / cleanup).

if exports['gs_racing']:IsInRace() then
    -- block other activities, hide markers, etc.
end

GetActiveRace

Returns a snapshot of the local race, or nil when not racing.

local race = exports['gs_racing']:GetActiveRace()
if race then
    print(race.raceId, race.mode, race.trackName, race.place, race.field)
end

Fields: raceId, mode, laps, lap, checkpoint, started, finished, trackName, vehicleKind, place, field, requiredClass.

IsInLobby

Returns true when the player has joined an open/scheduled lobby and is not yet in the active race session.

if exports['gs_racing']:IsInLobby() then
    -- waiting at the start line
end

GetJoinedRaceId

Returns the joined race id, or false when not in a lobby / race grid.

local raceId = exports['gs_racing']:GetJoinedRaceId()
if raceId then
    print('Joined race', raceId)
end

IsCreatingTrack

Returns true while the local player is in track builder (creator) mode.

if exports['gs_racing']:IsCreatingTrack() then
    -- disable conflicting controls / jobs
end

GetCreatorStatus

Returns the builder status table (same shape as the NUI creator status).

local status = exports['gs_racing']:GetCreatorStatus()
if status.active then
    print(status.step, status.racePoints, status.canSave)
end

Useful fields: active, name, type, vehicleKind, step, stepLabel, hasStart, hasFinish, racePoints, totalPoints, objectCount, canSave.

Server

openRacingTablet

Opens GS Racing for a player.

exports['gs_racing']:openRacingTablet(source)

IsInRace

Returns true when the player’s participant status is RACING (countdown / live race).

if exports['gs_racing']:IsInRace(source) then
    -- deny other server actions
end

IsInLobby

Returns true when the player is joined to a lobby (JOINED) and not yet racing.

if exports['gs_racing']:IsInLobby(source) then
    -- waiting in lobby
end

GetPlayerRace

Returns a participation summary, or nil when the player is idle.

local info = exports['gs_racing']:GetPlayerRace(source)
if info then
    print(info.phase, info.raceId, info.trackName, info.mode)
end

Fields: raceId, trackId, trackName, mode, laps, vehicleClass, raceStatus, participantStatus, phase ('lobby' or 'race').

GetSkillWinBonusPercent

Skill-based win bonus % used for podium payouts. See Economy & permissions.

local pct = exports['gs_racing']:GetSkillWinBonusPercent(source)

State bags

LocalPlayer.state.inActiveRace

BagLocal player
KeyinActiveRace
Typeboolean
ReplicatedNo (set(..., false)) — only the owning client can read it
When trueFrom race countdown start through finish / cancel / forfeit cleanup
When false / unsetIdle, lobby, or builder

Same meaning as the client IsInRace export. Useful for lightweight local checks (e.g. fuel scripts) without calling into gs_racing.

-- client (local player only)
if LocalPlayer.state.inActiveRace then
    -- in active race session
end

AddStateBagChangeHandler('inActiveRace', ('player:%s'):format(cache.serverId), function(_, _, value)
    print('inActiveRace', value == true)
end)

Because the bag is not replicated, other clients and the server cannot read Player(id).state.inActiveRace. Use the server exports (IsInRace, GetPlayerRace) for authoritative checks.

There are no other state bags owned by gs_racing (no lobby / builder bags, no entity bags).

Not exports, but useful owner hooks in server/edit.lua:

  • ResolveVehicleClass(model)
  • HasIllegalTune(plate)
  • OnRacingRepChanged(identifier, delta, total)
  • OnRacingAnnouncement(announcement) — auto races / meetups → phone mail, push, etc.
  • OnPoliceRaceDispatch(alert)

See server/edit.lua.

On this page