depending on dir
example if the direction is 15 and current x and y is 10
then
four_dir[1] = {x=10,y=9}
four_dir[2] = {x=11,y=10}
four_dir[3] = {x=9,y=10}
four_dir[4] = {x=10,y=11}
its hard to explain, but i hope you understand understand...
function sort_pos(x,y) 	local t = {} 	for k,v in pairs(player(0,"tableliving")) do 		table.insert(t,{player(v,"x"), player(v,"y")}) 	end 	table.sort(t, 		function(a,b) 		return math.sqrt(((a[1]-x)^2+(a[2]-y)^2) < ((b[1]-x)^2+(b[2]-y)^2)) 	) 	return t end
function four_dir (dir) dir_fixed = round(dir/90)*90 x_add = {} y_add = {} x_add[1] = round(math.cos(math.rad((dir_fixed) - 90))) y_add[1] = round(math.sin(math.rad((dir_fixed) - 90))) if dir < dir_fixed then dir_fixed = math.floor(dir/90)*90 else dir_fixed = math.ceil(dir/90)*90 end x_add[2] = round(math.cos(math.rad((dir_fixed) - 90))) y_add[2] = round(math.sin(math.rad((dir_fixed) - 90))) x_add[3] = -x_add[2] y_add[3] = -y_add[2] x_add[4] = -x_add[1] y_add[4] = -y_add[1] end