Objects on random position. -
HY - 03.03.2015
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!
Re: Objects on random position. -
awoo - 03.03.2015
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.
Re: Objects on random position. -
Mystique - 03.03.2015
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.
Re: Objects on random position. -
HY - 03.03.2015
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.
Re: Objects on random position. -
Evocator - 03.03.2015
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.
Re : Objects on random position. -
Golimad - 03.03.2015
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.
Re: Re : Objects on random position. -
HY - 03.03.2015
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!