Jump to content

Create vehicle either here or there


S.Eagle

Recommended Posts

Posted

I tried to spawn vehicles at a random location using math.rand(a,b) , but I sometimes have the problem that the vehicles get stuck in each other.

So I've chosen a few preset locations for the vehicles to spawn. But I have absolutely no clue how to make that the vehicles only spawn at those locations. I couldn't really find anything usefull.

So how do I make a vehicle spawn at either location a or location b?

Thnaks in advance.

Posted

You can make a table containing coordinates (in other tables) and then select a random index from the first table.

locations=
{
{1,2,3},
{4,5,6},
{7,8,9}
}
 
random_location = locations[  math.random(1, #locations)  ]

Posted

I mean you need to download map to clients separately; objects created in script don't need to be downloaded. Furthermore, downloading like 500kb-2mb every time you enter the server is very tiring.

Posted
I mean you need to download map to clients separately; objects created in script don't need to be downloaded. Furthermore, downloading like 500kb-2mb every time you enter the server is very tiring.

How do you think your script tells every player there is an object or a vehicle spawned in that specific place? They "download" (receive) the data which server sends to them to tell them where the vehicles, objects, markers, other players, etc. are located.

Posted

Map files aren't sent to clients. They're sent much more optimally when you use a map file than when you create them from a script. Each script object you create is (potentially) a new packet of data to be sent, map data is sent when the player joins in much larger packets. It's also much faster as you don't have a whole load of calls to script functions. Basically, don't do it.

Posted
Ok, so I have placed a few vehicles in a map file. Now, I only want one of them to spawn, randomly. How do I proceed?

If you add vehicles with tag then you can't. You can use your own tag (say, ) and use getElementsByType function to get all the elements of that type (randomVehSpawn in this case) and than create your vehicle at one of those places. This is not ideal because you'll still have to use createVehicle.

Posted

That might be a feature that's worth supporting officially - a 'start-not-spawned' flag.

Even so, this is the preferred method as the positions can be set using the editor.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...