Spawn player problems.
#1

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.
PHP код:
(under OnGamemodeInit)
    for (new 
i=0i<310i++)
    {
        if (
i>= 0)
        
AddPlayerClass(i1958.37831343.157215.3746269.1425000000);
     } 
PHP код:
new MapChange;
forward StartedNewRound();
forward NewMapTimer(playerid);
new 
Float:SpawnLVA[][]=
    {
        {
1651.17951543.308114.63340.0000},
        {
1623.37181536.687214.63340.0000},
        {
1635.28941581.709114.6334270.0000},
        {
1591.59161624.082714.6334180.0000},
        {
1701.49811673.077114.6334180.0000},
        {
1701.49811577.736614.633490.0000},
        {
1718.71241634.676114.63340.0000}
    };
    
new 
Float:SpawnWESTLV[][] =
    {
        {
1059.41841081.0885,10.1808 ,270.0000 },
        {
1092.52281107.5720,10.1808 ,180.0000 },
        {
1122.97881069.1709,10.1808 ,90.0000 },
        {
1085.90191040.0391,10.1808 ,0.0000 },
        {
1091.19861073.1435,10.8359 ,0.0000 },
        {
1122.97881100.9511,10.1808 ,180.0000 },
        {
1064.71511103.5995,10.1808 ,180.0000 }
    };
    
public 
OnPlayerSpawn(playerid)
{
GivePlayerWeapon(playerid,24,300); //DEAGLE
GivePlayerWeapon(playerid,25,300); //SHOTGUN
GivePlayerWeapon(playerid,34,300); //SNIPER
SetPlayerArmour(playerid100);
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(playeridSpawnLVA[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(playerid1);
        }
        case 
1:                                   // MapChange2 same settings on top
        
{
            new 
rand random(sizeof(SpawnWESTLV));
            
SetPlayerPos(playeridSpawnWESTLV[rand][0],SpawnWESTLV[rand][1],SpawnWESTLV[rand][2]);        // XYZ Co-rds of the first map
            
SetPlayerFacingAngle(playerid,SpawnWESTLV[rand][3]);
            
TogglePlayerControllable(playerid1);
            
            
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..."40006);
    
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 
0MAX_PLAYERSi++)
    {        
// 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;

I've been trying to fix this but I can't work around it, if anyone could help I will be grateful.
Reply


Messages In This Thread
Spawn player problems. - by Lofti - 26.07.2015, 23:46
Re: Spawn player problems. - by TwinkiDaBoss - 27.07.2015, 00:25
Re: Spawn player problems. - by Jefff - 27.07.2015, 01:12
Re: Spawn player problems. - by Lofti - 27.07.2015, 19:06
AW: Spawn player problems. - by Mencent - 27.07.2015, 19:11
Re: AW: Spawn player problems. - by Lofti - 27.07.2015, 19:18
AW: Spawn player problems. - by Mencent - 27.07.2015, 19:21

Forum Jump:


Users browsing this thread: 2 Guest(s)