variables:
{dutyInv::%player%} = false
command /duty:
trigger:
if {dutyInv::%player%} is not false:
send "&cYou are already on duty!" to player
stop
set {dutyInv::%player%} to player's inventory
clear player's inventory
send "&aYou are now on duty!" to player
command /offduty:
trigger:
if {dutyInv::%player%} is false:
send "&cYou are not on duty!" to player
stop
set player's inventory to {dutyInv::%player%}
delete {dutyInv::%player%}
send "&aYou are now off duty!" to player```
#Can skript save players inventories? If so is this correct?
1 messages · Page 1 of 1 (latest)
- https://tryitands.ee
- Yes, but they cant be saved in variables over a server restart. If you need to do that, look into serialising the inv into NBT
Very helpful..
when I was trying to learn this I used a skript I found and its this:
command /showinv [<player>]:
permission: op
trigger:
if arg 1 is set:
if {stuff::%arg 1%::*} exists:
open chest inventory with 6 rows named "Saved Inventory" to player
set {_slot} to -1
loop {stuff::%arg 1%::*}:
add 1 to {_slot}
set slot {_slot} of player's current inventory to loop-value
else:
if {stuff::%player%::*} exists:
open chest inventory with 6 rows named "Saved Inventory" to player
set {_slot} to -1
loop {stuff::%player%::*}:
add 1 to {_slot}
set slot {_slot} of player's current inventory to loop-value
command /saveinv [<player>]:
permission: op
trigger:
if arg 1 is set:
delete {stuff::%arg 1%::*}
loop all items in arg 1's inventory:
add loop-item to {stuff::%arg 1%::*}
send "&a&l[✓] &fSaved &7&o%size of {stuff::%arg 1%::*}%&r&f items."
else:
delete {stuff::%player%::*}
loop all items in player's inventory:
add loop-item to {stuff::%player%::*}
send "&a&l[✓] &fSaved &7&o%size of {stuff::%player%::*}%&r&f items."
command /setinv:
permission: op
trigger:
set player's current inventory to {stuff::%player%::*}
Feel free to play with this and the best way to understand is just to poke around in it
You never stated anythin was wrong with that code so how were we supposed to help you?