How I do this?
#1

I would like to know how random objects appear.
Reply
#2

You store Coordinates to a Multidimensional Array and from that, using random() function, you can choose a random index of array and can spawn any object on that coordinates.
Reply
#3

Quote:
Originally Posted by GTLS
Посмотреть сообщение
You store Coordinates to a Multidimensional Array and from that, using random() function, you can choose a random index of array and can spawn any object on that coordinates.
Can you give me a simple example?
Reply
#4

Код:
#define MAX_WORLD_CO 4

//You can also add the object ID, after coordinates like so {2443.20, 2872.08, 182.14, 2399/*Object ID*/}
new Float:WorldCoordinates[MAX_WORLD_CO][3] = {
    {2443.20, 2872.08, 182.14},      //0
    {2683.04, -1340.28, 150.90},   //1
    {398.05, 1427.73, 184.44},     //2
    {2283.20, 187.08, 182.14}      //3
};


stock randomEx(min, max)
{    
    //Credits to ******    
    new rand = random(max-min)+min;    
    return rand;
}

forward RandomWorldCoordinates(playerid);
public RandomWorldCoordinates(playerid)
{
      new ID = randomEx(0, MAX_WORLD_CO-1);

      //Create objects with this ID. (random).
      
      new Float: X, Float: Y, Float: Z;

      X = WorldCoordinates[ID][0];
      Y = WorldCoordinates[ID][1];
      Z = WorldCoordinates[ID][2];

   
      CreateObject(2587, X, Y, Z, 0.0, 0.0, 96.0); // Object will render at its default distance.

      return 1;
}
Reply
#5

Actually if you set the coordinates manually that's not random!
I guess MapAndreas could help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)