#Issue with inventory updates

1 messages · Page 1 of 1 (latest)

river breach
#

Hi there, trying to make a Crash gambling skript out of boredom. I have a multiplier starting at 1.0 increasing every 0.01x every 1 tick. This multiplier is shown in a GUI and when a player hovers over the item, the multiplier lore updates really slowly (e.g 1.02x -> 1.12x -> 1.12x OR 1.02x -> 1.22x -> 1.42x). One way to combat this is to keep opening the GUI to the player so it updates for them, but if they try clicking on the Multiplier item (the item that you need to click to cash out, and also view the multiplier then it just doesn't let you click at all, probably because the GUI is being opened every tick. Does anyone know of a possible solution to this?

Before you ask questions:
Have you tried setting the slot of the inventory only instead of opening the gui to the player every tick?
yes, I have. It just updates slowly like shown above 1.02x -> 1.12x etc. I have even debugged it by sending messages, it always sends the msg but barely updates

Why dont you use something else like a boss bar/title to show the multiplier instead?
Some people have their boss bars/titles disabled, it wouldnt really be ideal for that

Why dont you open the crash GUI to the player every other tick? (e.g +0.01x multi every tick, open gui to player every 2 ticks)
The multiplier will be very inaccurate causing it to only update every +0.02, and if the multiplier crashes at an odd number it will be really confusing for the players.

I would really appreciate any help from anyone, as well as criticism. I am not sure if Skript has a built in method to update inventories after a certain threshold as some kind of lag protection measure, or if its the variable saving being delayed.

real dust
#

have you tried on inventory open, then a while loop that updates the slot while the inventory is open?

river breach
#

like mentioned above, having any loop setting the slot of the opened inventory will not give that fast live update, it simply is delayed

#

which is probably due to skript's variables not saving quick enough or a built in method to prevent lag via gui's

#

im like 99.99% sure if it was set with a local variable it wouldnt be delayed at all (setting a local variable to the global variable still wouldnt work ive tried that before)

#

i could be wrong

livid scaffold
#

What did you try to just update the slot?

#

Seems like it would be doable

river breach
#

i have already tried updating the inventory slot instead of opening the GUI, but it updates slowly

#

because of said reasons earlier, skript variable saving slowly/after custom threshold, skript having anti lag feature via limiting updates via custom threshold

livid scaffold
river breach
#

set slot of players current inventory

#

in a while loop while players current inventory = “etc etc”

#

or maybe im not understanding your question here idk

real dust
river breach
#

ive tried literally almost everything

real dust
river breach
#

that does not change the fact that the inventory updates slowly even if you set the slot of the global variable OR the current player inventory

real dust
#

and send sk info

river breach
#
  if {multiplier} is set:
    while {multiplier} is set:
      wait 1 tick
      set slot 4 of {crash} to a nether star named "&c&lCASH OUT" with lore "&aMultiplier: &f%{multiplier}%x"
      loop all players:
        if name of loop-player's current inventory is "&d&lCRASH! &7Multiplier based gambling":
          wait 1 tick
          open {crash} to loop-player
      add 0.01 to {multiplier}
      chance of 1%:
        set slot 4 of {crash} to a redstone block named "&4&lCRASHED!" with lore "&aMultiplier: &f%{multiplier}%x"
        if {multiplier} >= 2:
          broadcast "&b&lCRASH: &aThe previous game just hit &f&l%{multiplier}%x! &b&lWOW! (/crash)"
``` this is my code rn, in the loop I have it open the gui instead of setting
#

since the inventory updates slow, but this issue where people cant click on items persist

#

since the inventory is being opened every tick

#

ive added "wait 1 tick" to the open gui loop and its still inaccurate

real dust
#

i would highly recommend not looping all players every tick

river breach
#

this is in the on load event

real dust
#

that's even worse

river breach
#

i have a /crash command where it opens this same gui for people too

#

it just doesnt work for some reason

real dust
river breach
#

well the loop is exited at the end

real dust
#

and it doesn't stop when u reload the script

river breach
#

the loop for opening the gui to the player isnt necessarily needed

#

but the loop to increase the multiplier is

#

I can remove the loop all players part sure

real dust
#

update your server

#

and skript

#

use 2.6.4

#

ur a whole major version behind

river breach
#

im sticking on 1.12.2 since my production server runs on 1.12.2, no additional questions have to be asked about why i run my server on this version

#

i will update skript

river breach
real dust
#

u do know that loops don't stop when a script is reload, right?

#

and a brand new loop is created every time it is called

#

so every time u reload the script, ur adding an additional loop to the server

river breach
#

if thats the case then my pc should have died, im running it on a localhost

river breach
#

I didnt add it here

#

I have it at the end of my on load event

#
  if {multiplier} is set:
    while {multiplier} is set:
      wait 1 tick
      set slot 4 of {crash} to a nether star named "&c&lCASH OUT" with lore "&aMultiplier: &f%{multiplier}%x"
      add 0.01 to {multiplier}
      chance of 3%:
        set slot 4 of {crash} to a redstone block named "&4&lCRASHED!" with lore "&aMultiplier: &f%{multiplier}%x"
        if {multiplier} >= 2:
          broadcast "&b&lCRASH: &aThe previous game just hit &f&l%{multiplier}%x! &b&lWOW! (/crash)"
        delete {playerbet::*}
        delete {multiplier}
#        wait 5 seconds
#        reload script "crash"
        exit loop
real dust
#

ok good

#

here's what would be the most efficient:

<event or command>:
    open inv
    format inv
    while name of player's current inventory is <name>:
        set slot X of player's inventory to <new item>
river breach
#

format inventory?

real dust
#

set slot x of {_inv} to ...

river breach
#

well

#

Im not sure if that would make any difference to the multiplier updating smoothly

#

but ill try

real dust
river breach
#

most likely

river breach
#

Idk if thats gonna hinder it

river breach
#

still same result, it updates slowly

#

I even tried setting the item using a local variable

#

it updates slowly aswell

real dust
#

have u tried using a brand new server with just skript and nothing else?

#

no other scripts or plugins running

river breach
#

just essentials vault and skript

#

same thing

river breach
#

bump

livid scaffold
river breach
#

it doesnt affect inventories, only things like physics and farms iirc

#

and the default value of randomTickSpeed is 3

river breach
#

bump (2)

wanton birch
#

at least try updating Skript to 2.6.4, since that is the most-recent version that should run on minecraft 1.12

river breach
#

bump (3)

livid scaffold
#

send full code

river breach
#

problem solved by a dear friend @lean palm (code issue/wasnt efficient)

#

this post is now resolved, thanks to everyone who tried helping me out