@name MP finder

runOnTick(1) # Makes the program update on server tick rate

if (first()) 
{
    holoCreate(0, entity():pos() + vec(0, 0, 10), vec(5,5,1), ang(0, 0, 0), vec(255, 255, 255))
    holoShadow(0, 0)
    holoModel(0,"torus")
    
    holoCreate(1, entity():pos() + vec(0, 0, 20), vec(1,1,1), ang(0, 0, 0), vec(255, 0, 0))
    holoShadow(1, 0)
    holoModel(1,"sphere") 
    
    # These spawn the nessecary holograms to display direction, look in the E2 documentation to understand how they work.
    
    Owner = owner()
}

findByClass("money_printer") # Finds all the money printers around

Target = findClosest(Owner:pos()) # selects the closest one and inputs it to Target variable
V1 = vec2(Owner:pos():x(),Owner:pos():y())   #
V2 = vec2(Target:pos():x(),Target:pos():y()) #Creates a 2D Vector
#Ang = Owner:eyeAngles():yaw() - (V2 - V1):toAngle() # Here you can get the bearing to the Entity, but its not needed right now. 

holoPos(0,Owner:pos() + vec(0,0,30)) # Moves the ring to owner position + 30 units in Z axis to lift the ring off the ground
holoColor(0,vec(255,255,255)) # Turns ring white, this is so when the if under was true, but becomes false: returns the ring to correct color

SX = Owner:pos():x() + cos((V2-V1):toAngle())*30 # Using Sin And Cosin, one can extrapolate
SY = Owner:pos():y() + sin((V2-V1):toAngle())*30 # the coordinates to where the ball must be

holoPos(1,vec(SX,SY,Owner:pos():z()+35)) #Moves the ball to the correct possition around the owner
if (Target == noentity()) {holoPos(1,vec(0,0,-1000)), holoColor(0,vec(255,0,0))} #Turns the ring Red and hides the ball underground
