icecube3456 Posted May 10, 2013 Share Posted May 10, 2013 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 More sharing options...
blowjobcumpussy Posted May 10, 2013 Share Posted May 10, 2013 (edited) 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 May 10, 2013 by blowjobcumpussy Link to comment Share on other sites More sharing options...
motorsport71 Posted May 11, 2013 Share Posted May 11, 2013 @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 More sharing options...
icecube3456 Posted May 11, 2013 Author Share Posted May 11, 2013 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now