Random Position ? - 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 Position ? (
/showthread.php?tid=231377)
Random Position ? -
park4bmx - 25.02.2011
Well i got this
Random Position ? Set up Is working fine but just 1 probblem
That Random Position is for a MiniGame and sometimes when the minigames starts 2/3 players are
SPAWNED in same position.
How Can I Prevent This From Happening ?
If you want to see my code
pawn Код:
//At the top of GM
new Float:RandomSpawn2[10][3] = {
{4443.4414,488.4186,30.9110},
{4467.0610,462.7075,30.8860},
{4467.3384,442.8307,30.8853},
{4509.6016,481.1109,48.0369},
{4484.2461,537.5523,48.0118},
{4443.5078,523.7330,30.6018},
{4362.3457,520.3850,30.5018},
{4361.7505,469.4979,30.5019},
{4320.5396,513.0151,48.0369},
{4455.7397,497.1385,48.0369}
};
//THen later On in Minigmae
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (playerinminigame[i] == 1)
{
new rand = random(sizeof(RandomSpawn2));
SetPlayerPos(i, RandomSpawn2[rand][0], RandomSpawn2[rand][1], RandomSpawn2[rand][2]);
}
//There is more but it has nothing to do with the problem.
Re: Random Position ? -
Jeffry - 25.02.2011
Hi park4bmx,
Try this code:
pawn Код:
//At the top of GM
new Float:RandomSpawn2[10][3] = {
{4443.4414,488.4186,30.9110},
{4467.0610,462.7075,30.8860},
{4467.3384,442.8307,30.8853},
{4509.6016,481.1109,48.0369},
{4484.2461,537.5523,48.0118},
{4443.5078,523.7330,30.6018},
{4362.3457,520.3850,30.5018},
{4361.7505,469.4979,30.5019},
{4320.5396,513.0151,48.0369},
{4455.7397,497.1385,48.0369}
};
new RandomSpawn2Num;
//THen later On in Minigmae
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (playerinminigame[i] == 1)
{
SetPlayerPos(i, RandomSpawn2[RandomSpawn2Num][0], RandomSpawn2[RandomSpawn2Num][1], RandomSpawn2[RandomSpawn2Num][2]);
RandomSpawn2Num++;
if(RandomSpawn2Num >= sizeof(RandomSpawn2)) RandomSpawn2Num=0;
}
If you have any questions or bugs in there, feel free to ask.
Jeffry
Re: Random Position ? -
park4bmx - 25.02.2011
Thanks so much 
Ur my Hero XD:
Re: Random Position ? -
Jeffry - 25.02.2011
Quote:
Originally Posted by park4bmx
Thanks so much 
Ur my Hero XD:
|
Glad I could help you.
Have fun.