Random 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 Spawn? (
/showthread.php?tid=110034)
Random Spawn? -
Christopher. - 24.11.2009
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);
}
}
Re: Random Spawn? -
Babul - 24.11.2009
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...
Re : Random Spawn? -
timaoux - 07.08.2011
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
Re: Random Spawn? -
Kingunit - 07.08.2011
Why are you bumping those old topics? Create your own one.
And uhh, where are you Z Y X positions.
Re: Random Spawn? -
SmileyForCheat - 07.08.2011
Where Line 241
Re: Re : Random Spawn? -
Grim_ - 07.08.2011
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 ];
Re : Random Spawn? -
timaoux - 07.08.2011
thx Grim_
Re: Random Spawn? -
Grim_ - 07.08.2011
Edit: Guess you fixed it yourself. No problem.
Re : Random Spawn? -
timaoux - 07.08.2011
but with this is not a random i got ever 0=no milk
Re: Random Spawn? -
Grim_ - 07.08.2011
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).