GithubHelp home page GithubHelp logo

Comments (12)

Pilvinen avatar Pilvinen commented on June 5, 2024

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.

Pilvinen avatar Pilvinen commented on June 5, 2024

Try what this gives you:

  1. Grab some items.
  2. Load skript below.
  3. 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.

Primorior avatar Primorior commented on June 5, 2024

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.

Pilvinen avatar Pilvinen commented on June 5, 2024

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.

Primorior avatar Primorior commented on June 5, 2024

Nope, does not work^^

from skript.

Pilvinen avatar Pilvinen commented on June 5, 2024

One thing you could try would be adding 1 tick delay right after "on respawn:" because we've established that:

  1. The list gets made -->
  2. 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.

Primorior avatar Primorior commented on June 5, 2024

Still does not work

from skript.

Pilvinen avatar Pilvinen commented on June 5, 2024

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.

Primorior avatar Primorior commented on June 5, 2024

Broadcasting works, adding loop-value doesn't, but it loads without any error^^

from skript.

Pilvinen avatar Pilvinen commented on June 5, 2024

Could be a bug then. Or several.

You could try:

    give loop-value to player

from skript.

Primorior avatar Primorior commented on June 5, 2024

omg it's working xDD thanks :)

from skript.

bensku avatar bensku commented on June 5, 2024

Adding list of items to inventory is fixed in next release.

from skript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.