RVT Hunt

API and integration

Exports, state bag, commands and how to adapt the resource to your server.

Exports

ExportParamsReturns
IsBusy (server)src: numbertrue if the player is in a match. Being in a room or the queue does not count.
OpenLobby (client)tab?: string (e.g. "rank")Nothing. Does not open if the player is downed or in a match.
InMatch (client)nonetrue if the player is in a match.

State bag: LocalPlayer.state.inHuntMatch is true inside a match and false outside. It is written by the client; on the server, for decisions that must not be spoofable, use IsBusy.

server.lua
-- server: block other activities while the player is in a match
if exports["rvt-hunt"]:IsBusy(source) then
    return
end
client.lua
-- client: open the lobby from your own menu
RegisterCommand("playhunt", function()
    exports["rvt-hunt"]:OpenLobby()          -- or OpenLobby("rank")
end, false)

if exports["rvt-hunt"]:InMatch() then
    -- the player is inside a match
end

Commands

Names come from Config.Commands (false turns one off). Staff commands require the ACE in Config.Staff.Ace, one of the Config.Staff groups or the configured vRP group.

CommandWhoWhat it does
/huntPlayerOpens the lobby: rooms, queue, ranking and how to play.
/huntrankPlayerOpens straight on the ranking.
/hunttutorialPlayerOpens "how to play".
/huntdiarioPlayerIn a match: perks, power and objective (F5 key).
/huntteste [sobrevivente|assassino] [bots]StaffTest match with bots. Does not count for the ranking.
/huntbot [quantidade]StaffAdds bot survivors (1 to 4) to the match you are in.
/huntfim [partida]StaffEnds your match or the one with the given number. Works from the console.
/huntassassino [sempre]StaffMarks you as the killer for the next match; inside one, switches character.
/huntpartidasStaffLists running matches and the queue. Works from the console.
/huntmapaStaffToggles the in-game map editor.
/huntimportarmapasStaffImports the arenas from maps-import.json as new maps. Server console only; repeating it duplicates the maps.
/huntassistirStaffWatch matches without appearing to the players.
/huntrankzerar confirmarStaffResets the current season ranking. Works from the console.
Powers API (HuntPower)

Each file in open/powers/ registers a power with HuntPower(id, definition). Then give the power to a character with Power = "id" in Config.Hunt.Killer.Costumes and translate Name and Note in open/locales. The file open/powers/lampejo.lua is a complete, commented example.

open/powers/my_power.lua
HuntPower("my_power", {
    Icon = "bolt",
    Aim = { Range = 30.0, Angle = 20 },        -- optional: sends the aimed player as ctx.Target

    -- server: runs when the killer presses F
    Server = function(ctx)
        local Near = ctx.Survivors(ctx.Config.Radius)
        if #Near == 0 then return false, "nobody_near" end   -- no cooldown spent
        for _, S in ipairs(Near) do
            ctx.Hit(S.source, false)
            ctx.Send(S.source, "hit", { seconds = 4 })
        end
        return true                                          -- cooldown starts
    end,

    -- client: screen effects only, the server decides who is hit
    Client = function(event, data, ctx)
        if event == "hit" then ctx.PowerFx("Hit", data.seconds) end
    end,
})
  • Server(ctx): runs when the killer presses F. Return true to use the power (cooldown starts) or false, "reason" to not spend the cooldown.
  • Tick(ctx): optional, runs several times per second during the match, for powers with a duration.
  • Client(event, data, ctx): screen effects only. The server always decides who is hit.
  • Server ctx: Survivors(radius, point), Hit(src, down, opts), Send and SendAll, Noise(point, radius), HoldAttack(seconds), Coords, Name, State, Now and Data.
  • An error inside a power shows in the console with the file name and does not break the match: F is simply not used.
Bridge functions (frameworks)

The core talks to your server only through the Bridge.* functions in the two files of open/bridge/. The default is Config.Framework = "standalone". With "auto", detection follows the order qbx_core, qb-core, es_extended, vrp; with none, standalone. For a custom framework, set "standalone" and adjust these functions.

open/bridge
-- open/bridge/server.lua
function Bridge.GetId(src) end            -- persistent player id (string)
function Bridge.GetDisplayId(src) end     -- number shown on screen and typed to invite
function Bridge.FindPlayer(number) end    -- number -> source, or nil
function Bridge.GetName(src) end          -- character name
function Bridge.IsStaff(src) end          -- true for staff
function Bridge.Notify(src, title, text, kind) end
function Bridge.RestoreAppearance(src) end  -- asks the client to restore the appearance

-- open/bridge/client.lua
function Bridge.Notify(title, text, kind) end
function Bridge.SaveAppearance() end
function Bridge.RestoreAppearance() end
function Bridge.SetHud(visible) end
function Bridge.SetScene(on, hour, weather) end
function Bridge.ClearWeapons() end
function Bridge.OnMatch(on) end
  • GetId is the persistent id (ranking, return after a drop and last killer). ESX uses identifier, QBCore/Qbox citizenid, vRP the passport and standalone the license.
  • GetDisplayId is the number shown on screen and typed to invite: passport on vRP, server ID elsewhere.
  • SaveAppearance and RestoreAppearance save and give back the player’s clothes and face; adapt them to your appearance system.
  • SetHud, SetScene, ClearWeapons and OnMatch handle the HUD, weather, weapons and effects that must be removed on entering a match.