Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

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

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

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

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

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

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

    2. Support

    3. Suggestions

Car spawning and despawning question


icecube3456
 Share

Recommended Posts

icecube3456

I'm using C# with scripthook .net, is there a way to remove cars if too many are spawned?

Link to comment
Share on other sites

blowjobcumpussy

 

using System;using System.Windows.Forms;using GTA;public class CarDensity : Script{   //edit numbers to right of equal sign only   const Keys DELETE_CARS_MANUALLY_KEY = Keys.Delete;   const float DELETE_RANGE = 25f;   const float CAR_DENSITY = 0.75f;//1.0 is default   //do not edit below unless u know what ur doing   public CarDensity()   {       BindKey(DELETE_CARS_MANUALLY_KEY, DeleteAroundPlayer);       World.CarDensity = CAR_DENSITY;   }   private void DeleteAroundPlayer()   {       foreach (Vehicle veh in World.GetVehicles(Game.LocalPlayer.Character.Position, DELETE_RANGE))           if (Game.Exists(veh) && veh != Game.LocalPlayer.Character.CurrentVehicle)               veh.Delete();   }}

 

 

Requires:

-scripthookdotnet 1.7.1.7 beta by hazardx

-scripthook c++ 0.4.0 (gta 1.0.4) or 0.5.1 (gta 1.0.7 or eflc) by aru

-one of the asi loaders (listener, alexander blade, etc)

 

Intsall:

-copy to notepad, save as ILoveBlowJobs.cs and put in scripts folder u made when u installed scripthookdotnet

 

Editing Values:

-to change values, tab out of game, open script in notepad, change values at top of script only, save and then go back to game and do the reloadscripts command in console

 

Extra Function:

-added command to manually delete cars in an area around player, u can change delete range at top of script, use delete key or edit key at top of script, google "system.windows.forms.keys enumeration" to see a list of valid Keys values

Edited by blowjobcumpussy
Link to comment
Share on other sites

motorsport71

@icecube3456 When you say "is there a way to remove cars if too many are spawned?", do you mean vehicles that you've spawned yourself and/or other scripts that won't go away even if you drive off and come back? If so they may be considered "mission vehicles" which won't despawn on their own. Off the top of my head try something like this:

 

Imports SystemImports System.CollectionsImports System.Windows.FormsImports GTAPublic Class ControlTraffic   Inherits Script   Private Scripton As Boolean = False   Public Sub New()       Me.interval = 1000   End Sub   Private Sub Traffic_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Tick       If Scripton = True Then           If (isKeyPressed(Settings.GetValueKey("Key", Keys.F9))) Then               Native.Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", "Vehicle Controls Deactivated", 5000, 1)               world.cardensity = 1.0               Scripton = False           Else               Dim vehicles As vehicle() = world.getallvehicles()               For Each vehicle As Vehicle In vehicles                   If Not exists(vehicle) OrElse vehicle Is Nothing Then                       Continue For                   End If                   If exists(vehicle) AndAlso vehicle IsNot Nothing AndAlso vehicle.isrequiredformission = True AndAlso player.character.Position.DistanceTo(vehicle.Position) >= 30.0F Then                       vehicle.nolongerneeded()                   End If               Next           End If       Else           If (isKeyPressed(Settings.GetValueKey("Key", Keys.F9))) Then               Scripton = True               Native.Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", "Vehicle Controls Activated", 5000, 1)               world.cardensity = 1.0  'change this value to increace/decrease overall traffic. 1.0 is default, 0.5 is half, 2.0 is double, etc.           End If       End If   End SubEnd Class

 

 

This should activate with F9, cycle through every second, and keep a constant default ingame value of 1.0 vehicle density. It will also allow the game to remove any spawned vehicles left lying around that are 30 meters or greater away from you. If you want to change the vehicles density change the second "world.cardensity = " whatever value you like, i marked it with a side annotation. When you turn off the script, it will automatically reset it to default vehicle density of 1.0. Copy the code to notepad and name "Traffic.vb" All necessary .net scripthook requirements that "blowjobcumpussy" are the same. Also, feel free to place it in a .cs converter and modify yourself. ps, i tested the script and it functions.

Link to comment
Share on other sites

icecube3456

Thanks for the help. I just made the script spawn the player in a vehicle and if you spawn another vehicle it deletes the current one and spawns you in another.

Link to comment
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
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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