Battlepass
Thin pcall-guarded wrapper around exports.vlab_battlepass:AddExpToCharacter. Never crashes the calling resource if vlab_battlepass is absent or restarting.
AddBattlepassXP(charIdentifier, xp) → booleanserver
Awards battlepass XP directly by character identifier. Returns false silently if vlab_battlepass is not started.
| Param | Type | Description |
|---|---|---|
| charIdentifier | number | string | From ch.charIdentifier / ch.identifier. |
| xp | number | XP to award. |
AddBattlepassXPForPlayer(source, xp) → booleanserver
Resolves charIdentifier automatically from the player source via WCLibPlayer, then awards XP.
| Param | Type | Description |
|---|---|---|
| source | number | Player server source ID. |
| xp | number | XP to award. |
example
-- recommended: resolve automatically from source
exports.wc_libs:AddBattlepassXPForPlayer(source, 100)
-- or if you already have the charIdentifier
exports.wc_libs:AddBattlepassXP(charIdentifier, 100)
Real Wild County example — safe optional integration
Every Green Studio resource can call this unconditionally — if vlab_battlepass isn't installed on a given server, it's just a no-op instead of an error.
wc_stagecoach/server/main.lua
-- safe to call even if this server doesn't run vlab_battlepass
wc:AddBattlepassXPForPlayer(src, 20)
Common mistakes
- Wrapping every call in your own
GetResourceState('vlab_battlepass')check — wc_libs already does that internally; it's redundant. - Calling from the client — this module is server-only.
- Passing a stale or wrong
charIdentifiertoAddXP— preferAddXPForPlayer(source, xp), which resolves it fresh from the player source every time.
Troubleshooting
- If XP never seems to apply: confirm
vlab_battlepassis actually started —AddXPsilently returnsfalsewhen it isn't, by design. - If
AddXPForPlayerlogs "could not resolve character": the player's framework character wasn't ready yet — call this afterOnPlayerLoaded, not on connect.