#why does this not work?

1 messages · Page 1 of 1 (latest)

hushed stream
#

good question! unfortunately as you didnt tell us what you mean by "not work[ing]", we arent exactly sure what the issue is and thus cant exactly explain anything.

You can however, try debugging the code and that will likely show you where things break

real portal
#

i thought maybe someone else instantly sees something thats off uk

hushed stream
#

okay, well then it clearly (a) doesnt do what you want it to, or (b) affects other things that its not supposed to.
Can you explain that?

real portal
#

the on first join seems to work, the broadcast and stuff work but when i do the command it doesn nothing, sends nothing either

hushed stream
real portal
#

will it not only run after doing the command once?

hushed stream
#

right now, I would think that the while loop is crashing your server, as it never ends

#

The first loop, if the abletowelcome variable is true, it will be set to false, but from there the loop just repeatedly runs the else: section infinitely

#

-# Also I would use ableToWelcome to make the variable easier to read as well, and delete the variable instead of setting it to false, as that saves storage space for unused variables

hushed stream
real portal
#

okay

#

so

#
    broadcast "{@prefix} /welcome %player% for some goodies!"
    set {welcome} to true
    loop all players:
        set {abletowelcome::%uuid of loop-player%} to true
    wait 20 seconds
    set {welcome} to false
    
command /welcome:
    aliases: wc
    trigger:
        if {abletowelcome::%uuid of player%} is true:
            while {welcome} is true:
                send "{@prefix} You got some rewards for welcoming a new player!"
                set {_chance} to random number between 1 and 3
                if {_chance} is 1:
                    add 150 to {coins::%uuid of player%}
                    send "You received 250 coins!"
                else if {_chance} is 2:
                    add 10 to {tokens::%uuid of player%}
                    send "You received 10 tokens!"
                else if {_chance} is 3:
                    add 1 to {gems::%uuid of player%}
                    send "You received 1 gem!"
                set {abletowelcome::%uuid of player%} to false
            stop
        else:
            send "{@prefix} You have already welcomed this player!"```
#

it was an infinite loop

#

so

#

idk how to stop it properly then

rich nimbus
#

in the while loop

#

add like

#

wait 1 second

#

doesnt REALLY matter where

#

but it NEEDS to exist

#

or the while loop will loop infinitely in 1 tick and destroy everything

real portal
#

yeah it just did 😭

rich nimbus
#

(could be wait 1 tick but im pretty sure you dont need this running that often in this case)

hushed stream
#

maybe when the player welcomes, add them to a list like {-hasWelcomed::*}, then you can use that to check if they have already welcomed. Once a new player joins, you can delete this list, and all players within it can then welcome the newest join

rich nimbus
#

no wait

#

WHY ARE WE EVEN USING A WHILE LOOP FOR THIS WHATTT

#

UR GONNA GIVE PEOPLE AN INF QUANTITY OF REWARDS

real portal
#

this - isnt ram for me

real portal
hushed stream
real portal
#

yeah ik

#

havent done that yet on this server

rich nimbus
hushed stream
real portal
#

fair

real portal
#
    aliases: wc
    trigger:
        if {welcome} is true:
            if {abletowelcome::%uuid of player%} is true:
                send "{@prefix} You got some rewards for welcoming a new player!"
                set {_chance} to random number between 1 and 3
                if {_chance} is 1:
                    add 150 to {coins::%uuid of player%}
                    send "You received 250 coins!"
                else if {_chance} is 2:
                    add 10 to {tokens::%uuid of player%}
                    send "You received 10 tokens!"
                else if {_chance} is 3:
                    add 1 to {gems::%uuid of player%}
                    send "You received 1 gem!"
                set {abletowelcome::%uuid of player%} to false
            else:
                send "{@prefix} You have already welcomed this player!"```
rich nimbus
#

atm i see no reason for a loop

#

there you go

#

that looks better

hushed stream
real portal
#

ill fix that

#

ty

rich nimbus