SA-MP Forums Archive
This small code makes the client instanly close connection? - 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)
+--- Thread: This small code makes the client instanly close connection? (/showthread.php?tid=636822)



This small code makes the client instanly close connection? - Meller - 04.07.2017

This video shows the issue: --

This little code is making the client close the connection?
PHP Code:
case DIALOG_PLAY: {
            if(
response) {
                switch(
listitem) {
                    case 
0: { // Competitive
                        
Player[playerid][pStatus]    = STATUS_COMP;
                        
Player[playerid][pDead]     = true;
                        
                        for(new 
id 0id 19id++)
                            
PlayerTextDrawDestroy(playeridHomeMenuTextdraws[playerid][id]);
                        for(new 
id 0id 10id++)
                            
PlayerTextDrawDestroy(playeridMenuTextdraws[playerid][id]);
                        
CancelSelectTextDraw(playerid);
                        
                        
Player[playerid][pTeam]     = GetCompTeam();
                        
                        if(
IsCompWarmup()) {
                            
SendClientMessage(playerid0xD7D7D7FF"WARMUP: The competitive requires atleast 2 players, so far there'll be a warmup.");
                            
                            
Player[playerid][pDead]     = false;
                            
TogglePlayerSpectating(playeridfalse);
                            
SendClientMessage(playerid0xD7D7D7FF"MAP: The current map is de_dust2 made by JamesT85.");
                            
TogglePlayerControllable(playeridfalse);
                            if(
Player[playerid][pTeam] == TEAM_CT)
                                
SetPlayerPos(playerid, -717.6069332577.695800241.739685);
                            
SetTimerEx("UnfreezePlayer"2000false"i"playerid);
                        }
                    }
                    case 
1: { // Shooting Range
                    
                      
}
                      case 
2: { // Missions
                    
}
                    case 
3: { // Dueling
                    
                    
}
                  }
            }
            else
                
SelectTextDraw(playerid, -673720321);
        } 



Re: This small code makes the client instanly close connection? - Meller - 04.07.2017

After some debugment, this is the line that shuts the clients connection.
TogglePlayerSpectating(playerid, false);


Re: This small code makes the client instanly close connection? - Meller - 04.07.2017

Fixed by forcing the player to spawn before letting him load in.