Here, a simple script that prints "Yes" if player Id 1 (mousemapX) and (mousemapY) are within player Id 2 (target) (X,Y) in 16 pixels each side for both coordinates, elsewise it prints a "No". It doesn't work the best though.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("ms100", "ms100_hook")
function ms100_hook()
	local You = 1
	local Target = 2
	
	local radius = 16
	local mouseMapX = player(You, "x") - player(You, "screenw")/2 + player(You, "mousex")
	local mouseMapY = player(You, "y") - player(You, "screenh")/2 + player(You, "mousey")
	local inRange_X = mouseMapX >= player(Target, "x") - radius and mouseMapX <= player(Target, "x") + radius
	local inRange_Y = mouseMapY >= player(Target, "y") - radius and mouseMapY <= player(Target, "y") + radius
	
	if inRange_X and inRange_Y then
		parse("hudtxt 0 Yes")
	else
		parse("hudtxt 0 No")
	end
end
If my explanation above was poor here an explanation in images:

So using the code above in the first image it prints "Yes" at this point as If I shoot It will hit the target.

But in the second image if the code above is being used it prints "No" even though still if I shoot it will hit the target.
It should print "Yes".
Note: Only If the target is being seen within the screen.
Does anyone know the "maths" behind this thing? Thanks, Would be appreciated!
edited 6×, last 14.04.21 09:25:16 am
Anticipate if you shoot it hits a target or not
1 
Offline
ohaz