SA-MP Forums Archive
An easier way to do this? - 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: An easier way to do this? (/showthread.php?tid=347538)



An easier way to do this? - Gangs_Rocks - 02.06.2012

Okay, so I'm making a stunt server and I wanna create some pickups in the Deathmatch areas. Now here's what I did in the past to do this:

new DMBaseballPickup1,
DMBaseballPickup2;

/// And 3-4


DMBaseballlPickup1= CreatePickup(...)
DMBaseballPickup2= CreatePickup(....)

// Then on Player Pickup//


But is there a simpler way? I've heard arrays can help in this matter but I've used arrays only in random spawns till now, I've got no idea how to put it all in arrays and sort it out per deathmatch arena.


Re: An easier way to do this? - newbienoob - 02.06.2012

pawn Код:
new DMBaseballPickup[5];

DMBaseballPickup[0] = Create........
DMBaseballPickup[1] = Create........
Try that ^


Re: An easier way to do this? - leonardo1434 - 02.06.2012

new NAMEOFPIKCUP[THENUMBEROFARRAY]

EX:

pawn Код:
new LOL[3]

// it will create like this to be used.

LOL[0]
LOL[1]
LOL[2]



Re: An easier way to do this? - Niko_boy - 02.06.2012

lol
he doesnt mean what u guys replied
he mean instead of type that much if he can create
with again and again creating variables and putting pickups in object
is there any way?
pawn Код:
enum pickup_Info{
model,
pType,
Float:pX,
Float:pY,
Float:pZ,
world
}

new PickupsArray[][pickup_Info] =
{
     { modelid,pos x, pos y,pos z , virtual world}, // cordinates here in format modelid,pos x, pos y,pos z , virtula world
     {1234,1, 1, 1, 1, 0}//e.g. // just an example
};
// name Pickupsnot actually namein just comment in front of each line in pickup array
and in filter script init
Код HTML:
public OnFilterScriptInit()
{
    for(new o = 0; o < sizeof(Objects); o++)
    {
     CreatePickup(PickupsArray[o][model],PlayerArray[o][pType],PickupsArray[o][pX],PickupsArray[o][pY],PickupsArray[o][pZ],PickupsArray[o][pRZ],PickupsArray[o][world]);
    }
}
// now use Pickup(the number like inside OnPlayerPickupPickup
PHP код:
public OnPlayerPickupPickup(playerid pickupid)
{
     if(
pickupid == PickupArray[4]) // will be the 4th pickup inside array
     
{
 
//rest  code here
     
}

i actualy my self never tried it :P


Re: An easier way to do this? - Ballu Miaa - 02.06.2012

Build Your Own Pickup system using enumeration and arrays.
pawn Код:
// Add it below include files.
#define MAX_PICKUPS 200

enum pickup
{
     pID,
     pModel,
     pType,
     Float:pX,
     Float:pY,
     Float:pZ,
     pWorld,
}
new PickupVar[MAX_PICKUPS][pickup];
Thats a basic format of using. Store the values in these arrays and load them accordingly using for loop.

EX:
pawn Код:
for(new i=0;i >= MAX_PICKUPS;i++) return CreatePickup(PickupVar[i][pModel],PickupVar[i][pType],PickupVar[i][pX],PickupVar[i][pY],PickupVar[i][pZ],PickupVar[i][pWorld]);



Re: An easier way to do this? - Gangs_Rocks - 02.06.2012

I don't understand how's this practically gonna help me out with pickups. + I want the pickups to be at random locations. Can someone explain and help me?


Re: An easier way to do this? - FearLe$$ - 02.06.2012

Gangs why ya resigned from COD5 man?


Re: An easier way to do this? - Gangs_Rocks - 02.06.2012

Bump.

@Fearless: I'm going mass inactive + I wanted to learn scripting with a free mind. I haven't told the second reason to anyone in COD5 as I didn't wanna look like a copycat suspect. + I'm working on a stunt, not a TDM


Re: An easier way to do this? - Gangs_Rocks - 03.06.2012

Bumping.


Re: An easier way to do this? - Azazelo - 03.06.2012

Quote:

new rnd = random(5000));
new stop = 0;
do
{
CreatePickup(1242, 2,15*rnd, 15*rnd, 15*rnd, -1);
}
until (stop == 1);

This will make it random