Objects on random position.
#1

Hello!
It's possible to create objects on random map?

For example, I have object 3026. I want to create this object 3026 on random positions?
Is there any way to do this?

Thanks!
Reply
#2

Quote:
Originally Posted by HY
Посмотреть сообщение
Hello!
It's possible to create objects on random map?

For example, I have object 3026. I want to create this object 3026 on random positions?
Is there any way to do this?

Thanks!
I guess yes, and if I'm right, it's the same way you do to set random player positions.
Reply
#3

Just create an array which contains the coordinates that you want the object to spawn randomly on and use the random function to get a random position in the array.
Reply
#4

Quote:
Originally Posted by awoo
Посмотреть сообщение
I guess yes, and if I'm right, it's the same way you do to set random player positions.
Quote:
Originally Posted by Mystique
Посмотреть сообщение
Just create an array which contains the coordinates that you want the object to spawn randomly on and use the random function to get a random position in the array.
I know this, lol.
I mean, to spawn object in any place of map.
For example, object 3026 will be spawned in San Fierro at Docks, but I don't want to save position, just random.
Reply
#5

Hi, yes thats possible and do such stuff in my gamemode. All you have to do is to fetch the Z pos. For this you need Kalcor's MapAndreas. You can randomize the X and Y coords (random function) and insert them to find the Z coord using the above MapAndreas plugin. Use the three coords to create the object.

NOTE THAT:
- The object might be created anywhere i.e you might need to add limits.
- Make sure that the randomized X, Y are within SA-MP's boundaries.
Reply
#6

new rand[4];
rand[0] = random(3000);
rand[1] = random(3000);
rand[2] = random(300);
( rand[3] add random(2) if it's 1 => multiply rand[0] by 1 , if 0 multiply it by -1 )
SetObjectPos(theobject you created, rand[0], rand[1], rand[2]);
Send message to admins : format(string, 128, " Item spawned in %f, %f, %f coords.", rand[0], rand[1], rand[2]);
Good luck finding it, that's what you asked for ( random ) because you said you don't wanna make array that contains different ( real random position ) because random can spawn the object in the air, in buildings, in mountains ..

MapAndreas uses a lot of RAM, it's efficient, accurate, but too heavy.
Reply
#7

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
Hi, yes thats possible and do such stuff in my gamemode. All you have to do is to fetch the Z pos. For this you need Kalcor's MapAndreas. You can randomize the X and Y coords (random function) and insert them to find the Z coord using the above MapAndreas plugin. Use the three coords to create the object.

NOTE THAT:
- The object might be created anywhere i.e you might need to add limits.
- Make sure that the randomized X, Y are within SA-MP's boundaries.
Quote:
Originally Posted by Golimad
Посмотреть сообщение
new rand[4];
rand[0] = random(3000);
rand[1] = random(3000);
rand[2] = random(300);
( rand[3] add random(2) if it's 1 => multiply rand[0] by 1 , if 0 multiply it by -1 )
SetObjectPos(theobject you created, rand[0], rand[1], rand[2]);
Send message to admins : format(string, 128, " Item spawned in %f, %f, %f coords.", rand[0], rand[1], rand[2]);
Good luck finding it, that's what you asked for ( random ) because you said you don't wanna make array that contains different ( real random position ) because random can spawn the object in the air, in buildings, in mountains ..

MapAndreas uses a lot of RAM, it's efficient, accurate, but too heavy.
Thanks both!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)