Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (84,693 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

OfficerJohnson

[.NET] Let's Discuss Range/Distance

Recommended Posts

OfficerJohnson

Hello everyone. In order to make the scripts I desire, I need to understand how I can effectively use range to my advantage. I'll get right to the point.

 

What I Want To Accomplish:

-creating random spawn points for call outs to occur (preferably randomized based on location or distance)

-spawning a vehicle with Peds in it and having them drive to my location like a normal, dispatched vehicle (not spawning in front of me)

-same thing but for ambient PEDS or spawned in PEDS

-creating that police search circle around a certain area

 

My Logic:

-using Vectors

-some way to check whether the area is not obstructed

-check for spawning on street

-natives to determine range or something

 

Goals of This Thread/Topic:

-learning how to determine range using natives or .NET API

-learning how to spawn a vehicle far enough away and task it to drive to your location

-learning to gather ambient peds within range and have them do something (come to player)

-learning how to create a search circle with a certain range

-learning how to randomize the fallouts created based on different range or location

 

This is HUGE for my script development, so I'll be coming back and adding to this topic as discussion goes.

Share this post


Link to post
Share on other sites
Bob_74

-some way to check whether the area is not obstructed

-check for spawning on street

There is a function that does just that:

Vector3 World.GetNextPositionOnStreet(Vector3 position, bool unoccupied)

The only issue, is that it doesn't return the heading for the position. So your vehicle may be facing the wrong way when spawning and the driver will have to turn around on the road, etc.

 

Btw, there is a native that returns the heading with the position: GET_NTH_CLOSEST_VEHICLE_NODE_WITH_HEADING (http://gtaforums.com/topic/820121-spawn-vehicle-cleanly-at-nearest-road/?p=1067986145)

You will need to check manually if the area is obstructed: IS_POINT_OBSCURED_BY_A_MISSION_ENTITY

 

 

-learning how to determine range using natives or .NET API

Do you mean distance between two coordinates?

if so:

 

// Calculate the distance between two coordinates using GPS pathfloat World.CalculateTravelDistance(Vector3 origin, Vector3 destination)// Calculate the distance between two coordinatesfloat World.GetDistance(Vector3 origin, Vector3 destination)

-learning how to spawn a vehicle far enough away and task it to drive to your location

Maybe not the best method, but you can use Vector3's function Vector3 Around(float distance) which return a random location in a radius of distance.

Then, if you want to be sure it is far enough, you can run this function until the distance between your character and the returned value is adequate (Vector3 also has a float DistanceTo(Vector3 position) which you can use to tell if it is far enough).

 

Driving a vehicle to the player is quite easy, you can use Ped's function Task.DriveTo(Vehicle vehicle, Vector3 target, float radius, float speed, DrivingStyle)

 

 

-learning to gather ambient peds within range and have them do something (come to player)

World.GetNearbyPeds(Vector3 position, float radius) is certainly what you want. You use this function with the player's coordinates and a radius, and it will return an array with the peds around the player.

Then for each Ped in the array, you call ped's Task.GoTo(Entity target)

 

 

-learning how to create a search circle with a certain range

I think it is a minimap scaleform since this seems to fit your needs (not tested) https://scaleform.devtesting.pizza/minimap.html#minimap - function SET_WANTED_LEVEL(circle, wantedLevel, radius) Edited by Bob_74

Share this post


Link to post
Share on other sites
OfficerJohnson

Once again, Bob. Always quick to answer.

 

"Do you mean distance between two coordinates?"

 

The script I have in mind is a mini callout script. In order to make it work the way I want, I need to be able to randomize the distance it takes to drive to where the callout occurs and also will need to randomize the locations where each callout spawns. Aka, I don't want to hard code callout areas unless I have to. Would rather have them randomized based on both distance and location.

 

Vector3 Position. This could also take the players' position as an argument, right?

 

So you're saying the wanted level search circle may be a scaleform? Okay. I'll look into it.

Share this post


Link to post
Share on other sites
Bob_74

The script I have in mind is a mini callout script. In order to make it work the way I want, I need to be able to randomize the distance it takes to drive to where the callout occurs and also will need to randomize the locations where each callout spawns. Aka, I don't want to hard code callout areas unless I have to. Would rather have them randomized based on both distance and location.

For the callout itself, I would hardcode some locations because an entirely random location could lead at the top of a mountain or in the middle of the sea.

You can set a large radius when calling Around() function to better randomize the position.

 

Then you can call World.GetNextPositionOnSidewalk or World.GetNextPositionOnStreet depending where you want it to occur.

 

UNLESS, you want it to happen only around the player. Then you can use Around() with the player's position without having to hardcode any coordinates.

 

 

Vector3 Position. This could also take the players' position as an argument, right?

Yes, the player's position is a Vector3.

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

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.