forked from JaylyDev/ScriptAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
22 lines (21 loc) · 799 Bytes
/
index.js
File metadata and controls
22 lines (21 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Script example for ScriptAPI
// Author: iBlqzed <https://github.com/iblqzed>
// Project: https://github.com/JaylyDev/ScriptAPI
import { Player, world } from "@minecraft/server";
/**
* Gets the score recorded for {displayName} on {objective}
* @param {Player} player or entity on the scoreboard
* @param {String} objectiveId Objective Identifer to get from
* @param {Boolean} rNull If the return should be null if its not found or 0.
* @returns {Number} Score that Was recorded for {Player} on {Objective}
* @example getScore(player, "objective"): number
*/
export function getScore(player, objectiveId, rNull = false) {
try {
return world.scoreboard
.getObjective(objectiveId)
.getScore(player.scoreboardIdentity);
} catch (error) {
return rNull ? null : 0;
}
}