core.libraries.meska.achievements.server.init
Metrics-Skill-Achievement Framework (MESKA) The achievements-system core 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
- 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
- table|unknown
- Servermeska.achievements.ensureType(type, cb)Source ☍
-
Creates the
meska_achievements_typerow thatmeska_achievements.typepoints at, if it is missing.namehas no unique index, so the check is in the query:INSERT IGNOREwould add a duplicate row.Parameters
- typestringThe achievement type, such as
minorormajor. - cbfun()?Called once the row exists.
- typestringThe achievement type, such as
- Servermeska.achievements.get(alias) → tableSource ☍
-
Either gets all or filtered achievements.
Parameters
- aliasanyAchievement alias.
Returns
- tableThe achievements.
- Servermeska.achievements.getBy(key, value) → tableSource ☍
-
Get achievements by key and value.
Parameters
- keyanyThe key.
- valueanyThe value.
Returns
- 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
- 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
- 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
- unknown
- Servermeska.achievements.runAnnounceQueue()Source ☍
-
Display delayed announcements.
- Servermeska.achievements.tpl(config) → tableSource ☍
-
The template for achievements
Parameters
- configanyAchievement configuration.
Returns
- tableThe template.