Quazaka Posted May 25, 2015 Share Posted May 25, 2015 I am some code that spawns a motorbike and set speed to 300. After i have spawned a handful of bikes i suddenly can't spawn anymore. Full code below using System.Drawing;using System.Windows.Forms;using GTA;using GTA.Native;using System;class CreateVehicle : Script{ bool canShootBikes = false; public CreateVehicle() { Tick += onTick; KeyUp += onKeyUp; KeyDown += onKeyDown; } private void onTick(object sender, EventArgs e) { } private void onKeyDown(object sender, KeyEventArgs e) { } private void ShootBikes() { if (!canShootBikes) { canShootBikes = true; } else { canShootBikes = false; } } private void onKeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F5) { ShootBikes(); } if (canShootBikes == true) { if (e.KeyCode == Keys.NumPad0) { Vehicle vehicle = World.CreateVehicle(VehicleHash.Bati2, Game.Player.Character.Position + Game.Player.Character.ForwardVector * 3.0f, Game.Player.Character.Heading); vehicle.PlaceOnGround(); vehicle.Speed = 300; } } }} Link to comment Share on other sites More sharing options...
c39687 Posted May 25, 2015 Share Posted May 25, 2015 Do this to toggle a bool... theBool = !theBool; Link to comment Share on other sites More sharing options...
c39687 Posted May 25, 2015 Share Posted May 25, 2015 (edited) I am some code that spawns a motorbike and set speed to 300. After i have spawned a handful of bikes i suddenly can't spawn anymore if they are mission entities then you might want to release them after you shoot so the game can delete them. Also 300 is way above the max speed. Edited May 25, 2015 by c39687 Link to comment Share on other sites More sharing options...
Quazaka Posted May 25, 2015 Author Share Posted May 25, 2015 Do this to toggle a bool... theBool = !theBool; Haha - monkey see, monkey do. I am some code that spawns a motorbike and set speed to 300. After i have spawned a handful of bikes i suddenly can't spawn anymore if they are mission entities then you might want to release them after you shoot so the game can delete them. Also 300 is way above the max speed. Figured out that a vehicle.MarkAsNoLongerNeeded(); Fixed it. 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