CityRP Documentation Repository

core.libraries.meska.achievements.server.init

Metrics-Skill-Achievement Framework (MESKA) The achievements-system core functions.

Functions

Servermeska.achievements.add(config, tmp, cb) → integer|nilSource ☍

Adds an achievement to the storage.

Parameters

  • configanyAchievement configuration.
  • tmpanyIf false, store in db. Default: false. @func[opt] cb Callback Function with id as return value.
  • cbany

Returns

  1. integer|nil
Servermeska.achievements.award(ply)Source ☍

Awards a player with achievements.

Parameters

  • plyany
Servermeska.achievements.create(achievements, cb) → table|unknownSource ☍

Creates all given achievements in the database.

Parameters

  • achievementsanyInitial achievements table. @func[opt] cb Callback Function with the insert ids as return value.
  • cbany

Returns

  1. table|unknown
Servermeska.achievements.ensureType(type, cb)Source ☍

Creates the meska_achievements_type row that meska_achievements.type points at, if it is missing. name has no unique index, so the check is in the query: INSERT IGNORE would add a duplicate row.

Parameters

  • typestringThe achievement type, such as minor or major.
  • cbfun()?Called once the row exists.
Servermeska.achievements.get(alias) → tableSource ☍

Either gets all or filtered achievements.

Parameters

  • aliasanyAchievement alias.

Returns

  1. tableThe achievements.
Servermeska.achievements.getBy(key, value) → tableSource ☍

Get achievements by key and value.

Parameters

  • keyanyThe key.
  • valueanyThe value.

Returns

  1. tableThe achievements.
Servermeska.achievements.giveRewards(ply, achievement)Source ☍

Calls the rewards hook.

Parameters

  • plyany
  • achievementanyAchievement.
Servermeska.achievements.iterator(achievements) → functionSource ☍

Creates all given achievements in the database.

Deprecated

This function is deprecated and may be removed in a future version.

Use meska.achievements.create instead.

Parameters

  • achievementsanyInitial achievements table.

Returns

  1. functionAn exhausted iterator, kept for backwards-compatibility.
Servermeska.achievements.load(cb)Source ☍

Loads all achievements from DB. @func[opt] cb Callback Function.

Parameters

  • cbany
Servermeska.achievements.loadFor(ply, cb) → tableSource ☍

Loads the achievements of a player.

Parameters

  • plyany
  • cbany

Returns

  1. table
Servermeska.achievements.meetsRequirements(ply, achievement)Source ☍

Calls the requirements hook.

Parameters

  • plyany
  • achievementanyAchievement.
Servermeska.achievements.producer(achievements, curIdx, cb, dbIdsMatrix) → unknownSource ☍

Creates the achievements one after another while respecting the underlying asynchronous DB code-flow. The next achievement is only created once its predecessor finished, which prevents race-conditions. The callback receives the collected insert ids once the chain is done. Note the chain walks the table backwards, so the collected ids come back in reverse order relative to the given achievements.

Parameters

  • achievementsanyAchievements table.
  • curIdxanyThe current table index. @func[opt] cb Callback Function with the insert ids as return value. @param[opt] dbIdsMatrix The accumulated insert ids, passed along the chain.
  • cbany
  • dbIdsMatrixany

Returns

  1. unknown
Servermeska.achievements.runAnnounceQueue()Source ☍

Display delayed announcements.

Servermeska.achievements.tpl(config) → tableSource ☍

The template for achievements

Parameters

  • configanyAchievement configuration.

Returns

  1. tableThe template.

Tables

Servermeska.achievements.announceQueueSource ☍
Servermeska.achievements.storageSource ☍

Fields

Servermeska.achievements.cacheKeySource ☍
Servermeska.achievements.readySource ☍