Random Pickup Spawn
#1

How would i make pickups spawn at random places... like so players would have to search for them... thanks for any help... i know i would have to get the coordinates but... how would i make the pickups spawn randomly there?
Reply
#2

pawn Код:
new Float:RandomSpawns[][3] =
{
    {x coord, y coord, z coord},
    {x coord, y coord, z coord}
};

new rand = random(sizeof(RandomSpawns));
SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]);
Reply
#3

i dont want the players to spawn at the pickups i want the pickups to be spawned at random places...
Reply
#4

pawn Код:
new Float:RandomSpawns[][3] =
{
    {x coord, y coord, z coord},
    {x coord, y coord, z coord}
};

new rand = random(sizeof(RandomSpawns));
CreatePickup(model, type, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2], 0);
You can also do it many times by looping them and also putting as random the type / model.
Reply
#5

With that method the pickups can spawn in all san andreas, including on air.
Reply
#6

pawn Код:
new Float:RandomSpawns[][3] =
{
    {x coord, y coord, z coord},
    {x coord, y coord, z coord}
};
Positions are defined by that ^
Reply
#7

well just add the coordinates -_-
Reply
#8

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
With that method the pickups can spawn in all san andreas, including on air.
Nope, both ways mentioned here so far use a set of predefined coordinates that you set yourself, and it picks one of them to spawn the pickup. The x/y/z values are not randomized.

This would be another method, the best would be to use it with the MapAndreas Plugin (https://sampforum.blast.hk/showthread.php?tid=120013), so they wont spawn in the air.

pawn Код:
new Float:x, Float:y, Float:z;
x = random(6000) - 3000.0;    // random(max_value + min_value) - min_value;
y = random(6000) - 3000.0;   // random(max_value + min_value) - min_value;
MapAndreas_FindZ_For2DCoord(x, y, z);

CreatePickup(model, type, x, y, z + 0.5, 0);
This example will spawn a pickup at a random pos on the ground, somewhere in whole SA. You could adjust the max/min_values as you like.
Reply
#9

Quote:
Originally Posted by blackwave
Посмотреть сообщение
pawn Код:
new Float:RandomSpawns[][3] =
{
    {x coord, y coord, z coord},
    {x coord, y coord, z coord}
};

new rand = random(sizeof(RandomSpawns));
CreatePickup(model, type, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2], 0);
You can also do it many times by looping them and also putting as random the type / model.
Allright, i get that, but ive used this method with random spawns and i could only use like 3...

Another thing i need is that there be five pickups spawned every round of a game...
Reply
#10

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Nope, both ways mentioned here so far use a set of predefined coordinates that you set yourself, and it picks one of them to spawn the pickup. The x/y/z values are not randomized.

This would be another method, the best would be to use it with the MapAndreas Plugin (https://sampforum.blast.hk/showthread.php?tid=120013), so they wont spawn in the air.

pawn Код:
new Float:x, Float:y, Float:z;
x = random(6000) - 3000.0;    // random(max_value + min_value) - min_value;
y = random(6000) - 3000.0;   // random(max_value + min_value) - min_value;
MapAndreas_FindZ_For2DCoord(x, y, z);

CreatePickup(model, type, x, y, z + 0.5, 0);
This example will spawn a pickup at a random pos on the ground, somewhere in whole SA. You could adjust the max/min_values as you like.
Ok, uhm i think ill do that. Another question, how would i attach a mapicon to the Pickup
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)