How can I make a player lose 10% of their property when they die?

  • 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 skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
10% would be 3.5 slots, so let's say 4
Code:
on death:
  loop 4 times:
      while {_x} is not set:
        if {_tries} is more than 100:
          set {_x} to true
        else:
            set {_slot} to a random integer between 0 and 35
            if slot {_slot} of player's inventory is not air:
                set slot {_slot} of player's inventory to air
                set {_x} to true
            wait 1 tick
            add 1 to {_tries}
 
10%는 3.5 슬롯이므로 4라고 가정해 보겠습니다.
Code:
 사망 시:
  루프 4번:
      {_x}가 설정되지 않은 동안:
        {_tries}가 100보다 큰 경우:
          {_x}를 true로 설정
        또 다른:
            {_slot}을 0에서 35 사이의 임의의 정수로 설정
            플레이어 인벤토리의 {_slot} 슬롯이 에어가 아닌 경우:
                플레이어 인벤토리의 {_slot} 슬롯을 방송으로 설정
                {_x}를 true로 설정
            1틱 기다려
            {_tries}
에 1 추가
재산은 인벤토리 슬롯이 아니라 돈입니다.
 
I'm not really sure what you actually want to do but if you want to make it so that they lose 10% of their balance do this:
Code:
on death:
    set {_x} to the victim's balance
    set {_y} to {_x} / 10
    remove {_y} from the victim's balance
# If what you meant was wealth such as gold ingots do this instead:
on death:
    set {_x} to amount of gold ingot in victim's inventory
    set {_y} to {_x} / 10
    remove floor({_y}) of gold ingot from victim's inventory
But I'm not sure if I understood what you want to do correctly so yeah. But if that's what you want, this one works I tried it.
 
Status
Not open for further replies.