#How do I make a levelup system using ScriptApi?
1 messages · Page 1 of 1 (latest)
Thanks for asking your question!
Once you have finished, please close your thread.
Use the /close command or button below.
@jovial girder check out my addon LOTR Craft. I literally just did this for the most recent update. check the scripts folder in behavior pack
it basically sets all of the objectives, and after certain events, modifies the XP and the level by running a quick calculation formula
One message removed from a suspended account.
Don’t use objectives, use DynamicProperties
var gained_xp = 0
//If killing a player, get a portion of their XP
if (event.hurtEntity.typeId == "minecraft:player"){
gained_xp = entity_functions.get_entity_objective_score(event.hurtEntity, "command_level")
gained_xp *= 8.2
}
else{
gained_xp = entity_functions.get_entity_objective_score(event.hurtEntity, "command_points")
}
var gain_side = data_convert.FactionSIDEINVERT(entity_functions.get_entity_objective_score(event.hurtEntity, "chosen_faction"))
var damager_side = data_convert.FactionSIDE(entity_functions.get_entity_objective_score(event.damagingEntity, "chosen_faction"))
if (damager_side == gain_side || entity_functions.get_entity_objective_score(event.hurtEntity, "chosen_faction") == 88){
//server_main.world.say("giving XP")
//DIRECT TO PLAYER
if (event.damagingEntity.typeId == "minecraft:player"){//give player xp for killing entity
commander_controller.modify_commanderXP(event.damagingEntity, gained_xp)
}
//A TAMED ENTITY KILLS IT
else if (entity_functions.check_valid_score(event.damagingEntity, "player_host")){
gained_xp *= 0.7
var playerHost = entity_functions.get_playerBy_ID(entity_functions.get_entity_objective_score(event.damagingEntity, "player_host"))
commander_controller.modify_commanderXP(playerHost, Math.round(Number(gained_xp)))
}
}
}```
This I assume?
yes that script is for events that add the xp. The actual function is the commander_controller.modify_commanderXP
stil pretty new to script API, so im not 100% sure how to use them yet