Skip to content

Exports & events

Public API of Cuxial PvP: exports to open the menu and state to know who is in a match.

Open the menu from your own resources and find out whether a player is fighting or spectating. Cuxial PvP has two client exports and two player state values; it exposes no server exports.

Client exports ​

toggleUI ​

Opens or closes the menu. The call is ignored while the player is in a match.

lua
exports.CuxiaPvP:toggleUI(toggle)
ParameterTypeDescription
togglebooleantrue opens the menu, false closes it.

Returns: nothing.

lua
-- Open the menu with your own command
RegisterCommand('arena', function()
    exports.CuxiaPvP:toggleUI(true)
end, false)

isPlaying ​

Tells whether the local player is in a match.

lua
local playing = exports.CuxiaPvP:isPlaying()

Returns: boolean. true from the moment the match loads until it ends.

lua
-- Skip your own death screen during a match
if exports.CuxiaPvP:isPlaying() then return end

Player state ​

Both values are replicated, so they can be read on the client and on the server. Treat them as read only.

StateTypeValue
inDuelnumber | nilId of the match the player is fighting in. nil outside a match.
spectatingMatchnumber | nilId of the match the player is spectating. nil when not spectating.

The id of a match is also the routing bucket it runs in.

lua
if LocalPlayer.state.inDuel then
    -- the local player is in a match
end

To react when a player enters or leaves a match:

lua
AddStateBagChangeHandler('inDuel', nil, function(bagName, _, value)
    local player = GetPlayerFromStateBagName(bagName)
    if player == 0 then return end

    if value then
        -- entered the match with id `value`
    else
        -- left the match
    end
end)

Events Cuxial PvP triggers on other scripts ​

These are client events sent to the scripts chosen in data/config.lua.

EventWhenSet in
Each event of revive.eventsAfter every duel round, on every Gun Game respawn and when a match endsrevive
av_weather:freezeWhen a match starts and ends, with weatherSystem = 'av'weatherSystem
cd_easytime:PauseSyncWhen a match starts and ends, with weatherSystem = 'cd'weatherSystem

The revive events are triggered with no arguments. To plug in a script that needs something else, add your own event to revive.events and handle it:

lua
AddEventHandler('myserver:pvpRevive', function()
    -- revive the local player with your own ambulance script
end)

© Cuxial