#Pet skript
1 messages · Page 1 of 1 (latest)
Set a var or sometime when they use it
Then check how long its been since that var was set
im new to skript so i dont know how to do that could you post it or an example
set a var to now
Which is the current time
Then use
difference between now and var
Which will give you how long its been
Ex
if difference between now and {cd::%player's uuid%} >= 1 second:
it didnt work for me does it have to have addons for the sk to work
@remote furnace
:technologist: Code Blocks
To make it easier for others to read your code, it is asked that you send it in a code block. On Discord, you can simply send this:
```
Code here
```
on toggle sneak:
player is sneaking:
name of player's offhand tool is "&cVulture":
push player upwards with speed 0.5
push player forwards with speed 1.5
if difference between now and {cd::%player's uuid%} >= 1 second
cancel event
...
and error says
oh sorry
Dont just copy paste
ok
You didnt even copy paste correctly (you missed the :)
Also canceling the event just cancels the sneak
It doesnt do anything to your pushing
Put this check before you push then
And add a stop (it stops the rest of your code from running)
i did this and it doesnt work it doesnt have an error the cooldown just doesnt run
on toggle sneak:
player is sneaking:
name of player's offhand tool is "&cVulture":
push player upwards with speed 0.5
push player forwards with speed 1.5
if difference between now and {cd::%player's uuid%} is less than 1 second:
stop
else:
push player upwards with speed 0.5
push player forwards with speed 1.5
indention is 1 of the key thing to understand to be good at skript, so if you are not going to make a if statement you dont want to be using : at the end of the condition.
example;
on jump:
if player is online: # here is a ifstatement that ends with :, then the line under needs a indent
broadcast "r"
on jump:
player is online # here is a condition that does not have if and does not have : so the line under should not be indented
broadcast "r"
so uh what do i need to change
line 2 and 3
like this?
on toggle sneak:
player is sneaking
name of player's offhand tool is "&cVulture":
push player upwards with speed 0.5
push player forwards with speed 1.5
if difference between now and {cd.%uuid of player%} is less than or equal to 1 second:
stop
else:
push player upwards with speed 0.5
push player forwards with speed 1.5
line 3 still has : at the end
so i put an if before it?
if you try to understand this i explain you dont need an if
but the only reason to have a if is if you are going to check something else
on toggle sneak:
player is sneaking
name of player's offhand tool is "&cVulture"
push player upwards with speed 0.5
push player forwards with speed 1.5
if difference between now and {cd.%uuid of player%} is less than or equal to 1 second:
stop
else:
push player upwards with speed 0.5
push player forwards with speed 1.5
like this?
the indention looks about right
but now you just need to fix your code
why push player before the if statements?
so remove that?
if thats how you want your code to work sure
now like this
on toggle sneak:
player is sneaking
name of player's offhand tool is "&cVulture"
if difference between now and {cd.%uuid of player%} is less than or equal to 1 second:
stop
else:
push player upwards with speed 0.5
push player forwards with speed 1.5
give it a try
no
on toggle sneak:
player is sneaking
name of player's offhand tool is "&cVulture"
if difference between now and {cd.%uuid of player%} is greater than or equal to 2 second:
stop
else:
push player upwards with speed 0.5
push player forwards with speed 1.5
i also made it greater than or equal to 2
seconds
no?
nah
bro wdym, you wont give it a try?
ok, what didnt work?
debug
debug?
debugging means you need to figure out why and what makes it not stop
maybe because its specifically greater than 2 seconds
or maybe because you never set the variable to something after use
for example yes
do i put that in or would it be different
give it a try
dont be scared to try out different things its a great way to learn skript
ik ik
still wont work
on toggle sneak:
player is sneaking
name of player's offhand tool is "&cVulture"
if difference between now and {cd.%uuid of player%} is greater than or equal to 2 second:
stop
else:
push player upwards with speed 0.5
push player forwards with speed 1.5
set {cd.%uuid of player%} to now
this is the new sk
do what i said, instead of trying once and coming back here saying it didnt work
ok
its starting to work as it doesnt let me use it and it sends a message but it doesnt let me use it at all
on toggle sneak:
player is sneaking
name of player's offhand tool is "&cVulture"
{vulture::%uuid of player%::last usage} was less than 2 seconds ago:
message "&cWait a bit before again using this"
stop
else:
push player upwards with speed 0.5
push player forwards with speed 1.5
set {vulture::%uuid of player%::last usage} to now
@lucid haven
removing the if statement makes the else statement not work
ohh
the else section was not erroring but as i add this back it has 2 errors
on toggle sneak:
player is sneaking
name of player's offhand tool is "&cVulture"
if difference between now and {vulture::%uuid of player%::last usage} was less than 2 seconds ago:
message "&cWait a bit before again using this"
stop
else:
push player upwards with speed 0.5
push player forwards with speed 1.5
set {vulture::%uuid of player%::last usage} to now
was less and the error says "{the variable} does not have a past state" which means you cant check past state of a variable
now it says this when i changed the was to is
on toggle sneak:
player is sneaking
name of player's offhand tool is "&cVulture"
if difference between now and {vulture::%uuid of player%::last usage} is less than 2 seconds ago:
message "&cWait a bit before again using this"
stop
else:
push player upwards with speed 0.5
push player forwards with speed 1.5
set {vulture::%uuid of player%::last usage} to now
im not understanding what to do for that
remove ago
I love how one of the first things mentioned was code blocks and he never used it lol
!format