Targeted player's location

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

005emre005

Member
Jun 9, 2024
1
0
1
19
Hello,
How can ı get targeted player's location

I wrote this but it's not working


Code:
on load:

command /konum [<player>]:
    trigger:
        if arg 1 is set:
            set {_targetPlayer} to arg 1 parsed as player
            if {_targetPlayer} is online:
                set {_loc} to location of {_targetPlayer}
                set {_x} to x-coordinate of {_loc}
                set {_y} to y-coordinate of {_loc}
                set {_z} to z-coordinate of {_loc}
                send "&a%{_targetPlayer}%'s coords: X: %{_x}%, Y: %{_y}%, Z: %{_z}%" to player
            else:
                send "&cPlayer is not Online!" to player
        else:
            set {_loc} to location of player
            set {_x} to x-coordinate of {_loc}
            set {_y} to y-coordinate of {_loc}
            set {_z} to z-coordinate of {_loc}
            send "&aYour coords: X: %{_x}%, Y: %{_y}%, Z: %{_z}%" to player
 
Error: "the 1st argument is not a text"
arg-1 is already a player
Why you do not use just the arg-1 or the player?
Code:
command /konum [<player>]:
    trigger:
        if arg 1 is set:
            if arg-1 is online:
                set {_x} to x-coordinate of arg-1
                set {_y} to y-coordinate of arg-1
                set {_z} to z-coordinate of arg-1
                send "&a%arg-1%'s coords: X: %{_x}%, Y: %{_y}%, Z: %{_z}%" to player
            else:
                send "&cPlayer is not Online!" to player
        else:
            set {_x} to x-coordinate of player
            set {_y} to y-coordinate of player
            set {_z} to z-coordinate of player
            send "&aYour coords: X: %{_x}%, Y: %{_y}%, Z: %{_z}%" to player

Or if you like more your example:
Code:
command /konum [<player>]:
    trigger:
        if arg 1 is set:
            set {_targetPlayer} to arg 1
            if {_targetPlayer} is online:
                set {_loc} to location of {_targetPlayer}
                set {_x} to x-coordinate of {_loc}
                set {_y} to y-coordinate of {_loc}
                set {_z} to z-coordinate of {_loc}
                send "&a%{_targetPlayer}%'s coords: X: %{_x}%, Y: %{_y}%, Z: %{_z}%" to player
            else:
                send "&cPlayer is not Online!" to player
        else:
            set {_loc} to location of player
            set {_x} to x-coordinate of {_loc}
            set {_y} to y-coordinate of {_loc}
            set {_z} to z-coordinate of {_loc}
            send "&aYour coords: X: %{_x}%, Y: %{_y}%, Z: %{_z}%" to player