#not working when offline

1 messages · Page 1 of 1 (latest)

jolly quartz
#
loop all players:
                broadcast "%{beacon::%loop-player's uuid%}%"
                if {beacon::%loop-player's uuid%} contains location of event-block:
                    broadcast "%{beacon::%loop-player's uuid%}%"
                    broadcast "{@prefix} &8›&f The beacon of &3%loop-player%&f was broken by &3%event-player%!"
                    loop all blocks in radius 20 around {beacon::%loop-player's uuid%}:
                        if loop-block is a cracked stone bricks:
                            set {_d} to string tag "custom;OwnerD" of nbt compound of loop-block
                            if {_d} is uuid of loop-player:
                                set loop-block to air
                    delete {beacon::%loop-player's uuid%}
#

so what im trying to do is

#

if players beacon gets broken while he is offline it should break normally but it doesn't

#

even tho it broadcasts the variable

harsh orchid
#

your code doesn't work because its looping all online players
you should probably do it with a block list instead of looping all players
you can add the beacon to a list (set its index to the player's uuid) and loop that list (loop-value is the player's beacon, uuid is the player and it'll always work when they are offline)

jolly quartz
orchid knoll
#

there's one in your other post

jolly quartz
#

wdym

#

which one i got 3

#

oh you mean while player is online?

orchid knoll
#

no, for looping offline players

jolly quartz
#

loop all offline players?

orchid knoll
jolly quartz
#

i tried looping all offline players but it didnt work

#

like just to try i removed the loop all player and tried it and didnt work

orchid knoll
jolly quartz
#

btw what does he mean with a “list”

orchid knoll
orchid knoll
jolly quartz
#

i know

orchid knoll
#

list variable

jolly quartz
#

how can i add the beacon to a list does he mean a variable or something

orchid knoll
#

which you already have

#

{beacon::%loop-player's uuid%}

jolly quartz
orchid knoll
jolly quartz
#

does he mean loop {beacon::%player’s uuid%::*}

orchid knoll
#

you have the right idea, but the * is one less

orchid knoll
jolly quartz
#

ohh

#

so {beacon::*}

#

loop {beacon::*}

#

so by doing this i hope it works

#

thanks let me try

jolly quartz
#

i have a question

#

okay wait

#

do i loop all players or not?

#

@orchid knoll (sorry for the ping)

orchid knoll
#

no

#

you loop the list instead

jolly quartz
#

just loop the list?

#

okay how do i get the player thats beacon broken and the player who broke it

#

do i just do %player% and %event-player%

harsh orchid
#

a list is not an event
it would be loop-value

jolly quartz
#

ohh

#

so %loop-value% and %event-player%

orchid knoll
#

okay

#

so do what it says

jolly quartz
#

okay so i did

#

it still doesnt for some reason

orchid knoll
jolly quartz
#

okay

#
loop {beacon::*}:
                broadcast "%{beacon::%loop-value's uuid%}%"
                if {beacon::%loop-value's uuid%} contains location of event-block:
                    broadcast "%{beacon::%loop-value's uuid%}%"
                    broadcast "{@prefix} &8›&f The beacon of &3%loop-value%&f was broken by &3%event-player%!"
                    loop all blocks in radius 20 around {beacon::%loop-value's uuid%}:
                        if loop-block is a cracked stone bricks:
                            set {_d} to string tag "custom;OwnerD" of nbt compound of loop-block
                            if {_d} is uuid of loop-value-1:
                                set loop-block to air
                        if loop-block is a stone bricks:
                delete {beacon::%loop-value's uuid%}
orchid knoll
#

...and what's the issue with this code

#

the loop-value is not the player

#

the index is the player's uuid

#

the value is whatever you set the variable to

jolly quartz
#

oh right

#

i mean

#

when u place a beacon its set to beacon::%player's uuid%

#

so do i use just loop-value

#

like

#

{beacon::%loop-value%}

orchid knoll
#

you are trying to insert a value as an index

#

{list::index} = value

jolly quartz
#

whats the right

#

so beacon is the list and index is player's uuid right

orchid knoll
#

set {list::index} to "value"

index = the index
"value" = the value for {list::index}

jolly quartz
harsh orchid
#

other way around

#

set {beacon::%uuid of player%} to loop-value

jolly quartz
#

okay

#

so i will set the list::index to loop-value which is {beacon::*}

#

wait whats the loop value of it let me broadcast

#

Ohhh

#

i get itt

#

the loop value is the location of it

#

@harsh orchid im sorry for the ping so i broadcasted the loop-value it showed this and from what im seeing, its all of the locations of beacons in the server?

#

i dont get it setting the location of the beacon to the loop-value which is all of the locations

harsh orchid
#

what you need is a list of beacons in the server, and the index of the list is the loop-player's uuid (so you can easily loop the list and get the player's beacon)
because it is broadcasting all the locations of the beacons, it looks fine (although i would set the value to the block itself and not the location of the block)
try broadcasting the indices of the list and see if it shows your uuid (if it does, then you probably did it correctly)

jolly quartz
#

so for the index it gave me the uuid of player's and for value of it, it gave me location of event block

harsh orchid
#

yay good job! your almost done
now you can loop the list, get the uuid of the player, and do whatever you want to their beacon (even if they are offline)

jolly quartz
#

set {_b} to loop-index?

#

or if i want the location of it

#

ohhh

#

i get it

#
loop {beacon::*}:
                set {_p} to loop-index
                if {beacon::%{_p}%} contains location of event-block:
                    broadcast "{@prefix} &8›&f The beacon of &3%{_p}%&f was broken by &3%event-player%!"
                    loop all blocks in radius 20 around {beacon::%{_p}%}:
#

i did this

#

is that okay?

#

it works!

harsh orchid
#

yay good job
you can use loop-value instead of {beacon::%{_p}%} inside your loop btw