How can I pre-spawn in cars for a c# script mod?
-
I have new to c# coding and i was trying to find some help on how to pre-spawn in cars for a script. I have currently got to the point where I 'steal money from a bag' and then I have to get through a gang of people to an escape vehicle out the other side of the building. I was wondering how i can have the vehicle spawn so that when they get to that point in the mission it is already there.
Thanks.
Any help would be much appreciated.
-
There are a couple of ways.
one easy way is to Have a Vector3 position that you check the players distance too.Vector3 somePosition = new Vector3(99f,99f,99f); // the location you want to check if the player is near bool spawnedStuff = false;
then in your ontick()
float distanceToMission = Game.Player.Character.Position.DistanceTo(somePosition); if(!spawnedStuff && distanceToMission < 200) { spawnedStuff = true; // spawn your stuff } else if(spawnedStuff && distanceToMission > 200) { spawnedStuff = false; // despawn your stuff }
There are other methods, but this would depend on how you have structured your code and if you keep track of the state of the mission using a
switch case
.
-
@mcal9909 OK, thanks a lot. Coming to help again