Moneyrush random point question
#1

hi,
ive got kinda a moneyrush mode in my script. There are 30 random locations where the moneybag could be located.
Ive done it like:

pawn Код:
//This are my 4 moneybag pickups (created after entered a certain checkpoint)
pickup1 = CreateDynamicPickup(1241,3,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);

pickup2 = CreateDynamicPickup(1241,4,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);

pickup3 = CreateDynamicPickup(1241,5,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);

pickup4 = CreateDynamicPickup(1241,6,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);

new Float:MoneyRushPoints[30][5] = //My random moneyrush locations
{

{-1633.6028,-2244.1521,31.4766},
{-1635.2443,-1935.8237,115.1392},
//and 28 more ;)

};
Well, everything works fine exept all 4 pickups are created at the same time (after uve entered a cp) and at the same location.
But i want that every pickup appears somewhere else.
I thought about using a timer to delay the creation of the pickups and force them to spawn somewhere else like that.
cause i dont want to define another Spawnpoints function with 30 locations.
I want to reduce text in my script so i thought there might be some more elegant solutions for that.

regards...
Reply
#2

This shall work... it will create pickups at different locations.

pawn Код:
//This are my 4 moneybag pickups (created after entered a certain checkpoint)
pickup1 = CreateDynamicPickup(1241,3,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);

pickup2 = CreateDynamicPickup(1241,4,MoneyRushPoints[RRush+1][0],MoneyRushPoints[RRush+1][1],MoneyRushPoints[RRush+1][2],0);

pickup3 = CreateDynamicPickup(1241,5,MoneyRushPoints[RRush+2][0],MoneyRushPoints[RRush+2][1],MoneyRushPoints[RRush+2][2],0);

pickup4 = CreateDynamicPickup(1241,6,MoneyRushPoints[RRush+3][0],MoneyRushPoints[RRush+3][1],MoneyRushPoints[RRush+3][2],0);

RRush +=4;
//EDIT
if(RRush >= 30) RRush = 0; //This will reset count and start all over again
//Oh yes, your random moneyrush locations should be divisible by 4 :) make either 28, 32, 36, 40 or more...

new Float:MoneyRushPoints[30][3] = //My random moneyrush locations
{

{-1633.6028,-2244.1521,31.4766},
{-1635.2443,-1935.8237,115.1392},
//and 28 more ;)

};
Reply
#3

pawn Код:
new PickUpids[4];

new Float:MoneyRushPoints[][3] = //you had two to many cells on the 2nd dimension
{
    {-1633.6028,-2244.1521,31.4766},
    {-1635.2443,-1935.8237,115.1392}
};

public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == MONEY_RUSH_CP)
    {
        new
            RRush;
        for(new i; i < 4; i++)
        {
            RRush = random(sizeof(MoneyRushPoints));
            PickUpids[i] = CreateDynamicPickup(1241,3,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);
        }
    }
    return 1;
}
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    for(new i; i < 4; i++)
    {
        if(pickupid == PickUpids[i])
        {
            new
                RRush= random(sizeof(MoneyRushPoints));
            //do pickup stuff here
            PickUpids[i] = CreateDynamicPickup(1241,3,MoneyRushPoints[RRush][0],MoneyRushPoints[RRush][1],MoneyRushPoints[RRush][2],0);
            break;
        }
    }
    return 1;
}
If i understood correctly that should work.
Reply
#4

thx a lot once again.
i used iggys code cause this one worked

regards.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)