SA-MP Forums Archive
random spawn place - 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 place (/showthread.php?tid=241823)



random spawn place - Madsen - 18.03.2011

Hey i am making a dm server for fun that me and my friends can play in together and have fun.

but i have made a minigunwar place and you always spawn the same place so they can just spawnkill...

how can i make 10 more spawn places so its random where they spawn ?


Re: random spawn place - Jochemd - 18.03.2011

Took me 3 seconds to find, but here it is anyways


Re: random spawn place - [L3th4l] - 18.03.2011

pawn Код:
new Float:SpawnLocs[][3] = {
    {0.0, 0.0, 0.0},
    {0.0, 0.0, 0.0},
    {0.0, 0.0, 0.0}
};

new rPos = random(sizeof(SpawnLocs));

SetPlayerPos(playerid, SpawnLocs[rPos][0], SpawnLocs[rPos][1], SpawnLocs[rPos][2]);



Re: random spawn place - Madsen - 18.03.2011

thx both helped me alot, and i tried finding it on samp wiki but i could not..


Re: random spawn place - Madsen - 18.03.2011

i almost got it to work..

but i spawn out in nowhere and i have triple checked the cord and i have no warnings or errors.

at the top of my script:
Код:
new Float:locmgw[][4] =
{
	(2179.2834, 1622.2817, 999.9767, 8.9377),
	(2173.2778, 1576.6918, 999.9637, 349.3425),
	(2190.0759, 1593.7576, 999.9708, 25.0665),
	(2196.9924, 1612.3495, 999.9675, 275.2932),
	(2206.8613, 1579.8500, 999.9770, 251.5817),
	(2222.3083, 1598.8792, 999.9706, 168.0277),
	(2232.3013, 1589.5380, 999.9569, 349.7713)
};
OnPlayerSpawn
Код:
    if(mgw[playerid] == 1)
    {
    new spawnmgw = random(sizeof(locmgw));
	SetPlayerInterior(playerid, 1);
	SetPlayerPos(playerid, locmgw[spawnmgw][0], locmgw[spawnmgw][1], locmgw[spawnmgw][2]);
    SetPlayerFacingAngle(playerid, locmgw[spawnmgw][3]);
    GivePlayerWeapon(playerid, 38, 111110); // minigun
    SetPlayerHealth(playerid, 200);
    }



AW: random spawn place - xerox8521 - 18.03.2011

pawn Код:
if(mgw[playerid] == 1)
   {
     new spawnmgw = random(sizeof(locmgw));
     SetPlayerPos(playerid, locmgw[spawnmgw][0], locmgw[spawnmgw][1], locmgw[spawnmgw][2]);
     SetPlayerInterior(playerid, 1);
     SetPlayerFacingAngle(playerid, locmgw[spawnmgw][3]);
     GivePlayerWeapon(playerid, 38, 111110); // minigun
     SetPlayerHealth(playerid, 200);
    }



Re: random spawn place - sciman001 - 19.03.2011

Quote:
Originally Posted by [L3th4l]
Посмотреть сообщение
pawn Код:
new Float:SpawnLocs[][3] = {
    {0.0, 0.0, 0.0},
    {0.0, 0.0, 0.0},
    {0.0, 0.0, 0.0}
};

new rPos = random(sizeof(SpawnLocs));

SetPlayerPos(playerid, SpawnLocs[rPos][0], SpawnLocs[rPos][1], SpawnLocs[rPos][2]);
NICE!!!!! I may use this. Simple but effective!!! THANKZ!


Re: AW: random spawn place - Madsen - 19.03.2011

Quote:
Originally Posted by xerox8521
Посмотреть сообщение
pawn Код:
if(mgw[playerid] == 1)
   {
     new spawnmgw = random(sizeof(locmgw));
     SetPlayerPos(playerid, locmgw[spawnmgw][0], locmgw[spawnmgw][1], locmgw[spawnmgw][2]);
     SetPlayerInterior(playerid, 1);
     SetPlayerFacingAngle(playerid, locmgw[spawnmgw][3]);
     GivePlayerWeapon(playerid, 38, 111110); // minigun
     SetPlayerHealth(playerid, 200);
    }
did you just line it up ??. because thats not the reason its not working...

i lined it up under my script but under the forum it was not lined up proberly


Re: random spawn place - JaTochNietDan - 19.03.2011

Quote:
Originally Posted by Madsen
Посмотреть сообщение
i almost got it to work..

but i spawn out in nowhere and i have triple checked the cord and i have no warnings or errors.

at the top of my script:
Код:
new Float:locmgw[][4] =
{
	(2179.2834, 1622.2817, 999.9767, 8.9377),
	(2173.2778, 1576.6918, 999.9637, 349.3425),
	(2190.0759, 1593.7576, 999.9708, 25.0665),
	(2196.9924, 1612.3495, 999.9675, 275.2932),
	(2206.8613, 1579.8500, 999.9770, 251.5817),
	(2222.3083, 1598.8792, 999.9706, 168.0277),
	(2232.3013, 1589.5380, 999.9569, 349.7713)
};
OnPlayerSpawn
Код:
    if(mgw[playerid] == 1)
    {
    new spawnmgw = random(sizeof(locmgw));
	SetPlayerInterior(playerid, 1);
	SetPlayerPos(playerid, locmgw[spawnmgw][0], locmgw[spawnmgw][1], locmgw[spawnmgw][2]);
    SetPlayerFacingAngle(playerid, locmgw[spawnmgw][3]);
    GivePlayerWeapon(playerid, 38, 111110); // minigun
    SetPlayerHealth(playerid, 200);
    }
You're using the wrong bracket type for the initialization of the multi-dimensional array containing the co-ordinates, you should be using the curly brackets "{ }" instead of the smooth brackets "( )".


Re: random spawn place - Madsen - 19.03.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
You're using the wrong bracket type for the initialization of the multi-dimensional array containing the co-ordinates, you should be using the curly brackets "{ }" instead of the smooth brackets "( )".
:O wierd last time i used the { } instead of ( ) and i got like 20 warnings hmm xD..

but it works now thx alot