Cancel dropping inventory slots on death

  • 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.

Bilbo

Member
Jan 26, 2017
27
0
0
29
Good Evening.

I have one simple question, that i couldnt figure out how to cancel out.

When a player dies, how am i able to cancel dropping items from specific slots? in my case cancel dropping of slot 0/1/2 of players inventory.

Thank you for anybody who can answer ^^
 
Good Evening.

I have one simple question, that i couldnt figure out how to cancel out.

When a player dies, how am i able to cancel dropping items from specific slots? in my case cancel dropping of slot 0/1/2 of players inventory.

Thank you for anybody who can answer ^^

The player is already dead , so you can't take player's inventory items.

At least (Skellett):
code_language.skript:
clear inventory slot 1 of player's current inventory
 
  • Like
Reactions: RobotZz
The player is already dead , so you can't take player's inventory items.

At least (Skellett):
code_language.skript:
clear inventory slot 1 of player's current inventory

Hello Again.

I know this is possible to do, yet i dont understand how exactly. This one server that is fully based on Skript and stuff, they have it so that if you die, your inventory slots 1-9 dont drop, or in minecraft code 0-8
 
@Bilbo Here you go , sorry for the long wait , but i forgot about working at that.
Not tested , but im sure this work.
code_language.skript:
function hotbarUpdate(p: player) :: text:
    set {hotbar.slot-0.%{_p}%} to {_p}'s slot 0
    set {hotbar.slot-1.%{_p}%} to {_p}'s slot 1
    set {hotbar.slot-2.%{_p}%} to {_p}'s slot 2
    set {hotbar.slot-3.%{_p}%} to {_p}'s slot 3
    set {hotbar.slot-4.%{_p}%} to {_p}'s slot 4
    set {hotbar.slot-5.%{_p}%} to {_p}'s slot 5
    set {hotbar.slot-6.%{_p}%} to {_p}'s slot 6
    set {hotbar.slot-7.%{_p}%} to {_p}'s slot 7
    set {hotbar.slot-8.%{_p}%} to {_p}'s slot 8
  
function hotbarRestore(p: player) :: text:
    set slot 0 of {_p}'s inventory to {hotbar.slot-0.%{_p}%}
    set slot 1 of {_p}'s inventory to {hotbar.slot-1.%{_p}%}
    set slot 2 of {_p}'s inventory to {hotbar.slot-2.%{_p}%}
    set slot 3 of {_p}'s inventory to {hotbar.slot-3.%{_p}%}
    set slot 4 of {_p}'s inventory to {hotbar.slot-4.%{_p}%}
    set slot 5 of {_p}'s inventory to {hotbar.slot-5.%{_p}%}
    set slot 6 of {_p}'s inventory to {hotbar.slot-6.%{_p}%}
    set slot 7 of {_p}'s inventory to {hotbar.slot-7.%{_p}%}
    set slot 8 of {_p}'s inventory to {hotbar.slot-8.%{_p}%}

on hotbar change:
    hotbarUpdate(player)

on drop:
    hotbarUpdate(player)
  
on place:
    hotbarUpdate(player)
  
on respawn:
    hotbarRestore(player)
 
1. You could use a loop.
2. The functions doesn't have to return something obligatory.
Correcting that, here a better code applying what I said.
code_language.skript:
function hotbarUpdate(p: player):
    loop integers from 0 to 8:
        set {hotbar::slot::%loop-int%::%{_p}%} to {_p}'s slot loop-int

function hotbarRestore(p: player):
    loop integers from 0 to 8:
        set slot loop-int of {_p} to {hotbar::slot::%loop-int%::%{_p}%}

on hotbar change:
    hotbarUpdate(player)

on drop:
    hotbarUpdate(player)

on place:
    hotbarUpdate(player)

on respawn:
    hotbarRestore(player)
 
Good Evening.

I have one simple question, that i couldnt figure out how to cancel out.

When a player dies, how am i able to cancel dropping items from specific slots? in my case cancel dropping of slot 0/1/2 of players inventory.

Thank you for anybody who can answer ^^

I haven't tested it but that should work:

code_language.skript:
On death:
    If  victim is a player:
        clear inventory slot 1 of player's current inventory
        clear inventory slot 2 of player's current inventory
        clear inventory slot 3 of player's current inventory
 
I haven't tested it but that should work:

code_language.skript:
On death:
    If  victim is a player:
        clear inventory slot 1 of player's current inventory
        clear inventory slot 2 of player's current inventory
        clear inventory slot 3 of player's current inventory

That's for clear inventory slot , he requested how to save only the hotbar items and is already solved.
 
1. You could use a loop.
2. The functions doesn't have to return something obligatory.
Correcting that, here a better code applying what I said.
code_language.skript:
function hotbarUpdate(p: player):
    loop integers from 0 to 8:
        set {hotbar::slot::%loop-int%::%{_p}%} to {_p}'s slot loop-int

function hotbarRestore(p: player):
    loop integers from 0 to 8:
        set slot loop-int of {_p} to {hotbar::slot::%loop-int%::%{_p}%}

on hotbar change:
    hotbarUpdate(player)

on drop:
    hotbarUpdate(player)

on place:
    hotbarUpdate(player)

on respawn:
    hotbarRestore(player)


Thank you ^^
Thanks a lot!
 
Status
Not open for further replies.