Jump to content
DMes71

Looking for a way to find a random safe place for a ped to spawn

Recommended Posts

I'm trying to find a way to make ped spawn at a random position within a certain radius from a given point. 

I've tried using the native GET_SAFE_COORDS_FOR_PED but i have not been able to successfully implement it.

is there a simpler function in rage to do this or am I stuck using this native or a similar one?

Share this post


Link to post
Share on other sites

Hi DMes71,

I have previously created myself a common function to call for this reason - spawning peds.  I use the below:

public static unsafe Vector3 GetSafeCoordsForPed(Vector3 CheckPoition)
        {
            Vector3 ReturnPosition;
            NativeFunction.CallByName<bool>("GET_SAFE_COORD_FOR_PED", CheckPoition.X, CheckPoition.Y, CheckPoition.Z, true, &ReturnPosition.X, &ReturnPosition.Y, &ReturnPosition.Z, 0);

            if (ReturnPosition == Vector3.Zero)
            {
                return CheckPoition;
            }
            else
            {
                return ReturnPosition;
            }
        }

If this function returns a Vector3.Zero value then the function was unable to find a safe location to spawn a ped.

Please also be aware that a 'Safe Position' only seems to be not on a road.

I am new at RPH and LSPDR plugins so there maybe a better way but this is how I have implemented this.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×