PDA

View Full Version : Random pickups doubt


aalbero99
07/07/2015, 11:04 AM
I'd like to create a system which spawns objects such as guns, bags, etc. all around the map, so the player can go and pick them up, drop them, etc.
I've seen some systems but the problem's in the random thing, I don't really know how to do it since they could appear even in the air.
Thanks!

Misiur
07/07/2015, 11:56 AM
Most of those scripts aren't really 100% random. Of course you could create true randomness, fetch Z position using MapAndreas, but you'd have to refine it. Usually it's done like:
1. Create an array of viable positions
static stock const Float:Positions[3193219837132][3] = {
{ X, Y, Z },
{ X, Y, Z },
//ad nauseam
}

2. Generate random number between 0 and sizeof Positions - 1
3. Use that as an index