Comments (12)
Does it work if you add the item to list and THEN remove it from drops? Also you are only doing stuff if the player has dirt and even then with only 50 chance. Make a test skript which always adds to list and see if it still bugs out.
from skript.
Try what this gives you:
- Grab some items.
- Load skript below.
- Die.
on death of player:
loop items in victim's inventory:
add loop-item to {inventory.%name of victim%::*}
loop {inventory.%name of victim%::*}:
broadcast " DEBUG: loop-index: %loop-index%, loop-value: %loop-value%"
If you had items when you died and you are getting "" then it's a bug in Skript. If you get item names then your code's structure might be wrong and it's not doing what you think it's supposed to do. For example if you always wish to loop the inventory and build the list then you need to move that part of the code on the same level with the if statement, thus:
on death of player:
if victim's inventory contains a dirt:
chance of 50%:
remove a dirt from drops
loop items in victim's inventory:
add loop-item to {inventory.%name of victim%::*}
remove loop-item from drops
on respawn:
add {inventory.%name of player%::*} to player's inventory
delete {inventory.%name of player%::*}
stop
from skript.
it gives the right output... strange.. but for some reasons, it doesn't gives the items
Edit:Tested this:
on death of player: loop items in victim's inventory: remove loop-item from drops add loop-item to {inventory.%name of victim%::*} on respawn: loop {inventory.%name of player%::*}: broadcast " DEBUG: loop-index: %loop-index%, loop-value: %loop-value%"
Edit2: http://paste.md-5.net/sedufirife.vhdl (Github-Code just broke the format)
No output ^^
from skript.
It could be the old bug that's been around for ages where in some cases %name of victim/player% or possibly %victim/player% from some events doesn't pass over correctly to other events. It gets corrupted somehow.
I'm not 100% sure how to reproduce it but it definitely needs some serious fixing.
The usual way around this problem is to - for example:
on death of player:
set {_playerUUID} to UUID of victim
if victim's inventory contains a dirt:
chance of 50%:
remove a dirt from drops
loop items in victim's inventory:
add loop-item to {inventory.%{_playerUUID}%::*}
remove loop-item from drops
on respawn:
set {_playerUUID} to UUID of player
add {inventory.%{_playerUUID}%::*} to player's inventory
delete {inventory.%{_playerUUID}%::*}
stop
That should work, I think. If it doesn't try setting it as text -> set {_playerUUID} to "%UUID of victim%", that should basically always work no matter what.
EDIT: If for some reason you don't want to/can't use UUID you can just use %victim% or %player% as I've shown above. Setting the value to a variable first is somehow more stable and usually gives less trouble.
from skript.
Nope, does not work^^
from skript.
One thing you could try would be adding 1 tick delay right after "on respawn:" because we've established that:
- The list gets made -->
- Therefore you should be able to access it.
Basically the player is still dead right when the respawn event happens so adding the items back to inventory not working might be attributed to that. After 1 tick delay the event has happened already and the player should be alive, so you might wish to try this:
on respawn:
wait for 1 ticks
set {_playerUUID} to UUID of player
add {inventory.%{_playerUUID}%::*} to player's inventory
delete {inventory.%{_playerUUID}%::*}
stop
If that doesn't work then @bensku will have to debug why it fails to work and I'm out of ideas.
from skript.
Still does not work
from skript.
How about changing this part like this in the "on respawn" event:
loop {inventory.%{_playerUUID}%::*}:
add loop-value to player's inventory
You could also try checking if you get any values:
loop {inventory.%{_playerUUID}%::*}:
broadcast " DEBUG: %loop-index%: %loop-value%"
from skript.
Broadcasting works, adding loop-value doesn't, but it loads without any error^^
from skript.
Could be a bug then. Or several.
You could try:
give loop-value to player
from skript.
omg it's working xDD thanks :)
from skript.
Adding list of items to inventory is fixed in next release.
from skript.
Related Issues (20)
- Prefixes HOT 7
- large_smoke particle generates error on Paper/Spigot 1.20.6 HOT 13
- NoClassDefFound Error HOT 3
- Legacy Code Tracker
- unexpected repair/damage behaviour HOT 4
- Add recently added attributes HOT 2
- Searching Feature
- Add experience class into accept change on ExprTotalExperience
- Add skript-reflect (or at least some features) into Skript HOT 1
- Expose required variable changes for save as a config option
- SimpleLiterals pass "constant" backing array to other syntax.
- Stop referencing the old Converter class in PropertyExpression HOT 2
- Wither HOT 2
- Allow `armour stand` as `armor stand` HOT 2
- Entities despawning when target is set HOT 1
- bStats syntax for Skript HOT 14
- Remove skript: from commands created in skript (config option) HOT 8
- New beta: not setting canceled event-block to bedrock
- Error HOT 1
- Tadpoles cannot spawn HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skript.