# Calculate coordinates at a target block

Status
Not open for further replies.

#### AkroDogy2005

##### Member
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
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.

nop, same thing it doesn t display any message like "test"

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.