how to make two players share 1 inventory

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

KewlKiller

Member
Sep 16, 2024
2
0
1
24
how would i make it so 2 players would like have access to one inventory invluding hotbar and allt hat is it even possivle?
 
i lowkey wanna like make it so i can roll and eveyrone is assinged a diffrent person they share with yk i just wnted to see if its possbile before i attmetped
 
I tryed to make it work but I cant get the loops to work so it is 100% possible and will only take time


what I have so far:
<---not tested in server environment--->
Code:
on load:
    {shared_inventory::player1} = none
    {shared_inventory::player2} = none

command /shareinventory <player>:
    trigger:
        if {shared_inventory::player1} is set:
            message "A shared inventory is already in use!" to sender
            stop
        set {shared_inventory::player1} to player
        set {shared_inventory::player2} to arg-1
        message "You are now sharing your inventory with %arg-1%!" to player
        message "You are now sharing your inventory with %player%!" to arg-1
        loop all items in player's inventory:
            set slot loop-index of arg-1's inventory to loop-value
        loop all items in arg-1's inventory:
            set slot loop-index of player's inventory to loop-value

on inventory click:
    if player is {shared_inventory::player1} or {shared_inventory::player2}:
        set {_other} to {shared_inventory::player1}
        if player is {_other}:
            set {_other} to {shared_inventory::player2}
        wait 1 tick
        loop all items in player's inventory:
            set slot loop-index of {_other}'s inventory to loop-value

on inventory close:
    if player is {shared_inventory::player1} or {shared_inventory::player2}:
        set {shared_inventory::player1} to none
        set {shared_inventory::player2} to none
        message "Inventory sharing has ended!" to player