Calculate coordinates at a target block

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

AkroDogy2005

Member
Apr 20, 2018
18
1
3
24
Hi, I'm trying to make a calculation so that when the arrow reaches the center point of the block it receives 3 points, farther from the center 2 points and farthest from the center of the block 1 point.
This is my actual code:
Code:
on projectile hit:
    if {shape::*} is true:
        if {game::*} is true:
            projectile is arrow:
                shooter is player:
                    if event.getHitBlock() is target:
                        set {_x::*} to x-location of projectile
                        set {_y::*} to y-location of projectile
                        set {_z::*} to z-location of projectile
                        set {_xar1} to "%event-block's x-location%"
                        set {_yar1} to "%event-block's y-location%"
                        set {_zar1} to "%event-block's z-location%"
                        message "Hit coords %{_x::*}% %{_xar1}%  %{_y::*}% %{_yar1}%  %{_z::*}% %{_zar1}%" to shooter
                        message "&e+1 point" to shooter
                        if {_x::*} > {_xar1}+0.5:
                            message "test"
    else:
        cancel event

When test it i don t get any "test" message:
Can someone help me with?
 

Attachments

  • Screenshot_17.png
    Screenshot_17.png
    115.8 KB · Views: 94
Try this:
Code:
on projectile hit:
    if {shape::*} is true:
        if {game::*} is true:
            projectile is arrow:
                shooter is player:
                    if event.getHitBlock() is target:
                        set {_x} to x-location of projectile
                        set {_y} to y-location of projectile
                        set {_z} to z-location of projectile
                        set {_xar1} to "%event-block's x-location%"
                        set {_yar1} to "%event-block's y-location%"
                        set {_zar1} to "%event-block's z-location%"
                        message "Hit coords %{_x}% %{_xar1}%  %{_y}% %{_yar1}%  %{_z}% %{_zar1}%" to shooter
                        message "&e+1 point" to shooter
                        if {_x} > {_xar1}+0.5:
                            message "test"
    else:
        cancel event
 
Try this:
Code:
on projectile hit:
    if {shape::*} is true:
        if {game::*} is true:
            projectile is arrow:
                shooter is player:
                    if event.getHitBlock() is target:
                        set {_x} to x-location of projectile
                        set {_y} to y-location of projectile
                        set {_z} to z-location of projectile
                        set {_xar1} to "%event-block's x-location%"
                        set {_yar1} to "%event-block's y-location%"
                        set {_zar1} to "%event-block's z-location%"
                        message "Hit coords %{_x}% %{_xar1}%  %{_y}% %{_yar1}%  %{_z}% %{_zar1}%" to shooter
                        message "&e+1 point" to shooter
                        if {_x} > {_xar1}+0.5:
                            message "test"
    else:
        cancel event
Tried it but the variable is not working, if i put {_x} instead of {_x::*} i ll not get the test message and on the first message with all coords i ll get a <none> instead of a coord
 
oh i know why now. you are comparing a number with a string, since you set {_xar1} as a string while {_x::*} as a number. If you make {_xar1} to a number as well it should work.
 
Hi, thanks for responding but I don't think the code is for me, im using skript and i saw that code written by you is for web browsers.
 
Status
Not open for further replies.