Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
action (args) {
const isLevel = !!args[2]
const amt = parseInt(args[1])
const user = args[3] ? serv.getPlayer(args[3]) : player
if (!user) return args[3] + ' is not on this server!'
if (!isLevel) {
user.setXp(user.xp + amt)
player.chat('Gave ' + user.username + ' ' + amt + ' xp')
} else {
const currLevel = getXpLevel(player.xp)
const baseCurrLevel = getBaseXpFromLevel(currLevel)
const extraXp = player.xp - baseCurrLevel
user.setXp(getBaseXpFromLevel(currLevel + amt) + extraXp)
player.chat('Gave ' + user.username + ' ' + amt + ' levels')
}
}
})
player.setXp = (xp, { setLevel = true, setDisplay = true, send = true } = {}) => {
player.xp = xp
if (setLevel) player.level = getXpLevel(xp)
if (setDisplay) player.displayXp = distanceToXpLevel(xp)
if (send) player.sendXp()
}