Random spawn in area - 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 spawn in area (
/showthread.php?tid=81974)
Random spawn in area -
Dreftas - 15.06.2009
I make area with minx, maxx, miny, maxy. How to make random spawn in that area? Spawn anywhere in that area?
Re: Random spawn in area -
dice7 - 15.06.2009
Save 12 (or more) coordinates then use random()
https://sampwiki.blast.hk/wiki/Random
pawn Код:
new c = random(12)+1; //creates a random number from 0 to 12
switch (c)
{
case 0:{SetPlayerPos(playerid,286.9416,1410.9337,10.3947);}
case 1:{SetPlayerPos(playerid,286.9416,1410.9337,10.3947);}
case 2:{SetPlayerPos(playerid,215.0739,1411.1678,10.5859);}
case 3:{SetPlayerPos(playerid,111.3430,1410.3840,10.6022);}
case 4:{SetPlayerPos(playerid,189.9601,1483.5343,10.5859);}
case 5:{SetPlayerPos(playerid,205.5110,1347.1440,10.5859);}
case 6:{SetPlayerPos(playerid, 215.0226,1466.8556,23.7344);}
case 7:{SetPlayerPos(playerid,246.6161,1361.7271,23.3703);}
case 8:{SetPlayerPos(playerid, 246.3493,1435.4602,23.3750);}
case 9:{SetPlayerPos(playerid, 215.0226,1466.8556,23.7344);}
case 10:{SetPlayerPos(playerid, 187.6121,1371.7318,23.7344);}
case 11:{SetPlayerPos(playerid, 187.6121,1371.7318,23.7344);}
case 12:{SetPlayerPos(playerid, 246.6161,1361.7271,23.3703);}
}
Re: Random spawn in area -
Dreftas - 15.06.2009
Here is the problem, I want to make random spawn in that area without saving spawn positions,just having MinX, MaxX, MinY, MaxY. How to make that ?
Re: Random spawn in area -
yezizhu - 15.06.2009
pawn Код:
SetPlayerPos(
random(maxx-minx)+minx,
random(maxy-miny)+minz,
z
);
Re: Random spawn in area -
Dreftas - 15.06.2009
Quote:
Originally Posted by yezizhu
pawn Код:
SetPlayerPos( random(maxx-minx)+minx, random(maxy-miny)+minz, z );
|
pawn Код:
SetPlayerPos(
random(maxx-minx)+minx,
random(maxy-miny)+minz, // +miny here i think :)
z
);
Thanks
Re: Random spawn in area -
yezizhu - 15.06.2009
You're right^^