🤠 Wild Country Libs
Server API

Lifecycle Events

One event name per lifecycle moment, regardless of which framework is running underneath. No more if framework == 'vorp' then ... else ... end blocks scattered through your resources.

OnPlayerLoaded(callback)server

Fires once a player finishes loading into the server.

ParamTypeDescription
callbackfunction(source)Runs when the player loads in.
internally listens to —
vorp_core events
'vorp_CharSelectedCharacter'  -- existing character selected
'vorp_NewCharacter'           -- new character created
rsg-core event
'RSGCore:Server:OnPlayerLoaded'
example
wc:OnPlayerLoaded(function(source)
  print("Player loaded:", source)
end)
OnPlayerUnload(callback)server

Fires when a player logs out or returns to character select.

VORP gap. There's no confirmed dedicated server-side "player unload" event for VORP in the docs this lib was built against. On RSG this fires reliably via RSGCore:Server:OnPlayerUnload; on VORP it currently registers but never fires, with a console warning on startup explaining why. Extend it in _custom/server.lua if your VORP build exposes a usable event.
OnJobUpdate(callback)server

Fires when a player's job changes.

ParamTypeDescription
callbackfunction(source, newJob, oldJob)Runs on job change.
example
wc:OnJobUpdate(function(source, newJob, oldJob)
  wc:Notify(source, { title = "Job updated" })
end)

Real Wild County example — stagecoach job list refresh

wc_stagecoach rebuilds a driver's available missions the moment their job changes, instead of waiting for the player to relog.

wc_stagecoach/server/main.lua
wc:OnPlayerLoaded(function(source)
  RefreshStagecoachMissions(source)
end)

wc:OnJobUpdate(function(source, newJob, oldJob)
  if newJob == 'stagecoach_driver' or oldJob == 'stagecoach_driver' then
    RefreshStagecoachMissions(source)
  end
end)

Common mistakes

Troubleshooting