Random Spawn?
#1

Anyone got any idea why this isn't randomly spawing the player in the two places ?

Код:
new Float:RandomSpawns[2][4] = {
{-2365.1787, -1635.4945, 485.9717, 253.8724},
{1958.3783, 1343.1572, 15.3746, 269.1425}
};
Код:
	for(new i = 0; i < 299; i++)
  {
    if(IsValidSkin(i))
    {
      new rand = random(sizeof RandomSpawns);
      AddPlayerClass(i, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2], RandomSpawns[rand][3], 3, 0, 0, 0, 0, 0);
    }
  }
Reply
#2

yes: you are assigning a "random" spawn point to each skin, so for each skin a different spawn position will be chosen. i bet u placed it in OnGameModeInit(), so the random coordinates will be set to a skin once only - when the gamemode starts.
i guess, u want to let all players spawn at a new chosen position when they die, try:
pawn Код:
public OnPlayerSpawn(playerid)
{
new rand = random(sizeof RandomSpawns);
SetPlayerPos(playerid,RandomSpawns[rand][0],RandomSpawns[rand][1],RandomSpawns[rand][2],RandomSpawns[rand][3]);
SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
}
instead of your old "AddPlayerClass".
this way u make sure a new position will be chosen for all players and all skins at after spawn...

Reply
#3

someone can tell me why it doesnt work please

Код:
new RandomMilk[][2] = {
	{1},
	{0}
};
Код:
new rand = random(sizeof(RandomMilk));
	    HaveMilk[pickupid] = RandomMilk[rand][0], RandomMilk[rand][1], RandomMilk[rand][2];
C:\Users\maxime\Desktop\script Tropic Roleplay\gamemodes\tgmrp.pwn(241) : warning 215: expression has no effect
C:\Users\maxime\Desktop\script Tropic Roleplay\gamemodes\tgmrp.pwn(241) : error 032: array index out of bounds (variable "RandomMilk")
C:\Users\maxime\Desktop\script Tropic Roleplay\gamemodes\tgmrp.pwn(241) : warning 215: expression has no effect
Reply
#4

Why are you bumping those old topics? Create your own one.
And uhh, where are you Z Y X positions.
Reply
#5

Where Line 241
Reply
#6

Quote:
Originally Posted by timaoux
Посмотреть сообщение
someone can tell me why it doesnt work please

Код:
new RandomMilk[][2] = {
	{1},
	{0}
};
Код:
new rand = random(sizeof(RandomMilk));
	    HaveMilk[pickupid] = RandomMilk[rand][0], RandomMilk[rand][1], RandomMilk[rand][2];
C:\Users\maxime\Desktop\script Tropic Roleplay\gamemodes\tgmrp.pwn(241) : warning 215: expression has no effect
C:\Users\maxime\Desktop\script Tropic Roleplay\gamemodes\tgmrp.pwn(241) : error 032: array index out of bounds (variable "RandomMilk")
C:\Users\maxime\Desktop\script Tropic Roleplay\gamemodes\tgmrp.pwn(241) : warning 215: expression has no effect
For one, you are assigning a variable multiple values. Secondly, your array index is out-of-bounds. I assume you're trying to assign a random value to that pickup (HaveMilk[pickupid]) of a value of 1 or 0:
pawn Код:
new rand = random( sizeof( RandomMilk ) );
HaveMilk[ pikcupid ] = RandomMilk[ rand ];
Reply
#7

thx Grim_
Reply
#8

Edit: Guess you fixed it yourself. No problem.
Reply
#9

but with this is not a random i got ever 0=no milk
Reply
#10

You're only setting the value to one variable, and there is only two options. It is possible that it would randomly pick the 0 value multiple times before the other(s).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)