Random Spawn Problem
#1

Hi, I get an error when I try to compile this:

pawn Код:
new Float:gRandomPlayerSpawns[23][3] = {
{1126.0092,-2037.9825,69.8832,266.0716},
{1218.6750,-1813.6223,16.5938,173.7294},
{1682.0446,-1975.2065,21.9609,270.6907},
{2000.3623,-1964.0881,16.6941,346.7484},
{2639.2134,-2004.1072,13.5547,262.3929},
{2466.8745,-1952.4679,16.8357,2.0895},
{2311.6658,-2006.3544,16.0291,359.6062},
{2706.1008,-1822.2168,11.8438,162.3573},
{2527.5410,-1716.2231,13.4974,175.1807},
{2403.5842,-1549.4222,28.0000,354.3857},
{2316.0547,-1527.5721,25.3438,271.0616},
{1099.5416,-825.6235,114.4477,20.4942},
{1291.9457,-768.9805,95.9688,176.4889},
{1535.7139,-1365.3596,329.4609,356.9391},
{1281.8003,-1485.7231,13.5469,272.6516},
{668.6912,-1275.0568,13.4609,90.9400},
{757.2111,-1259.3552,13.5647,92.4833},
{894.9800,-1253.0883,15.1358,2.2425},
{824.9377,-1102.9980,25.7891,268.8854},
{821.7704,-1362.3132,-0.5078,319.6679},
{888.0453,-1372.8567,25.2025,353.1949},
{1710.7283,-1099.3209,24.0781,358.3517},
{1970.6563,-1157.0607,20.9617,274.9936}
};
Error:

pawn Код:
C:\Users\Damien\Desktop\samp server\gamemodes\lsdm.pwn(15) : error 018: initialization data exceeds declared size
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Line 15 is the first random spawn ({1126.0092,-2037.9825,69.8832,266.0716},)

i'm not sure whats wrong, please help
Reply
#2

pawn Код:
new Float:gRandomPlayerSpawns[23][4]
[3] = X, Y, and Z
[4] = X, Y, Z, and Angle
Reply
#3

Thanks a bunch, made a stupid mistake
Reply
#4

Hmm, I have another problem. It doesnt spawn me to the random spawn point. It brings me to this random place, where there's nothing around
Reply
#5

Well we'd need to see the rest of the script to fix that.
Reply
#6

I switched to this https://sampwiki.blast.hk/wiki/Random

pawn Код:
new Float:RandomSpawn[23][4] =
{
{1126.0092,-2037.9825,69.8832,266.0716},
{1218.6750,-1813.6223,16.5938,173.7294},
{1682.0446,-1975.2065,21.9609,270.6907},
{2000.3623,-1964.0881,16.6941,346.7484},
{2639.2134,-2004.1072,13.5547,262.3929},
{2466.8745,-1952.4679,16.8357,2.0895},
{2311.6658,-2006.3544,16.0291,359.6062},
{2706.1008,-1822.2168,11.8438,162.3573},
{2527.5410,-1716.2231,13.4974,175.1807},
{2403.5842,-1549.4222,28.0000,354.3857},
{2316.0547,-1527.5721,25.3438,271.0616},
{1099.5416,-825.6235,114.4477,20.4942},
{1291.9457,-768.9805,95.9688,176.4889},
{1535.7139,-1365.3596,329.4609,356.9391},
{1281.8003,-1485.7231,13.5469,272.6516},
{668.6912,-1275.0568,13.4609,90.9400},
{757.2111,-1259.3552,13.5647,92.4833},
{894.9800,-1253.0883,15.1358,2.2425},
{824.9377,-1102.9980,25.7891,268.8854},
{821.7704,-1362.3132,-0.5078,319.6679},
{888.0453,-1372.8567,25.2025,353.1949},
{1710.7283,-1099.3209,24.0781,358.3517},
{1970.6563,-1157.0607,20.9617,274.9936}
};

public OnPlayerSpawn(playerid)
{
  new iRandom = random(sizeof(RandomSpawn));
  SetPlayerPos(playerid, RandomSpawn[iRandom][0], RandomSpawn[iRandom][1],RandomSpawn[iRandom][2]);
  SetPlayerFacingAngle(playerid, RandomSpawn[iRandom][3]);

  return 1;
}
Reply
#7

I assume none of your RandomSpawns are inside of interiors, so:

pawn Код:
public OnPlayerSpawn(playerid)
{
  new iRandom = random(sizeof(RandomSpawn));
  SetPlayerPos(playerid, RandomSpawn[iRandom][0], RandomSpawn[iRandom][1],RandomSpawn[iRandom][2]);
  SetPlayerFacingAngle(playerid, RandomSpawn[iRandom][3]);
  SetPlayerInterior(playerid, 0);
  SetPlayerVirtualWorld(playerid, 0);
  return 1;
}
Try that.
Reply
#8

Quote:
Originally Posted by ledzep
I assume none of your RandomSpawns are inside of interiors, so:

pawn Код:
public OnPlayerSpawn(playerid)
{
  new iRandom = random(sizeof(RandomSpawn));
  SetPlayerPos(playerid, RandomSpawn[iRandom][0], RandomSpawn[iRandom][1],RandomSpawn[iRandom][2]);
  SetPlayerFacingAngle(playerid, RandomSpawn[iRandom][3]);
  SetPlayerInterior(playerid, 0);
  SetPlayerVirtualWorld(playerid, 0);
  return 1;
}
Try that.
It worked, thanks a bunch
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)