#why does this not work?
1 messages · Page 1 of 1 (latest)
no errors thats why lmao
i thought maybe someone else instantly sees something thats off uk
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?
the on first join seems to work, the broadcast and stuff work but when i do the command it doesn nothing, sends nothing either
I mean I see a while loop without a wait or path to terminate
will it not only run after doing the command once?
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
Or well it ends after 20s, but runiing the loop without a wait is still likely really bad
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
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
yeah it just did 😭
(could be wait 1 tick but im pretty sure you dont need this running that often in this case)
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
no wait
WHY ARE WE EVEN USING A WHILE LOOP FOR THIS WHATTT
UR GONNA GIVE PEOPLE AN INF QUANTITY OF REWARDS
this - isnt ram for me
but i stop it no?
you can enable that in the skript config
...the current code would literally infinitely reward someone until crashing
I think the point is this code doesnt need to be looped in the first place
fair
agree
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!"```
This is the simplest solution I can think of, you can add to it and customise it to fit your needs
yeah that'd be a better solution by far