#Get Nearest Player

31 messages · Page 1 of 1 (latest)

opaque dome
#

Gets the nearest player to an object.

LABEL Get Nearest - EB
SET R6 1e+20
SET R4 255
SET R7 0
LABEL Loop
LESS R5 R7 Player.Count
NOT R5 R5
IF R5 Done
SET Player.SelIndex R7
EQUAL R5 Player.Valid 1
NOT R5 R5
IF R5 Next
SUB R0 Player.Pos.X Obj.Pos.X
SUB R1 Player.Pos.Y Obj.Pos.Y
SUB R2 Player.Pos.Z Obj.Pos.Z
MUL R0 R0 R0
MUL R1 R1 R1
MUL R2 R2 R2
ADD R3 R0 R1
ADD R3 R3 R2
LESS R5 R3 R6
IF R5 Update
LABEL Next
ADD R7 R7 1
GOTO Loop
LABEL Update
SET R6 R3
SET R4 Player.Id
GOTO Next
LABEL Done
SET sgn1.Sign.Number R4
SLEEP 0
GOTO Get Nearest - EB
#

You dont need a sign but its helpful to know who's closest

faint ivy
#

Could this technically be used to make monsters?

#

Just wondering

opaque dome
#

Like chase the nearest player?

#

Yes thats why I made it
R4 is the nearest player but I have no chase code with this right now.

wicked coral
#

W

opaque dome
#

I can add a video and guidance for what values do what if needed

wicked coral
#

actually yeah

#

imma be honest

#

the only code i use is useful snippets

#

i haven't coded anything

mossy dew
simple charm
#

adding this here.

#

it should look at the player with this codeeee

#

LABEL Done
SET sgn1.Sign.Number R4

SET Player.SelId R4
EQUAL R5 Player.Valid 1
NOT R5 R5
IF R5 SkipLook

SUB R0 Player.Pos.X Obj.Pos.X
SUB R1 Player.Pos.Y Obj.Pos.Y
SUB R2 Player.Pos.Z Obj.Pos.Z

ATAN2 R3 R0 R2
SET Obj.Rot.Y R3

LABEL SkipLook
SLEEP 0
GOTO Get Nearest - EB

worn turret
void stone
#

um so its not working right its following the person with the higest id

#

unless that how its supposed to work

worn turret
#

cause its working fine for me

void stone
#

and yeah i had multiple

#

ppl

void stone
sturdy tinsel
#

it chases me when im out the range

pulsar knot
#

canmod Make me a Code Block that a block will go into the players hand and if it hits a block it goes off their hand

rotund harnessBOT