one coordinate = only one object - HOW? +rep!
#1

hi,

im using this code to spawn 5 pickups and random defined spawnpoints but sometimes it happens that there are 2 or even 3 pickups spawned at the same place.
How would i prevent that?
How can i make it like only 1 pickup can be spawned at a place?

+rep for help
pawn Код:
new Float:MoneyRushPoints[60][5] = //spawnpoints
{
    {-1633.6028,-2244.1521,31.4766},
    {-1635.2443,-1935.8237,115.1392},
    {-1335.9425,-2248.6763,32.5839},
    {-1845.4031,-1709.8015,41.1106},
    {-1820.0410,-1608.4302,23.0156},
    {-1982.5382,-2120.4873,74.5776},
    {-2089.5581,-2346.9045,30.6250},
//etc.
};

            new RRush = random(sizeof(MoneyRushPoints));
            DynPickup[2] = CreateDynamicPickup(1550,2,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);

            for(new i; i < 1; i++)
            {
                RRush = random(sizeof(MoneyRushPoints));
                PickUpDrugOnMr[1] = CreateDynamicPickup(1241,3,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);

                RRush = random(sizeof(MoneyRushPoints));
                PickUpDrugOnMr[2] = CreateDynamicPickup(1241,3,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);

                RRush = random(sizeof(MoneyRushPoints));
                PickUpDrugOnMr[3] = CreateDynamicPickup(1241,3,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);

                RRush = random(sizeof(MoneyRushPoints));
                PickUpDrugOnMr[4] = CreateDynamicPickup(1241,3,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);

                RRush = random(sizeof(MoneyRushPoints));
                PickUpDrugOnMr[5] = CreateDynamicPickup(1241,3,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);
            }
Reply
#2

When you spawn a pickup mark the location as occupied(By adding a value to the array or whatever) and run an if check to see if that point is occupied to avoid two pickups housing the same location.
Reply
#3

can you give me an example please, im not that good at this
Reply
#4

I just noticed the CreatePickup is in a loop, is there any reason for it?
Reply
#5

i also tried to make it without the loop first but then just all pickups were created at the same place...
Reply
#6

help?
Reply
#7

pawn Код:
new RRush = random(sizeof(MoneyRushPoints));
            DynPickup[2] = CreateDynamicPickup(1550,2,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);

            for(new i; i < 5; i++)
            {
                PickUpDrugOnMr[1] = CreateDynamicPickup(1241,3,MoneyRushPoints[i][0],MoneyRushPoints[i][1],MoneyRushPoints[i][2],0);

                PickUpDrugOnMr[2] = CreateDynamicPickup(1241,3,MoneyRushPoints[i][0],MoneyRushPoints[i][1],MoneyRushPoints[i][2],0);

                PickUpDrugOnMr[3] = CreateDynamicPickup(1241,3,MoneyRushPoints[i][0],MoneyRushPoints[i][1],MoneyRushPoints[i][2],0);
                PickUpDrugOnMr[4] = CreateDynamicPickup(1241,3,MoneyRushPoints[i][0],MoneyRushPoints[i][1],MoneyRushPoints[i][2],0);

                PickUpDrugOnMr[5] = CreateDynamicPickup(1241,3,MoneyRushPoints[i][0],MoneyRushPoints[i][1],MoneyRushPoints[i][2],0);
            }
Reply
#8

thx but now it works even worse
All pickups are created at the same place or not at all...


Please, someone can show me how to do this correctly?
Would really appreciate that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)