#Hola, Soy Dora. Do you see the bug that makes this trash heap crash the server?

1 messages · Page 1 of 1 (latest)

rigid elbow
#

``on sneak toggle:
set {goliath} to event-player
{goliath} is not sneaking
loop lore of event-player's held item:
if loop-value is "&7&oIt only takes one to end a war":

        set {w} to difference between now and {superaxe.%player's uuid%.lastSneak}

        if {w} is greater than 5 seconds:
            send action bar "&7Cooldown:&2 Active" to {goliath}
            set {w} to now
            loop entities in radius 5 around {goliath} where [input is not {goliath}]:
                set {_pitch} to a random integer from 1 to 0.5
                play sound "entity.warden.sonic_boom" at volume 2 and pitch 7 at {goliath}
                set {vector} to vector between {goliath} and loop-entity
                push loop-entity up at speed 0.5
                wait 1 tick
                push loop-entity {vector} at speed 1
        else:
            while event-player is player:
                if {w} is less than 5 seconds:
                    wait 0.1 seconds
                    send action bar "&7Cooldown:&c %difference between now and {superaxe.%player's uuid%.lastSneak}%" to {goliath}``
granite charm
#

no wait in the while loop

#

and what it this even meant to do
it's like saying while 1 is 1

#

and why are vector and w global variables??

#

goliath too?

rigid elbow
#

that can include an else statement

granite charm
#

what?

rigid elbow
#

if balls:
while balls are true:

granite charm
#

loops don't have else statements

rigid elbow
#

else:

rigid elbow
rigid elbow
granite charm
#

i'm telling you you don't have one

#

that's the bug

granite charm
#

so the while loop will never stop running

rigid elbow
#

shoot my partner must of removed it

#

ahhh

#

im a smarty pants

#
on sneak toggle:
    set {goliath} to event-player
    {goliath} is not sneaking
    loop lore of event-player's held item:
        if loop-value is "&7&oIt only takes one to end a war":
     
            set {w} to difference between now and {superaxe.%player's uuid%.lastSneak}
    
            if {w} is greater than 5 seconds:
                send action bar "&7Cooldown:&2 Active" to {goliath}
                set {w} to now
                loop entities in radius 5 around {goliath} where [input is not {goliath}]:
                    set {_pitch} to a random integer from 1 to 0.5
                    play sound "entity.warden.sonic_boom" at volume 2 and pitch 7 at {goliath}
                    set {vector} to vector between {goliath} and loop-entity
                    push loop-entity up at speed 0.5
                    set difference between now and {superaxe.%player's uuid%.lastSneak} to now
                    wait 1 tick
                    push loop-entity {vector} at speed 1
            else:
                while {w} is less than 5 seconds:
                        wait 1 tick
                        send action bar "&7Cooldown:&c %difference between now and {superaxe.%player's uuid%.lastSneak}%" to {goliath}```
granite charm
#

w, goliath, and vector should still be local vars tho

#

(and you never reset the cooldown)

rigid elbow
#

what are local var

granite charm
#

you're literally using one

#

_pitch

#

well actually you're never using it

#

what are you doing mate

rigid elbow
#

erm

granite charm
#

did you just add set difference between now and {superaxe.%player's uuid%.lastSneak} to now?

rigid elbow
#

yes

granite charm
#

why would you think that would work

rigid elbow
#

im really bad with syntaxes

granite charm
#

actually this whole thing is a mess

#

i don't even know where to start

rigid elbow
#

yes 😄

granite charm
#

first off:

rigid elbow
#

see why im always in skript help

#

still typing 😰

granite charm
#

basic cooldown structure:

if ({your-timestamp} ? (1 second ago)) is less than now:
    send "yay cooldown over"
    set {your-timestamp} to 5 seconds from now # a new time, some amount of time in the future
else:
    send "oh no! cooldown not over"```
rigid elbow
#

right

#

in this code we have the succsess on if statement and a while loop in the fail to have a live cooldown count

granite charm
#

this should be replaced by a contains

granite charm
rigid elbow
#

thank you for visiting my helpless corner btw much apprecaite

granite charm
#

this is all fine

rigid elbow
#

yay

#

that would be my part 😀

#

(its all just stolen code)

#

patched together

granite charm
#

you should not wait 1 tick in the loop entities... loop, then it'll wait 1 tick for each entity in range
you should instead finish the loop, wait 1 tick outside the loop, and then loop again to do the final push

rigid elbow
#

im so dumb i have to check the documentation to be remined how skript works every day bro

#

yes i remeber seeing that

granite charm
#

finally, {goliath} shouldn't even be a variable

#

just use player

rigid elbow
#

it was pretty funny it made like a waterfal of entityies

rigid elbow
#

so the reason people use _ is to make it local?

granite charm
#

yes

rigid elbow
#

its not just like wool for redstoners

granite charm
#

you should also be using :: instead of . in your variable names

#

then they'll be lists, which can be manipulated much more easily

rigid elbow
#

its just a nother period on top whats the diff?

granite charm
#

what happens if you want to clear every player's cooldowns?

#

if you're using ., you have to literally know every player's uuid, no matter if they're online or haven't played in 2 months

rigid elbow
#

only one person is gonn abe able to do this skript

granite charm
#

if you're using ::, you just have to do clear {cooldowns::*} or whatever

rigid elbow
#

ah

#

so extra dots just makes it smarter

rigid elbow
#

is this fine or should i change it up?

granite charm
#

i mean it can easily cause you to have multiple while loops running at once

#

but if this is for a single person it's not a huge deal

#

oh wait

#

that's very dumb

#

can you spot the issue

rigid elbow
#

fffttt

#

see this is the issue when my partner tries to fix my own code but doesnt fix all of it

granite charm
#

well this is just a simple logic thing

#

the if checks if w > 5

#

so anything inside it will se a w that's bigger than 5

rigid elbow
#

which just wouldnt

granite charm
#

and therefore the while loop will never run
because it's looking for < 5

rigid elbow
#

unless 5 was somehow so fat it became 5.1 to 4.9

#

wait, im swtiching the if and else so thats gotta be less than or equal

#
on sneak toggle:
    player is not sneaking
    lore of player's tool contains "&7&oIt only takes one to end a war"
    if ({superaxe-cooldown::%player's uuid%} ? (1 second ago)) is less than now:
        set {superaxe-cooldown::%player's uuid%} to 5 seconds from now
        
        set {_pitch} to a random integer from 1 to 0.5
        play sound "entity.warden.sonic_boom" at volume 2 and pitch {_pitch} at player
        set {_nearby-entities::*} to entities in radius 5 around player where [input is not player]  
        push {_nearby-entities::*} up at speed 0.5
        wait 1 tick
        loop {_nearby-entities::*}:
            set {_vector} to vector between player and loop-value
            push loop-value {_vector} at speed 1
            push loop-value down at speed 0.2
        while {superaxe-cooldown::%player's uuid%} is greater than now:
            if difference between now and {superaxe-cooldown::%player's uuid%} >= 0.5:
                send action bar "&7Cooldown:&c %difference between now and {superaxe-cooldown::%player's uuid%}%" to player
                wait 1 tick
            else:
                send action bar "&7Cooldown:&2 Active" to player

#

okay here we go

granite charm
#
on sneak toggle:
    player is not sneaking

    # first: we don't need everything in a loop, just use contains
    lore of player's tool contains "&7&oIt only takes one to end a war"

    # second: let's improve the cooldown
    # we'll use a timestamp that's set to some future time, and check if it's in the past
    # if it is, the cooldown's over. We also use a default value of 1 second ago so that the first time the player uses the ability, it's not on cooldown
    if ({superaxe-cooldown::%player's uuid%} ? (1 second ago)) is less than now:
        # if the cooldown's over, we set the timestamp to 5 seconds from now, or whatever the cooldown is
        set {superaxe-cooldown::%player's uuid%} to 5 seconds from now
        # then we do the ability
        send action bar "&7Cooldown:&2 Active" to player

        # i'm assuming you actually meant to only play the sound once
        # because it's kinda weird to play it once for each player nearby
        # and i'm also assuming you meant to use {_pitch}
        set {_pitch} to a random integer from 1 to 0.5
        play sound "entity.warden.sonic_boom" at volume 2 and pitch {_pitch} at player

        # since we need to wait a tick in between doing things to nearby entities, we'll store all the entities in a local var
        set {_nearby-entities::*} to entities in radius 5 around player where [input is not player]
        
        # since we've moved around a lot of the stuff that was in the loop, all we're left with is a `push` effect
        # this can just act on the list all at once, without needing a loop
        push {_nearby-entities::*} up at speed 0.5

        # then we wait for them to get into the air, and push them again, this time in various directions
        wait 1 tick
        loop {_nearby-entities::*}:
            set {_vector} to vector between player and loop-value
            push loop-value {_vector} at speed 1

        # finally, let's show the cooldown to the player as long as it's not over
        while {superaxe-cooldown::%player's uuid%} is greater than now:
            send action bar "&7Cooldown:&c %difference between now and {superaxe-cooldown::%player's uuid%}%" to player
            wait 1 tick

    # if the cooldown's not over, just stop, we don't need to do anything else```
this is what I would do
#

(though I'd probably also put the cooldown in a metadata tag, not a global var, but that's nit picking)

rigid elbow
#

yay

#

its so advanced wth

#

what does ::* do

rigid elbow
#

oh no not lists

#

i remeber this from school

#

ever since we went over for loops 2 years ago ive never understood a thing about python

granite charm
#

well good thing this isn't python

rigid elbow
#

prob my fav part about skript tbh

#

shoot it crashed again

#
on sneak toggle:
    loop players:
        loop lore of loop-player's held item:
            if loop-value-2 is "&7&oIt only takes one to end a war":
                remove slowness and resistance and weakness and regeneration from potion effects of loop-player
#

theres also this but i dont think its causing a crash

granite charm
#

why is that in a separate event

rigid elbow
#

the whole push ability was a superate idea

#

jus tnot to confuse me cuz you know how i like my speggeti

granite charm
#

well it's really not a good idea

#

that clears the resistance of the holder when ANYONE shifts

#

plus it's just being wasteful

#
                remove slowness and resistance and weakness and regeneration from potion effects of player``` this can just go before all the cooldown stuff, right after the lore check
rigid elbow
#

sorry i got distracted

#

some chick was asking for help to make a box server and when i joined it was a total mes of bedrock so i had to atleast try and help

#

back now

#

after a quick sleep

#

and acedemic torture

rigid elbow
#

cooldown crap happens when you shift

granite charm
rigid elbow
#

But since the cooldown only updates by ticks, sometimes it finishes on 0.03 seconds and stays so imma make a cooldown complete action bar to overlap it

rigid elbow
#

now uh what if i told you there were two of these things