Grouping Arrays
#1

Hey guys, i'm using arrays to randomly select objects but lets say i want to select 2 objects at a time and they need to be grouped in the sense if object 1 spawns then object 2 spawns and if object 3 spawns then object 4 spawns. I was thinking about doing two separate arrays to spawn the objects but the issue is it selects from the group randomly. Any ideas?
Reply
#2

Show your code.
Reply
#3

pawn Код:
new randomSpawns[12][4] = {
    {1535.6497,-1679.7516,13.3828},   //fire 1
    {1535.6281,-1684.0664,13.5469},   //fire 1
    {1535.6559,-1689.5146,13.5469},   //fire 1
    {1535.5216,-1696.2633,13.5469},   //fire 1
    {1698.7971,1435.2810,10.7149},    //fire 2
    {1702.1265,1432.8711,10.6901},    //fire 2
    {1703.1891,1426.2205,10.6406},    //fire 2
    {1703.6338,1420.9512,10.6484},    //fire 2
    {1172.3600,-1323.3131,15.4029},   //fire 3
    {1175.4486,-1325.5078,14.3906},   //fire 3
    {1178.7393,-1326.0090,14.1349},   //fire 3
    {1182.5364,-1327.6281,13.5824},   //fire 3
};

//----

public AddFire(Float:x, Float:y, Float:z)
{
    new slot = GetFlameSlot();
    if(slot == -1) {return slot;}
    Flame[slot][Flame_Exists] = 1;
    Flame[slot][Flame_pos][0] = x;
    Flame[slot][Flame_pos][1] = y;
    Flame[slot][Flame_pos][2] = z - Z_DIFFERENCE;
    Flame[slot][Flame_id] = CreateObject(18689, Flame[slot][Flame_pos][0], Flame[slot][Flame_pos][1], Flame[slot][Flame_pos][2], 0.0, 0.0, 0.0);
    return slot;
}
//----

OnGameModeInit{

    SetTimer("RandomFireSpawn",454131135113,true);
    return 1;
}

//--------

public RandomFireTimer{

AddFire(randomSpawns0, randomSpawns1, randomSpawns2);

return1;
}
This code was quickly typed up. So it may contain some newb errors
Reply
#4

Single Random Fire
pawn Код:
new randomSpawns[][3] =
{
    {1535.6497,-1679.7516,13.3828},   //fire 1
    {1535.6281,-1684.0664,13.5469},   //fire 1
    {1535.6559,-1689.5146,13.5469},   //fire 1
    {1535.5216,-1696.2633,13.5469},   //fire 1
    {1698.7971,1435.2810,10.7149},    //fire 2
    {1702.1265,1432.8711,10.6901},    //fire 2
    {1703.1891,1426.2205,10.6406},    //fire 2
    {1703.6338,1420.9512,10.6484},    //fire 2
    {1172.3600,-1323.3131,15.4029},   //fire 3
    {1175.4486,-1325.5078,14.3906},   //fire 3
    {1178.7393,-1326.0090,14.1349},   //fire 3
    {1182.5364,-1327.6281,13.5824},   //fire 3
};

public RandomFireTimer
{
    new rndfire = random(sizeof(randomSpawns));
    AddFire(randomSpawns[rndfire][0], randomSpawns[rndfire][1], randomSpawns[rndfire][2]);
    return 1;
}
Grouped Fire
pawn Код:
new randomSpawns[][][3] =
{
    { {1535.6497,-1679.7516,13.3828}, {1535.6281,-1684.0664,13.5469}, {1535.6559,-1689.5146,13.5469}, {1535.5216,-1696.2633,13.5469} },  // fire 1
    { {1698.7971,1435.2810,10.7149}, {1702.1265,1432.8711,10.6901}, {1703.1891,1426.2205,10.6406}, {1703.6338,1420.9512,10.6484} },   // fire 2
    { {1172.3600,-1323.3131,15.4029}, {1175.4486,-1325.5078,14.3906}, {1178.7393,-1326.0090,14.1349}, {1182.5364,-1327.6281,13.5824} }   //fire 3
};
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)