I think im abusing VARS
#1

Hey, basically I want to make something where the players each have a spawn point and an assigned variable, tell me if there is a better way to do this without wasting memory

How I did it:

Global Vars
Код:
new Spawn1;
new Spawn2;
new Spawn3;
new Spawn4;
new Spawn5;
new Spawn6;
new Spawn7;
new Spawn8;
new Spawn9;
new Spawn10;
new Spawn11;
new Spawn12;
new Spawn13;
new Spawn14;
new Spawn15;
new Spawn16;
new Spawn17;
new Spawn18;
new Spawn19;
new Spawn20;
new Spawn21;
new Spawn22;
new Spawn23;
new Spawn24;
new Spawn25;
new Spawn26;
new Spawn27;
new Spawn28;
new Spawn29;
new Spawn30;
new Spawn31;
new Spawn32;
new Spawn33;
new Spawn34;
new Spawn35;
new Spawn36;
new Spawn37;
// Grove Spawn
new Spawn38;
new Spawn39;
new Spawn40;
new Spawn41;
new Spawn42;
new Spawn43;
new Spawn44;
new Spawn45;
new Spawn46;
new Spawn47;
new Spawn48;
new Spawn49;
new Spawn50;
new Spawn51;
new Spawn52;
new Spawn53;
new Spawn54;
new Spawn55;
new Spawn56;
new Spawn57;
new Spawn58;
new Spawn59;
new Spawn60;
new Spawn61;
new Spawn62;
new Spawn63;
new Spawn64;
new Spawn65;
new Spawn66;
new Spawn67;
new Spawn68;
new Spawn69;
new Spawn70;
new Spawn71;
new Spawn72;
new Spawn73;
new Spawn74;
The player getting registered to the vars.
Код:
new PlayerVar = playerid;
if(PlayerInfo[playerid][pTeam] == 1)
{
if(playerid == 0)
{
PlayerVar = 101;
}
if(Spawn1 == 0)
{
Spawn1 = PlayerVar;
}
else if(Spawn2 == 0)
{
Spawn2 = PlayerVar;
}
else if(Spawn3 == 0)
{
Spawn3 = PlayerVar;
}
else if(Spawn4 == 0)
{
Spawn4 = PlayerVar;
}
else if(Spawn5 == 0)
{
Spawn5 = PlayerVar;
}
else if(Spawn6 == 0)
{
Spawn6 = PlayerVar;
}
else if(Spawn7 == 0)
{
Spawn7 = PlayerVar;
}
else if(Spawn8 == 0)
{
Spawn8 = PlayerVar;
}
else if(Spawn9 == 0)
{
Spawn9 = PlayerVar;
}
else if(Spawn10 == 0)
{
Spawn10 = PlayerVar;
}
else if(Spawn11 == 0)
{
Spawn11 = PlayerVar;
}
else if(Spawn12 == 0)
{
Spawn12 = PlayerVar;
}
else if(Spawn13 == 0)
{
Spawn13 = PlayerVar;
}
else if(Spawn14 == 0)
{
Spawn14 = PlayerVar;
}
else if(Spawn15 == 0)
{
Spawn15 = PlayerVar;
}
else if(Spawn16 == 0)
{
Spawn16 = PlayerVar;
}
else if(Spawn17 == 0)
{
Spawn17 = PlayerVar;
}
else if(Spawn18 == 0)
{
Spawn18 = PlayerVar;
}
else if(Spawn19 == 0)
{
Spawn19 = PlayerVar;
}
else if(Spawn20 == 0)
{
Spawn20 = PlayerVar;
}
else if(Spawn21 == 0)
{
Spawn21 = PlayerVar;
}
else if(Spawn22 == 0)
{
Spawn22 = PlayerVar;
}
else if(Spawn23 == 0)
{
Spawn23 = PlayerVar;
}
else if(Spawn24 == 0)
{
Spawn24 = PlayerVar;
}
else if(Spawn25 == 0)
{
Spawn25 = PlayerVar;
}
else if(Spawn26 == 0)
{
Spawn26 = PlayerVar;
}
else if(Spawn27 == 0)
{
Spawn27 = PlayerVar;
}
else if(Spawn28 == 0)
{
Spawn28 = PlayerVar;
}
else if(Spawn29 == 0)
{
Spawn29 = PlayerVar;
}
else if(Spawn30 == 0)
{
Spawn30 = PlayerVar;
}
else if(Spawn31 == 0)
{
Spawn31 = PlayerVar;
}
else if(Spawn32 == 0)
{
Spawn32 = PlayerVar;
}
else if(Spawn33 == 0)
{
Spawn33 = PlayerVar;
}
else if(Spawn34 == 0)
{
Spawn34 = PlayerVar;
}
else if(Spawn35 == 0)
{
Spawn35 = PlayerVar;
}
else if(Spawn36 == 0)
{
Spawn36 = PlayerVar;
}
else if(Spawn37 == 0)
{
Spawn37 = PlayerVar;
}
else if(PlayerInfo[playerid][pTeam] == 2)
{
SetPlayerTeam(playerid, TEAM_GROVE);
if(Spawn38 == 0)
{
Spawn38 = PlayerVar;
}
else if(Spawn39 == 0)
{
Spawn39 = PlayerVar;
}
else if(Spawn40 == 0)
{
Spawn40 = PlayerVar;
}
else if(Spawn41 == 0)
{
Spawn41 = PlayerVar;
}
else if(Spawn42 == 0)
{
Spawn42 = PlayerVar;
}
else if(Spawn43 == 0)
{
Spawn43 = PlayerVar;
}
else if(Spawn44 == 0)
{
Spawn44 = PlayerVar;
}
else if(Spawn45 == 0)
{
Spawn45 = PlayerVar;
}
else if(Spawn46 == 0)
{
Spawn46 = PlayerVar;
}
else if(Spawn47 == 0)
{
Spawn47 = PlayerVar;
}
else if(Spawn48 == 0)
{
Spawn48 = PlayerVar;
}
else if(Spawn49 == 0)
{
Spawn49 = PlayerVar;
}
else if(Spawn50 == 0)
{
Spawn50 = PlayerVar;
}
else if(Spawn51 == 0)
{
Spawn51 = PlayerVar;
}
else if(Spawn52 == 0)
{
Spawn52 = PlayerVar;
}
else if(Spawn53 == 0)
{
Spawn53 = PlayerVar;
}
else if(Spawn54 == 0)
{
Spawn54 = PlayerVar;
}
else if(Spawn55 == 0)
{
Spawn55 = PlayerVar;
}
else if(Spawn56 == 0)
{
Spawn56 = PlayerVar;
}
else if(Spawn57 == 0)
{
Spawn57 = PlayerVar;
}
else if(Spawn58 == 0)
{
Spawn58 = PlayerVar;
}
else if(Spawn59 == 0)
{
Spawn59 = PlayerVar;
}
else if(Spawn60 == 0)
{
Spawn60 = PlayerVar;
}
else if(Spawn61 == 0)
{
Spawn61 = PlayerVar;
}
else if(Spawn62 == 0)
{
Spawn62 = PlayerVar;
}
else if(Spawn63 == 0)
{
Spawn63 = PlayerVar;
}
else if(Spawn64 == 0)
{
Spawn64 = PlayerVar;
}
else if(Spawn65 == 0)
{
Spawn65 = PlayerVar;
}
else if(Spawn66 == 0)
{
Spawn66 = PlayerVar;
}
else if(Spawn67 == 0)
{
Spawn67 = PlayerVar;
}
else if(Spawn68 == 0)
{
Spawn68 = PlayerVar;
}
else if(Spawn69 == 0)
{
Spawn69 = PlayerVar;
}
else if(Spawn70 == 0)
{
Spawn70 = PlayerVar;
}
else if(Spawn71 == 0)
{
Spawn71 = PlayerVar;
}
else if(Spawn72 == 0)
{
Spawn72 = PlayerVar;
}
else if(Spawn73 == 0)
{
Spawn73 = PlayerVar;
}
else if(Spawn74 == 0)
{
Spawn74 = PlayerVar;
}
}
}
Now the spawning:
Код:
SetPlayerPos(Spawn1, 1544.4271,-1672.1821,13.5584);
SetPlayerPos(Spawn2, 1544.5597,-1678.7992,13.5586);
SetPlayerPos(Spawn3, 1544.4323,-1661.8086,13.9215);
SetPlayerPos(Spawn4, 1544.1134,-1659.4500,13.9215);
SetPlayerPos(Spawn5, 1544.4519,-1689.1775,13.9214);
SetPlayerPos(Spawn6, 1544.3990,-1691.3372,13.9214);
SetPlayerPos(Spawn7, 1539.7803,-1678.2511,13.5493);
SetPlayerPos(Spawn8, 1539.9037,-1675.4152,13.5496);
SetPlayerPos(Spawn9, 1539.7784,-1668.6803,13.5493);
SetPlayerPos(Spawn10, 1539.8792,-1663.9403,13.5495);
SetPlayerPos(Spawn11, 1534.9164,-1663.4031,13.5469);
SetPlayerPos(Spawn12, 1534.6294,-1681.5602,13.5469);
SetPlayerPos(Spawn13, 1515.6127,-1679.0426,14.0469);
SetPlayerPos(Spawn14, 1515.8558,-1673.8765,14.0469);
SetPlayerPos(Spawn15, 1512.6047,-1678.1190,14.0469);
SetPlayerPos(Spawn16, 1588.1805,-1682.9769,6.2252);
SetPlayerPos(Spawn17, 1588.5497,-1687.2325,6.2252);
SetPlayerPos(Spawn18, 1588.5371,-1690.8750,6.2188);
SetPlayerPos(Spawn19, 1583.9301,-1697.6953,6.2188);
SetPlayerPos(Spawn20, 1580.4611,-1697.8574,6.2188);
SetPlayerPos(Spawn21, 1577.4550,-1698.0767,6.2188);
SetPlayerPos(Spawn22, 1572.5621,-1715.7638,6.2188);
SetPlayerPos(Spawn23, 1576.4880,-1715.4264,6.2188);
SetPlayerPos(Spawn24, 1580.8654,-1715.1379,6.2188);
SetPlayerPos(Spawn25, 1585.4464,-1715.2522,6.2188);
SetPlayerPos(Spawn26, 1589.6041,-1715.0692,6.2188);
SetPlayerPos(Spawn27, 1593.7712,-1715.1892,6.2188);
SetPlayerPos(Spawn28, 1597.5199,-1715.4557,6.2188);
SetPlayerPos(Spawn29, 1606.8376,-1705.9949,6.2188);
SetPlayerPos(Spawn30, 1606.8228,-1697.9617,6.2188);
SetPlayerPos(Spawn31, 1560.7916,-1608.6584,13.3828);
SetPlayerPos(Spawn32, 1563.4050,-1608.9248,13.3828);
SetPlayerPos(Spawn33, 1565.7928,-1609.1696,13.3828);
SetPlayerPos(Spawn34, 1568.4969,-1609.4587,13.3828);
SetPlayerPos(Spawn35, 1567.3673,-1611.3918,13.3828);
SetPlayerPos(Spawn36, 1564.5393,-1611.8214,13.3828);
SetPlayerPos(Spawn37, 1565.5936,-1613.6688,13.3828);

SetPlayerPos(Spawn39, 2503.4358,-1692.0159,17.9575);
SetPlayerPos(Spawn40, 2505.7751,-1691.6632,17.9575);
SetPlayerPos(Spawn41, 2508.5320,-1691.5229,17.9575);
SetPlayerPos(Spawn42, 2507.8618,-1693.7950,17.9575);
SetPlayerPos(Spawn43, 2504.9846,-1693.5476,17.9575);
SetPlayerPos(Spawn44, 2503.4390,-1693.2478,17.9575);
SetPlayerPos(Spawn45, 2495.3950,-1688.5449,13.8729);
SetPlayerPos(Spawn46, 2475.1130,-1694.4684,13.5168);
SetPlayerPos(Spawn47, 2471.4751,-1694.1744,13.5150);
SetPlayerPos(Spawn48, 2473.4307,-1697.2275,13.5165);
SetPlayerPos(Spawn49, 2459.5847,-1688.4281,13.5327);
SetPlayerPos(Spawn50, 2483.0435,-1690.2512,13.5153);
SetPlayerPos(Spawn51, 2481.0688,-1689.4227,13.5171);
SetPlayerPos(Spawn52, 2510.7136,-1693.6812,17.3925);
SetPlayerPos(Spawn53, 2516.6367,-1686.7952,17.0370);
SetPlayerPos(Spawn54, 2524.8086,-1674.0641,19.9302);
SetPlayerPos(Spawn55, 2524.4307,-1676.7632,19.9302);
SetPlayerPos(Spawn56, 2524.1697,-1680.8735,19.9302);
SetPlayerPos(Spawn57, 2529.6338,-1679.5697,19.9302);
SetPlayerPos(Spawn58, 2528.9063,-1674.4556,19.9302);
SetPlayerPos(Spawn59, 2528.7664,-1677.0183,19.9302);
SetPlayerPos(Spawn60, 2495.4587,-1643.2532,17.8975);
SetPlayerPos(Spawn61, 2501.3665,-1643.9299,17.8689);
SetPlayerPos(Spawn62, 2503.2617,-1644.2281,17.2986);
SetPlayerPos(Spawn63, 2490.1990,-1647.4122,17.7592);
SetPlayerPos(Spawn64, 2486.8591,-1647.6820,17.7056);
SetPlayerPos(Spawn65, 2482.9263,-1648.7246,17.6735);
SetPlayerPos(Spawn66, 2474.4497,-1647.1976,16.8947);
SetPlayerPos(Spawn67, 2511.8408,-1651.7756,13.9018);
SetPlayerPos(Spawn68, 2506.0823,-1668.0885,13.3740);
SetPlayerPos(Spawn69, 2497.6077,-1660.6584,13.3359);
SetPlayerPos(Spawn70, 2497.5740,-1658.9886,13.3359);
SetPlayerPos(Spawn71, 2497.7715,-1657.5605,13.3670);
SetPlayerPos(Spawn72, 2483.5896,-1672.6461,13.3359);
SetPlayerPos(Spawn73, 2483.6685,-1679.2634,13.3359);
Is there an easier and less complicated way to do this?
Reply
#2

new spawnpositions[100] {
x,y,z,
x,y,z
}

SetPlayerPos(playerid, spawnpositions[playerid][0], spawnpositions[playerid][1], spawnpositions[playerid][2]);

Something like that. I can't remember it quite good how it went but it was something like this.
Reply
#3

Taken from lvdm.pwn:
pawn Код:
//top of the script
new Float:gRandomPlayerSpawns[23][3] = {
{1958.3783,1343.1572,15.3746},
{2199.6531,1393.3678,10.8203},
{2483.5977,1222.0825,10.8203},
{2637.2712,1129.2743,11.1797},
{2000.0106,1521.1111,17.0625},
{2024.8190,1917.9425,12.3386},
{2261.9048,2035.9547,10.8203},
{2262.0986,2398.6572,10.8203},
{2244.2566,2523.7280,10.8203},
{2335.3228,2786.4478,10.8203},
{2150.0186,2734.2297,11.1763},
{2158.0811,2797.5488,10.8203},
{1969.8301,2722.8564,10.8203},
{1652.0555,2709.4072,10.8265},
{1564.0052,2756.9463,10.8203},
{1271.5452,2554.0227,10.8203},
{1441.5894,2567.9099,10.8203},
{1480.6473,2213.5718,11.0234},
{1400.5906,2225.6960,11.0234},
{1598.8419,2221.5676,11.0625},
{1318.7759,1251.3580,10.8203},
{1558.0731,1007.8292,10.8125},
//{-857.0551,1536.6832,22.5870},  Out of Town Spawns
//{817.3494,856.5039,12.7891},
//{116.9315,1110.1823,13.6094},
//{-18.8529,1176.0159,19.5634},
//{-315.0575,1774.0636,43.6406},
{1705.2347,1025.6808,10.8203}
};

//somewhere in the script
new rand = random(sizeof(gRandomPlayerSpawns));
SetPlayerPos(playerid, gRandomPlayerSpawns[rand][0], gRandomPlayerSpawns[rand][1], gRandomPlayerSpawns[rand][2]); // Warp the player
Reply
#4

Quote:
Originally Posted by CrαcK
Taken from lvdm.pwn:
pawn Код:
//top of the script
new Float:gRandomPlayerSpawns[23][3] = {
{1958.3783,1343.1572,15.3746},
{2199.6531,1393.3678,10.8203},
{2483.5977,1222.0825,10.8203},
{2637.2712,1129.2743,11.1797},
{2000.0106,1521.1111,17.0625},
{2024.8190,1917.9425,12.3386},
{2261.9048,2035.9547,10.8203},
{2262.0986,2398.6572,10.8203},
{2244.2566,2523.7280,10.8203},
{2335.3228,2786.4478,10.8203},
{2150.0186,2734.2297,11.1763},
{2158.0811,2797.5488,10.8203},
{1969.8301,2722.8564,10.8203},
{1652.0555,2709.4072,10.8265},
{1564.0052,2756.9463,10.8203},
{1271.5452,2554.0227,10.8203},
{1441.5894,2567.9099,10.8203},
{1480.6473,2213.5718,11.0234},
{1400.5906,2225.6960,11.0234},
{1598.8419,2221.5676,11.0625},
{1318.7759,1251.3580,10.8203},
{1558.0731,1007.8292,10.8125},
//{-857.0551,1536.6832,22.5870},  Out of Town Spawns
//{817.3494,856.5039,12.7891},
//{116.9315,1110.1823,13.6094},
//{-18.8529,1176.0159,19.5634},
//{-315.0575,1774.0636,43.6406},
{1705.2347,1025.6808,10.8203}
};

//somewhere in the script
new rand = random(sizeof(gRandomPlayerSpawns));
SetPlayerPos(playerid, gRandomPlayerSpawns[rand][0], gRandomPlayerSpawns[rand][1], gRandomPlayerSpawns[rand][2]); // Warp the player
Won't that spawn some people in the same poistion as others?
Reply
#5

Quote:
Originally Posted by Paladin
Quote:
Originally Posted by CrαcK
Taken from lvdm.pwn:
pawn Код:
//top of the script
new Float:gRandomPlayerSpawns[23][3] = {
{1958.3783,1343.1572,15.3746},
{2199.6531,1393.3678,10.8203},
{2483.5977,1222.0825,10.8203},
{2637.2712,1129.2743,11.1797},
{2000.0106,1521.1111,17.0625},
{2024.8190,1917.9425,12.3386},
{2261.9048,2035.9547,10.8203},
{2262.0986,2398.6572,10.8203},
{2244.2566,2523.7280,10.8203},
{2335.3228,2786.4478,10.8203},
{2150.0186,2734.2297,11.1763},
{2158.0811,2797.5488,10.8203},
{1969.8301,2722.8564,10.8203},
{1652.0555,2709.4072,10.8265},
{1564.0052,2756.9463,10.8203},
{1271.5452,2554.0227,10.8203},
{1441.5894,2567.9099,10.8203},
{1480.6473,2213.5718,11.0234},
{1400.5906,2225.6960,11.0234},
{1598.8419,2221.5676,11.0625},
{1318.7759,1251.3580,10.8203},
{1558.0731,1007.8292,10.8125},
//{-857.0551,1536.6832,22.5870}, Out of Town Spawns
//{817.3494,856.5039,12.7891},
//{116.9315,1110.1823,13.6094},
//{-18.8529,1176.0159,19.5634},
//{-315.0575,1774.0636,43.6406},
{1705.2347,1025.6808,10.8203}
};

//somewhere in the script
new rand = random(sizeof(gRandomPlayerSpawns));
SetPlayerPos(playerid, gRandomPlayerSpawns[rand][0], gRandomPlayerSpawns[rand][1], gRandomPlayerSpawns[rand][2]); // Warp the player
Won't that spawn some people in the same poistion as others?
yes. though if you change the script a little to what I mentioned, you wont have a problem
Reply
#6

Quote:
Originally Posted by [NT
mamoru ]
Quote:
Originally Posted by Paladin
Quote:
Originally Posted by CrαcK
Taken from lvdm.pwn:
pawn Код:
//top of the script
new Float:gRandomPlayerSpawns[23][3] = {
(CO-ORDINATES)
}

//somewhere in the script
new rand = random(sizeof(gRandomPlayerSpawns));
SetPlayerPos(playerid, gRandomPlayerSpawns[rand][0], gRandomPlayerSpawns[rand][1], gRandomPlayerSpawns[rand][2]); // Warp the player
Won't that spawn some people in the same poistion as others?
yes. though if you change the script a little to what I mentioned, you wont have a problem
can you explain more in depth what you mean in it then.
Reply
#7

Well, instead of random spawn:
pawn Код:
SetPlayerPos(playerid, gRandomPlayerSpawns[playerid][0], gRandomPlayerSpawns[playerid][1], gRandomPlayerSpawns[playerid][2]);
Reply
#8

Quote:
Originally Posted by CrαcK
Well, instead of random spawn:
pawn Код:
SetPlayerPos(playerid, gRandomPlayerSpawns[playerid][0], gRandomPlayerSpawns[playerid][1], gRandomPlayerSpawns[playerid][2]);
you're missing the point, it's not about the spawn, it's about the server remembering who that player is, thats why I had all those "Spawn#" variables.
Reply
#9

pawn Код:
new spawn[74];

new PlayerVar = playerid;
if(PlayerInfo[playerid][pTeam] == 1)
{
  for(new i; i< 37; i++)
  {
   if(!spawn[i])
   {
     spawn[i] = PlayerVar;
     break;
   }
  }
}
else if(PlayerInfo[playerid][pTeam] == 2)
{
  SetPlayerTeam(playerid, TEAM_GROVE);
  for(new j=37; j< 74; j++)
  {
   if(!spawn[j])
   {
     spawn[j] = PlayerVar;
     break;
   }
  }
}
And finally put all your coords for spawn in an array like the one some posts above, and do:
pawn Код:
SetPlayerPos(spawn[playerid],array[spawn[playerid]][0],array[spawn[playerid]][1],array[spawn[playerid]][2]);
Reply
#10

Quote:
Originally Posted by CrαcK
pawn Код:
new spawn[74];

new PlayerVar = playerid;
if(PlayerInfo[playerid][pTeam] == 1)
{
  for(new i; i< 37; i++)
  {
   if(!spawn[i])
   {
     spawn[i] = PlayerVar;
     break;
   }
  }
}
else if(PlayerInfo[playerid][pTeam] == 2)
{
  SetPlayerTeam(playerid, TEAM_GROVE);
  for(new j=37; j< 74; j++)
  {
   if(!spawn[j])
   {
     spawn[j] = PlayerVar;
     break;
   }
  }
}
And finally put all your coords for spawn in an array like the one some posts above, and do:
pawn Код:
SetPlayerPos(spawn[playerid],array[spawn[playerid]][0],array[spawn[playerid]][1],array[spawn[playerid]][2]);
You are awesome
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)