random spawn place
#1

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 ?
Reply
#2

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

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]);
Reply
#4

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

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);
    }
Reply
#6

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);
    }
Reply
#7

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!
Reply
#8

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
Reply
#9

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 "( )".
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)