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')
}
}
})
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')
}
}
})