#How do I make a levelup system using ScriptApi?

1 messages · Page 1 of 1 (latest)

jovial girder
#

One message removed from a suspended account.

solar irisBOT
#
Thanks for asking your question!

Once you have finished, please close your thread.

scenic ravine
#

it basically sets all of the objectives, and after certain events, modifies the XP and the level by running a quick calculation formula

jovial girder
#

One message removed from a suspended account.

fathom basalt
nimble grove
# scenic ravine <@770250380755730472> check out my addon LOTR Craft. I literally just did this f...
            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?
scenic ravine
scenic ravine