26.07.2015, 23:46
(
Последний раз редактировалось Lofti; 27.07.2015 в 19:09.
)
o/,
Here is a code I wrote which switches spawn locations every round:
The first round, players spawn randomly at LV Airport normally.
However, in the second round instead of spawning at WEST LV they all spawn at the default location (on LV Strip in the building in front of the Pyramid near the escalators which are the coordinates for my skin but 1 player spawns normally at WEST LV...
On the third round when the spawn location is set back to LV Airport all players spawn normally at LV Airport.
I've been trying to fix this but I can't work around it, if anyone could help I will be grateful.
Here is a code I wrote which switches spawn locations every round:
The first round, players spawn randomly at LV Airport normally.
However, in the second round instead of spawning at WEST LV they all spawn at the default location (on LV Strip in the building in front of the Pyramid near the escalators which are the coordinates for my skin but 1 player spawns normally at WEST LV...
On the third round when the spawn location is set back to LV Airport all players spawn normally at LV Airport.
PHP код:
(under OnGamemodeInit)
for (new i=0; i<310; i++)
{
if (i>= 0)
AddPlayerClass(i, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
}
PHP код:
new MapChange;
forward StartedNewRound();
forward NewMapTimer(playerid);
new Float:SpawnLVA[][]=
{
{1651.1795, 1543.3081, 14.6334, 0.0000},
{1623.3718, 1536.6872, 14.6334, 0.0000},
{1635.2894, 1581.7091, 14.6334, 270.0000},
{1591.5916, 1624.0827, 14.6334, 180.0000},
{1701.4981, 1673.0771, 14.6334, 180.0000},
{1701.4981, 1577.7366, 14.6334, 90.0000},
{1718.7124, 1634.6761, 14.6334, 0.0000}
};
new Float:SpawnWESTLV[][] =
{
{1059.4184, 1081.0885,10.1808 ,270.0000 },
{1092.5228, 1107.5720,10.1808 ,180.0000 },
{1122.9788, 1069.1709,10.1808 ,90.0000 },
{1085.9019, 1040.0391,10.1808 ,0.0000 },
{1091.1986, 1073.1435,10.8359 ,0.0000 },
{1122.9788, 1100.9511,10.1808 ,180.0000 },
{1064.7151, 1103.5995,10.1808 ,180.0000 }
};
public OnPlayerSpawn(playerid)
{
GivePlayerWeapon(playerid,24,300); //DEAGLE
GivePlayerWeapon(playerid,25,300); //SHOTGUN
GivePlayerWeapon(playerid,34,300); //SNIPER
SetPlayerArmour(playerid, 100);
TextDrawShowForPlayer(playerid, FINAL);
switch (MapChange)
{ // you must have a case for the mapchange to get the list going
case 0: // MapChange1 this is the part for MapChange = 0; Which basically starts of the first MapChangein the list
{
new rand = random(sizeof(SpawnLVA));
SetPlayerPos(playerid, SpawnLVA[rand][0],SpawnLVA[rand][1],SpawnLVA[rand][2]); // XYZ Co-rds of the first map
SetPlayerFacingAngle(playerid,SpawnLVA[rand][3]); // Facing Angle of the first map
TogglePlayerControllable(playerid, 1);
}
case 1: // MapChange2 same settings on top
{
new rand = random(sizeof(SpawnWESTLV));
SetPlayerPos(playerid, SpawnWESTLV[rand][0],SpawnWESTLV[rand][1],SpawnWESTLV[rand][2]); // XYZ Co-rds of the first map
SetPlayerFacingAngle(playerid,SpawnWESTLV[rand][3]);
TogglePlayerControllable(playerid, 1);
MapChange =-1;
}
}
return 1;
}
public NewMapTimer(playerid) // The function we forwarded on the beginning of the tutorial
{
MapChange++; // this makes it to go to the second MapChange++ part basically does it
roundstats[playerid][rKills]=0;
roundstats[playerid][rDeaths]=0;
GameTextForPlayer(playerid, "~r~Switching maps, wait...", 4000, 6);
SetTimer("StartedNewRound",8000,false); // Starts a new timer for the MapChangechange 4 seconds this basically starts the new MapChangeand always must be in false
return 1;
}
forward StartedNewRound();
public StartedNewRound() // The callback we forwarded in the beginning of this tutorial
{
for(new i = 0; i < MAX_PLAYERS; i++)
{ // this loops everyone in the server also you can use foreach include for this part
SpawnPlayer(i); // Re Spawns everyone in the server which then gets OnPlayerSpawn Callback called
}
return 1;
}