I got that code from here -
https://forums.alliedmods.net/showthread.php?t=91122
Take a look at #5 reply by Arkshine.
Besides it being more accurate (not that big difference, but still better), I can easily use the max distance and still spawning the entity correctly (even if the end position is too far away), thing that get_user_origin with 2/3 value being the third parameter will not be able to do.
__________________