This might work for you:
Code:
$sServerIP="10.10.0.1"
$iMaxHops=5
$iWait=1000
 
If IPIsClose($sServerIP,$iMaxHops)
	"Server "+$sServerIP+" is within "+$iMaxHops+" hops."+@CRLF
Else
	"Server "+$sServerIP+" is down or too far away"+@CRLF
EndIf
 
Function IPIsClose($sIP,Optional $iHops, Optional $iWait)
	If VAL($iHops)<1 $iHops=30 EndIf
	If VAL($iWait)<1 $iWait=1000 EndIf
	SHELL %COMSPEC%+" /C tracert -d -h "+$iHops+" -w "+$iWait+" "+$sIP+' | FIND "ms  '+$sIP+'" >NUL:'
	$IPIsClose=Not @ERROR
	Exit @ERROR
EndFunction


Basically you use tracert to determine if the IP address is within a number of hops.

An alternative is to do a tracert, capture the output, then check the three RTTs on the last line if it matches the server IP address. Look up the PIPE udfs if you want to use this method.