Solved Command Variables

  • 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.

Purple Pixel

Member
Sep 23, 2020
40
4
8
26
Hello skript community,

I have been trying to develop a anti cheat. But thats isn't the point. I am trying to make the code teleport the npc to wherever the variables say. Here is the code. I know it isn't in the help format cause I am new to this. But this is the latest version minehut has released so here is. Please help XD

Code:

command /actest:
permission: op
trigger:
set {y} to player's location
set {x} to player's location
set {z} to player's location
add 4 to {x}
add 4 to {z}
execute console command "/minecraft:tp [name=Bob] {x} {y} {z}"
 
command actest:
permission: op
trigger:
set {_loc} to player's location
add 4 to x of {_loc}
add 4 to z of {_loc}
execute console command "/minecraft:tp [name=Bob] {_loc}"
 
command actest:
permission: op
trigger:
set {_loc} to player's location
add 4 to x of {_loc}
add 4 to z of {_loc}
execute console command "/minecraft:tp [name=Bob] {_loc}"
Thank you but it says there is a an error:
"Invalid argument for command"
 
You have identate it ?
Code:
command actest:
permission: op
trigger:
  set {_loc} to player's location
  add 4 to x of {_loc}
  add 4 to z of {_loc}
  execute console command "/minecraft:tp [name=Bob] {_loc}"
[doublepost=1601928051,1601927997][/doublepost]
Thank you but it says there is a an error:
"Invalid argument for command"
What line ?
 
You have identate it ?
Code:
command actest:
permission: op
trigger:
  set {_loc} to player's location
  add 4 to x of {_loc}
  add 4 to z of {_loc}
  execute console command "/minecraft:tp [name=Bob] {_loc}"
[doublepost=1601928051,1601927997][/doublepost]
What line ?
Still no :|
[doublepost=1601928208][/doublepost]
You have identate it ?
Code:
command actest:
permission: op
trigger:
  set {_loc} to player's location
  add 4 to x of {_loc}
  add 4 to z of {_loc}
  execute console command "/minecraft:tp [name=Bob] {_loc}"
[doublepost=1601928051,1601927997][/doublepost]
What line ?
Line 8
 
Code:
command actest:
    permission: op
    trigger:
        set {_y} to y-coordinate of player
        set {_x} to x-coordinate of player
        set {_z} to z-coordinate of player
        add 4 to {_x}
        add 4 to {_z}
        execute console command "/minecraft:tp @e[name=Bob] %{_x}% %{_y}% %{_z}%"
Tested and working. But it can stuck the entity
 
Code:
command actest:
    permission: op
    trigger:
        set {_y} to y-coordinate of player
        set {_x} to x-coordinate of player
        set {_z} to z-coordinate of player
        add 4 to {_x}
        add 4 to {_z}
        execute console command "/minecraft:tp @e[name=Bob] %{_x}% %{_y}% %{_z}%"
Tested and working. But it can stuck the entity
Omg Bro Thanks Soo Much :emoji_grinning:
 
Omg Bro Thanks Soo Much :emoji_grinning:
You're welcome :emoji_relieved:.
I'm working in this command yet, to better a bit. But, it's not guaranteed that I will post here again.
[doublepost=1601935335,1601931440][/doublepost]
You're welcome :emoji_relieved:.
I'm working in this command yet, to better a bit. But, it's not guaranteed that I will post here again.
Code:
command actest <string> <string> <string> <string>:
    permission: op
    trigger:
        set {_x} to x-coordinate of player
        set {_y} to y-coordinate of player
        set {_z} to z-coordinate of player
        if length of arg-1 and length of arg-2 and length of arg-3 is 1:
            if arg-1 and arg-2 and arg-3 are "~":
                execute console command "/minecraft:tp @e[name=%arg-4%] %{_x}% %{_y}% %{_z}%"
                broadcast "..."
        else:
            if first character of arg-1 is "~":
                if length of arg-1 is more than 1:
                    set {_arg1} to subtext of arg-1 from character 2 to (the length of arg-1)
                    set {_arg1} to {_arg1} parsed as number
                    add {_arg1} to {_x}

            if first character of arg-2 is "~":      
                if length of arg-2 is more than 1:
                    set {_arg2} to subtext of arg-2 from character 2 to (the length of arg-2)
                    broadcast {_arg2}
                    set {_arg2} to {_arg2} parsed as number
                    add {_arg2} to {_y}

            if first character of arg-3 is "~":
                if length of arg-3 is more than 1:
                    set {_arg3} to subtext of arg-3 from character 2 to (the length of arg-3)
                    set {_arg3} to {_arg3} parsed as number
                    add {_arg3} to {_z}  
            execute console command "/minecraft:tp @e[name=%arg-4%] %{_x}% %{_y}% %{_z}%"

Now you can use this command to teleport the entity to your location:
Code:
/actest ~ ~ ~ entityname
or this command to teleport the entity to your location but with your y coordinate + 2 block up
Code:
/actest ~ ~2 ~ entityname
There are certainty some bugs, for example: solo numbers will not work, because I'm not the best developer, but, I believe that this simple change can help you
 
Status
Not open for further replies.