Executing a command on another player

Started by Tom45 on

Topic category: Help with modding (Java Edition)

Last seen on 16:58, 2. Nov 2019
Joined Jun 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Executing a command on another player

Hello I’ve been making some commands however I haven’t been able to work out how to target other players. For example, if I use /speed it will give speed to the player that executes the command. I would like to be able to target a different player for example /speed <player>, but I do not know how to do this. Any help is appreciated.

Thanks

Last seen on 09:08, 28. Mar 2021
Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm sure the target selector…
Thu, 07/04/2019 - 07:48

I'm sure the target selector isn't added to MCreator.

Last seen on 09:08, 28. Mar 2021
Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I want that function because…
Thu, 07/04/2019 - 07:51

I want that function because I'm making a short version of /gamemode, and in Minecraft I can use the target selector to change game mode of a player.

Last seen on 04:00, 16. Sep 2020
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hello Tom. I would be happy…
Tue, 08/11/2020 - 20:03

Hello Tom. I would be happy if this feature would be added, but not it's does not exist. Instead, I found a way how to make a selector parameter that allows you to choose a player or an entity. let's make a /speed command!

so we are going to create two commands. one of them will be without an entity parameter, It will give speed to the entity that executed it. we will call it givespeed. the second one is going to execute givespeed on an entity. it's going to run the /execute command on the target entity. we will call this command speed.

our execute command looks like this: execute at (our entity) as @s run givespeed

when we will run speed i'ts going to generate our execute command. it's going to put the target entity command parameter instead of "(our entity)"

let's do this!

step 1

create 2 new commands:

step 2

add the "When command executed" trigger procedure in givespeed:

It will add a speed potion to the entity that executed this command.

step 3

add the "When command executed" trigger procedure in speed:

we are generating an execute command by joining the command parts with command parameter index 0. pay attention! command parameters must have a space between them so write "execute as " and " at @s run givespeed"

this procedure will simulate running givespeed on entities.

step 4

now test it! summon some pigs and some sheeps.

write /speed @e[type=sheep]. watch the particles! only sheep now will have speed effect.

I hope it helped you!

Last seen on 09:43, 1. Jun 2022
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
/execute at @e[type=player…
Mon, 06/07/2021 - 10:20

/execute at @e[type=player,sort=nearest] run effect give @s speed 999 255 true

Last seen on 13:32, 11. Apr 2022
Joined Dec 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It worked well for me. I…
Sat, 07/03/2021 - 11:02

It worked well for me.

I think it should work for 1.12 and before like this

At <input> its command parameter for selector (player)

/execute <input> ~~~ speed

to the player.