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.
exports.CuxiaPvP:toggleUI(toggle)| Parameter | Type | Description |
|---|---|---|
toggle | boolean | true opens the menu, false closes it. |
Returns: nothing.
-- 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.
local playing = exports.CuxiaPvP:isPlaying()Returns: boolean. true from the moment the match loads until it ends.
-- Skip your own death screen during a match
if exports.CuxiaPvP:isPlaying() then return endPlayer state
Both values are replicated, so they can be read on the client and on the server. Treat them as read only.
| State | Type | Value |
|---|---|---|
inDuel | number | nil | Id of the match the player is fighting in. nil outside a match. |
spectatingMatch | number | nil | Id of the match the player is spectating. nil when not spectating. |
The id of a match is also the routing bucket it runs in.
if LocalPlayer.state.inDuel then
-- the local player is in a match
endTo react when a player enters or leaves a match:
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.
| Event | When | Set in |
|---|---|---|
Each event of revive.events | After every duel round, on every Gun Game respawn and when a match ends | revive |
av_weather:freeze | When a match starts and ends, with weatherSystem = 'av' | weatherSystem |
cd_easytime:PauseSync | When 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:
AddEventHandler('myserver:pvpRevive', function()
-- revive the local player with your own ambulance script
end)