SA-MP Forums Archive
Random Pickup Spawn - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Random Pickup Spawn (/showthread.php?tid=239251)



Random Pickup Spawn - airsoft - 13.03.2011

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?


Re: Random Pickup Spawn - Antonio [G-RP] - 13.03.2011

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



Re: Random Pickup Spawn - airsoft - 13.03.2011

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


Re: Random Pickup Spawn - blackwave - 13.03.2011

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.


Re: Random Pickup Spawn - Sasino97 - 13.03.2011

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


Re: Random Pickup Spawn - blackwave - 13.03.2011

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


Re: Random Pickup Spawn - ElChapoGuzman - 13.03.2011

well just add the coordinates -_-


Re: Random Pickup Spawn - Mauzen - 13.03.2011

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.


Re: Random Pickup Spawn - airsoft - 13.03.2011

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...


Re: Random Pickup Spawn - airsoft - 13.03.2011

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