#Need help with an RTP-Queue skript

1 messages · Page 1 of 1 (latest)

wide vortex
#

im making an rtpqueue skript but im running into a problem when the block location that the skript randomly finds doesnt follow the requirements of not being water, air, or sand, and it just stops. i dont know how to make it continously check, can anyone give some advice on how i do it?

command /rtpqueue:
    trigger:
        if {rtpqueue::looking::searching::%player%} is not set:
            add 1 to {rtpqueue::looking}
            set {rtpqueue::looking::%player%} to player

            send "&aYou're now looking for an RTP fight. Use &7/rtpqueue &ato &cleave &aqueue." to player
            send "&aThere are currently &f%{rtpqueue::looking}% &aplayer(s) in queue."
            
            set {rtpqueue::looking::searching::%player%} to true
            if {rtpqueue::looking} is greater than 1:
                set {x} to random number between -5000 and 5000
                set {z} to random number between -5000 and 5000
                set {rtplocation} to highest block at location ({x}, 0, {z})
                loop all blocks above {rtplocation}:
                    if loop-block is air:
                        block below loop-block is not water[]
                        block below loop-block is not air
                        block below loop-block is sand
                        if block above loop-block is air:
                            teleport {rtpqueue::looking::*} to block above {rtplocation}
                            send action bar "&aYou've been teleported for an RTP fight!" to {rtpqueue::looking::*}
                            send "&aYou've been teleported for an RTP fight!" to {rtpqueue::looking::*}
                            clear {rtpqueue::looking}
                            clear {rtpqueue::looking::*}
                            clear {rtpqueue::looking::searching::%player%} 
#

I tried creating a function, but there is "no player in a function event":

function findSuitableLocation():
    set {x} to random number between -5000 and 5000
    set {z} to random number between -5000 and 5000
    set {rtplocation} to highest block at location ({x}, 0, {z})
    loop all blocks above {rtplocation}:
        if loop-block is air:
            if block below loop-block is not water[]:
                if block below loop-block is not air:
                    if block below loop-block is sand:
                        if block above loop-block is air:
                            teleport {rtpqueue::looking::*} to block above {rtplocation}
                            send action bar "&aYou've been teleported for an RTP fight!" to {rtpqueue::looking::*}
                            send "&aYou've been teleported for an RTP fight!" to {rtpqueue::looking::*}
                            clear {rtpqueue::looking}
                            clear {rtpqueue::looking::*}
                            clear {rtpqueue::looking::searching::%player%} 
                    else:
                        findSuitableLocation()
                else:
                    findSuitableLocation()
            else:
                findSuitableLocation()
        else:
            findSuitableLocation()
#

sorry for block text ik it's a lot

#

i hope someone can help tho :)

hollow pebble
#

is there an error?

#

you are looking at all the block Above the location but looking at the loop block below can it be why?

wide vortex
#

the skript basically just randomly gets coordinates, and if the block at the top is sand then it will teleport the player

#

if it isnt sand, then it doesnt retry

#

idk how to make it retry until it gets the right thing

hollow pebble
#

maybe don't look at all block above the location?

wide vortex
#

no that's not the issue

#

it's not glitching

#

the skript is working proper, for how it's written

#

i just want to add additional functionality to it

#

and idk how to do it

hollow pebble
wide vortex
#

ill write it out

hollow pebble
wide vortex
#

oh

#

wait lemme try that

hollow pebble
#

{rtpqueue::looking::searching::%{_p}%}

hollow pebble
#

so i saw your error

#

and it's understandable :P

wide vortex
#

that was a mistake on my end

#

can i do function findSuitableLocation(w: world):

#

and how would i do two things in one function?

#

is that possible

hollow pebble
hollow pebble
wide vortex
#

hmm im not calling the world anyway so i dont think it would work

hollow pebble
#

and when you try to execute the function it's trigger: findSuitableLocation(player, world):

wide vortex
#

this is just with function findSuitableLocation(p: player):

hollow pebble
#

you are still in the function so you will use the variable

#

mf discord aint letting me

#

well you use the variable sooooo

wide vortex
#

okay

#

okay just one error 🙌

#

hmm wait imma try smth

hollow pebble
wide vortex
#

yay

#

set {rtplocation} to highest block at location ({x}, 0, {z}) in world "world"

hollow pebble
#

i think yeah

wide vortex
#

now to test 😋

#

womp wopm

#

i think i can fix that

hollow pebble
#

eh

wide vortex
#

it was like this but i js removed them and kept the last one

#

that should fix it right?

hollow pebble
#

nope

#

i don,t think so

#

send the code rq

wide vortex
#

ok

#

⁉️

hollow pebble
#

bro what ;-;

wide vortex
#

uhmm

#

idk

#

it's not letting me send

#

wait

#
function findSuitableLocation(p: player):
    set {x} to random number between -5000 and 5000
    set {z} to random number between -5000 and 5000
    set {rtplocation} to highest block at location ({x}, 0, {z}) in world "world"
    loop all blocks above {rtplocation}:
        if loop-block is air:
            if block below loop-block is not water[]:
                if block below loop-block is not air:
                    if block below loop-block is sand:
                        if block above loop-block is air:
                            teleport {rtpqueue::looking::*} to block above {rtplocation}
                            send action bar "&aYou've been teleported for an RTP fight!" to {rtpqueue::looking::*}
                            send "&aYou've been teleported for an RTP fight!" to {rtpqueue::looking::*}
                            clear {rtpqueue::looking}
                            clear {rtpqueue::looking::*}
                            clear {rtpqueue::looking::searching::%{p}%}
                    else:
                        findSuitableLocation({p})
#
command /rtpqueue:
    trigger:
        if {rtpqueue::looking::searching::%player%} is not set:
            add 1 to {rtpqueue::looking}
            set {rtpqueue::looking::%player%} to player

            send "&aYou're now looking for an RTP fight. Use &7/rtpqueue &ato &cleave &aqueue." to player
            send "&aThere are currently &f%{rtpqueue::looking}% &aplayer(s) in queue."
            
            set {rtpqueue::looking::searching::%player%} to true
            if {rtpqueue::looking} is greater than 1:
                findSuitableLocation(player)
                
        else if {rtpqueue::looking::searching::%player%} is true:
            send "&cYou have left the RTP Queue. Use &7/rtpqueue &cto &arejoin &cthe queue." to player
            clear {rtpqueue::looking}
            clear {rtpqueue::looking::*}
            clear {rtpqueue::looking::searching::%player%} 
            stop
#

okay that works

#

breaking it up

#

hmm no it doesnt work

#

doesnt even teleport me

#

you were right

hollow pebble
#
    set {gudplace::%{_p}%} to false
    while {gudplace::%{_p}%} is false:
        set {x} to random number between -5000 and 5000
        set {z} to random number between -5000 and 5000
        set {rtplocation} to highest block at location ({x}, 0, {z}) in world "world"
        loop all blocks above {rtplocation}:
            if loop-block is air:
                if block below loop-block is not water[]:
                    if block below loop-block is not air:
                        if block below loop-block is sand:
                            if block above loop-block is air:
                                teleport {rtpqueue::looking::*} to block above {rtplocation}
                                send action bar "&aYou've been teleported for an RTP fight!" to {rtpqueue::looking::*}
                                send "&aYou've been teleported for an RTP fight!" to {rtpqueue::looking::*}
                                clear {rtpqueue::looking}
                                clear {rtpqueue::looking::*}
                                clear {rtpqueue::looking::searching::%{p}%}
                                set {gudplace::%{_p}%} to true```
#

try that

wide vortex
#

ok

#

oo

#

thanks

#

it works

hollow pebble
#

:D

wide vortex
#

i have a question though

hollow pebble
#

?

wide vortex
#

why did you add the player to the variable

#

is that necessary

hollow pebble
#

yes

wide vortex
#

{gudplace::%{_p}%} instead of {gudplace}

#

cuz i actually tried that earlier without the player

#

and it didnt work

hollow pebble
#

otherwise if someone tried to do the command also the other player would be stuck in the loop with the other player until it find a good place

#

we just do that so nobody get stuck :P

wide vortex
#

is there any possiblity that it can cause a lot of lag?

hollow pebble
#

you can always delete the var after

wide vortex
#

if it takes a while to find a location

wide vortex
hollow pebble
hollow pebble
wide vortex
#

okay

#

thanks a lot 🙏