Creative+ How can I clear all placed blocks by a player after ending a game?

veddnt

Active member
Joined
Jun 2, 2023
Messages
201
yeah so
place block -> append element(%player%_blocks-placed, block location)

function(Extract) -> if var(%player%_current-Index, more than 0) -> get element(%player%_blocks-placed, %player%_current-Index, %player%_block-location) -> set block( %player%_block-location, air) -> decrement(%player_current-Index) -> wait(1/2tick) -> call function(Extract) (ELSE Create array(%player%_blocks-placed) -> OPTIONAL Send message{all}( &cRemoved all the blocks placed by %player%.)

Note: set the variable "%player%-current-Index" to Array length(%player%_block-placed) before calling function(Extract)
Edit: Thanks for the likes <3
Edit(2): Forgot to delete array after its done going through all of the locations. ADDED
 
Last edited:

NeRdGM

New member
Joined
Sep 3, 2023
Messages
15
yeah so
place block -> append element(%player%_blocks-placed, block location)

function(Extract) -> if var(%player%_current-Index, more than 0) -> get element(%player%_blocks-placed, %player%_current-Index, %player%_block-location) -> set block( %player%_block-location, air) -> wait(1/2tick) -> decrement(%player_current-Index) ELSE Create array(%player%_blocks-placed) -> OPTIONAL Send message{all}( &cRemoved all the blocks placed by %player%.)

Note: set the variable "%player%-current-Index" to Array length(%player%_block-placed) before calling function(Extract)
Edit: Thanks for the likes <3
Edit(2): Forgot to delete array after its done going through all of the locations. ADDED
thanks ;)
 

Attachments

  • gato.jpg
    gato.jpg
    3.6 KB · Views: 0

NeRdGM

New member
Joined
Sep 3, 2023
Messages
15
yeah so
place block -> append element(%player%_blocks-placed, block location)

function(Extract) -> if var(%player%_current-Index, more than 0) -> get element(%player%_blocks-placed, %player%_current-Index, %player%_block-location) -> set block( %player%_block-location, air) -> wait(1/2tick) -> decrement(%player_current-Index) ELSE Create array(%player%_blocks-placed) -> OPTIONAL Send message{all}( &cRemoved all the blocks placed by %player%.)

Note: set the variable "%player%-current-Index" to Array length(%player%_block-placed) before calling function(Extract)
Edit: Thanks for the likes <3
Edit(2): Forgot to delete array after its done going through all of the locations. ADDED
Could you send a picture of the code? I think I'm dumb or something.
 

Attachments

  • rizz.jpg
    rizz.jpg
    4.7 KB · Views: 1

NeRdGM

New member
Joined
Sep 3, 2023
Messages
15
yeah so
place block -> append element(%player%_blocks-placed, block location)

function(Extract) -> if var(%player%_current-Index, more than 0) -> get element(%player%_blocks-placed, %player%_current-Index, %player%_block-location) -> set block( %player%_block-location, air) -> wait(1/2tick) -> decrement(%player_current-Index) ELSE Create array(%player%_blocks-placed) -> OPTIONAL Send message{all}( &cRemoved all the blocks placed by %player%.)

Note: set the variable "%player%-current-Index" to Array length(%player%_block-placed) before calling function(Extract)
Edit: Thanks for the likes <3
Edit(2): Forgot to delete array after its done going through all of the locations. ADDED
+ ophelios said his code works better
 

Ophelios

New member
Joined
Sep 3, 2023
Messages
9
yeah so
place block -> append element(%player%_blocks-placed, block location)

function(Extract) -> if var(%player%_current-Index, more than 0) -> get element(%player%_blocks-placed, %player%_current-Index, %player%_block-location) -> set block( %player%_block-location, air) -> wait(1/2tick) -> decrement(%player_current-Index) ELSE Create array(%player%_blocks-placed) -> OPTIONAL Send message{all}( &cRemoved all the blocks placed by %player%.)

Note: set the variable "%player%-current-Index" to Array length(%player%_block-placed) before calling function(Extract)
Edit: Thanks for the likes <3
Edit(2): Forgot to delete array after its done going through all of the locations. ADDED
You forgot to recall the function but besides that it works great. Only problem is dumb nerd wannabe forgot to say it is a global code, not local.
 

veddnt

Active member
Joined
Jun 2, 2023
Messages
201
thanks i added calling function and uh the other part idk context
 

veddnt

Active member
Joined
Jun 2, 2023
Messages
201
Basically this guy wanted it global, so without %player% but instead said by a player.
oh so that blocks placed by all players at once?
just remove %player% from everything ¯\_(ツ)_/¯
 
Top