SA-MP Forums Archive
one coordinate = only one object - HOW? +rep! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: one coordinate = only one object - HOW? +rep! (/showthread.php?tid=330516)



one coordinate = only one object - HOW? +rep! - PawnoQ - 01.04.2012

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);
            }



Re: one coordinate = only one object - HOW? +rep! - blank. - 02.04.2012

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.


Re: one coordinate = only one object - HOW? +rep! - PawnoQ - 02.04.2012

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


Re: one coordinate = only one object - HOW? +rep! - blank. - 02.04.2012

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


Re: one coordinate = only one object - HOW? +rep! - PawnoQ - 02.04.2012

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


Re: one coordinate = only one object - HOW? +rep! - PawnoQ - 05.04.2012

help?


Re: one coordinate = only one object - HOW? +rep! - WooTFTW - 05.04.2012

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);
            }



Re: one coordinate = only one object - HOW? +rep! - PawnoQ - 06.04.2012

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.