Separate loadouts

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

etheboi_

Active Member
Nov 9, 2023
50
1
8
23
So I am an owner of a minecraft server and I have many problems with my lifesteal code. The code works well but the hearts transfer across worlds. And so does the hotbar. I was wondering if it was possible to: when a player leaves the lifesteal lobby, there hearts go back to 10 and their loadout gets saved and unloaded. My current code is below and i know what i need to do but i don't know where to put it.


on load:
set {lifesteal::%player's uuid%.hearts} to 10

on death:
if event-world is "lifesteal":
subtract 1 from max health of victim
set {lifesteal::%victim's uuid%.hearts} to {lifesteal::%victim's uuid%.hearts} - 1

add 1 to max health of attacker
set {lifesteal::%attacker's uuid%.hearts} to {lifesteal::%attacker's uuid%.hearts} + 1

#heart item
on rightclick:
if player is holding red dye named "&4Heart" with lore "&6Right Click to redeem":
add 1 to max health of player
set {lifesteal::%player's uuid%.hearts} to {lifesteal::%player's uuid%.hearts} + 1
remove 1 of red dye named "&4Heart" with lore "&6Right Click to redeem" from player's inventory

on drop:
if player is holding red dye named "&4Heart" with lore "&6Right Click to redeem":
if {drop.warn} is 0:
cancel event
set {drop.warn} to 1
send "&4Are you sure you want to drop this?" to player

if {drop.warn} is 1:
set {drop.warn} to 0

command /itemheart [<offline player>]:
permission: get.heart
trigger:
if player does not have permission "get.heart":
send "&4You do not have permission to do this!"
else:
if event-world is "lifesteal":
if arg-1 is set:
set {_target} to arg-1
give {_target} red dye named "&4Heart" with lore "&6Right Click to redeem"
if arg-1 isn't set:
give player red dye named "&4Heart" with lore "&6Right Click to redeem"
else:
send "&4You can not do that here!" to player



and i need to add:


if event-world is not "lifesteal":
set max health of player to 10
if event-world is "lifesteal":
set max health of player to {lifesteal::%player's uuid%.hearts}



but i just dont know where to put it.
 
You could put it in an 'on player world change' event. I'd wait a tick before setting the max health, though.

Edit: I should probably mention this, too, but if you have multiple gamemodes like this and get around 20 players or more, I would recommend making a proxy instead of running it all on one server. It takes a bit of technical knowledge, but if you're hosting your own server, it looks more professional and makes coding easier. And if you're using Minehut, like the majority of us are, I believe there's a way to do it on the dashboard, but it costs a bit more credits each month (I set mine up as an external and I'm using Oracle to host, which ties closer with setting it up manually).