Help with the execute command

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Aberforth

Member
Jun 14, 2019
40
2
8
Canada
Hello, I have the following code:

Code:
on projectile hit:
    if projectile is an arrow:
        execute console command "/execute as %event-projectile% run time set night"

Doesn't work, doesn't print any errors.
Using 2.5-alpha5 with Spigot 1.16.1

Is it because of the alpha release?
[doublepost=1595391599,1595253459][/doublepost]Any ideas?
 
But what if it's gonna be a different command? The problem is that the console doesn't execute any commands as the event-projectile. I don't want a workaround that's gonna work only in this particular example. This is a crucial feature and it needs a real solution.
 
What your code is executing is
Code:
/execute as arrow run time set night
and since no player online has that name, your code does not work.
 
So is there any way to make the command target the actual arrow instead of a player named 'arrow'?
[doublepost=1596098661,1595621451][/doublepost]Still looking for a solution to this problem
 
I don't think there is a way to do it, since /execute as only affects players. I don't understand why you want to do this. Just use:
Code:
on projectile hit:
    if projectile is an arrow:
        execute console command "/time set night"
Like, why do you want the PROJECTILE to execute a command? I don't even think they can...
 
Thanks for the answer. I'm new to the new command syntax (after 1.13) so maybe I'm missing something. Before 1.13 any entity could execute a command. For example "/execute @e[type=arrow,name=some_name] ~ ~ ~ time set night"

So I hope there is a command that can execute a command as an arrow. I know I could do this thing the way you posted, but some other commands use positions of the executing entity, for example /summon, /setblock or /playlist

Running these commands would offer many possibilities. What if I wanted to run "/playsound custom.example_sound neutral @a ~ ~ ~ 1 1 0"? This command would need the coordinates.
[doublepost=1596556357,1596202136][/doublepost]Still haven't found a solution
[doublepost=1598031218][/doublepost]Still looking, has no one run into this problem yet?
 
on damage:
if victim is a player:
if cause of damage is projectile: i have no clue if its projectile or arrow
execute console command "do something"​

i have no clue as to what you are tring to do with this but the alpha realeses are unstable also i havent tested it​
 
@Piggydoe

"on projectile hit" is called when a projectile hits a block, so we can't substitute it with "on damage"

Edit: And what I'm trying to do, in short, is execute a command as the projectile, when it hits.
 
@Piggydoe

"on projectile hit" is called when a projectile hits a block, so we can't substitute it with "on damage"

Edit: And what I'm trying to do, in short, is execute a command as the projectile, when it hits.

makes sense I'm playing around with it right now, although it might just be an unstable version of skript try this version just like shadowlifemc said it would be easier to run a console command that sets time to night
 
@Piggydoe

I know the console could run it, but that's a specific case. If we could run a command as the projectile, we could use commands with relative coordinates, such as: playing a sound at the projectile, spawning an entity at the projectile, setting a block, playing any particle effect at that position etc. I'm gonna try that Skript version soon.
 
@Piggydoe

I know the console could run it, but that's a specific case. If we could run a command as the projectile, we could use commands with relative coordinates, such as: playing a sound at the projectile, spawning an entity at the projectile, setting a block, playing any particle effect at that position etc. I'm gonna try that Skript version soon.
ok i see what your saying, i would say stick to skripts syntax things like

on place of TNT:
if name of tool of player is "&6Explosive TNT":
cancel the event
remove 1 TNT named "&6Explosive TNT" from player's inventory
loop 6 times:
create a fake explosion at the player ←←←←← here instead of using /particle blah blah blah you can use at the player or at player, in some cases, yes using specific coords is better but generally stick to the built-in skript syntax. i don't know if this is helpful I'm still fairly new to skript I've been skripting since mid-july so I'm not that advanced
 
I tried your suggestions. The reason I want the projectile to execute a command is because the skript syntax lacks some features that are present in the commands. Example:

If I want to play a sound at the projectile:

Code:
on projectile hit:
    play sound "block.anvil.land" with volume 1 and pitch 1 at projectile

But then I can't specify a parameter for minVolume which is present in the command:

Code:
playsound <sound> <category> <player> <x> <y> <z> <volume> <pitch> <minVolume>

This results with skript sounds being cutoff if you walk too far, instead of slowly fading away like the command sounds do if you provide 0 as minVolume.

If you know the commands it would be SO easy to have the ability to run commands as projectiles and entities in general without replacing them with skript syntax which often doesn't work because no-idea-why, plus it's easier to have "1 1" instead of "with volume 1 and pitch 1" or "@a" instead of "for all players". What's frustrating is that it worked on 1.12, so why wouldn't it work on 1.16?

I even set up a small test:
Code:
on projectile hit:
    execute shooter command "/summon zombie"
And even this simple thing doesn't work, sending no errors.

I think this alpha version's default commands handling is very broken. Even though,
Code:
on step on stone:
    execute player command "/summon zombie"
works well.


p l e a s e s e n d h e l p
 
Status
Not open for further replies.