SA-MP Forums Archive
Small Issue - 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: Small Issue (/showthread.php?tid=559364)



Small Issue - iFiras - 22.01.2015

So basically, I've been facing a problem, it's when I turn off the spectating mode, the server closes the connection. Let me describe what I wanted to do.
I wanted to disable the class selection (spawn buttons) and put a dialog instead.
After the player's logged in to the server, it puts him/her in the spectating mode and when the player attempts to spawn (using the dialog I made), the server closes the connection.

Code:
pawn Code:
if(dialogid == DIALOG_SELECT)
{
    if(!response)
    {
        KickPlayer(playerid,500);
    }
    else
    {
        if(listitem == 0)
        {
            TogglePlayerSpectating(playerid, false); // At this point, the server closes the connection.
            SetPlayerTeam(playerid, 0);
        }
    }
}
I don't know if you understood what I mean but I hope you did.


Re: Small Issue - Riso135 - 22.01.2015

try this...

Quote:

if(dialogid == DIALOG_SELECT)
{
if(response)
{
if(listitem == 0)
{
TogglePlayerSpectating(playerid, false);
SetPlayerTeam(playerid, 0);
}
}
else if(!response)
{
KickPlayer(playerid,500);
}
}




Re: Small Issue - iFiras - 23.01.2015

Quote:
Originally Posted by Riso135
View Post
try this...
Same thing, doesn't work.
I just noticed that the server closes the connection by itself, I removed that "KickPlayer" function and tried again and the same thing just keeps happening, must be a SA-MP bug.


Re: Small Issue - Runn3R - 23.01.2015

Try removing SetPlayerTeam?


Re: Small Issue - iFiras - 23.01.2015

Quote:
Originally Posted by Runn3R
View Post
Try removing SetPlayerTeam?
Same thing.
I added SpawnPlayer(playerid);.
Code:
pawn Code:
if(dialogid == DIALOG_SELECT)
{
    if(!response)
    {
        KickPlayer(playerid,500);
    }
    else
    {
        if(listitem == 0)
        {
            SpawnPlayer(playerid);
            TogglePlayerSpectating(playerid, false);
            SetPlayerTeam(playerid, 0);
        }
    }
}
It worked though but OnPlayerSpawn gets called twice and I kinda dislike that because messages get sent again and that would cause spam.
Is there any other way I can do this?


Re: Small Issue - Ciarannn - 23.01.2015

I don't know if this will make a difference, but you may as well try it:

pawn Code:
if(dialogid == DIALOG_SELECT)
{
    if(!response) return KickPlayer(playerid,500);
    if(reponse)
    {
        if(listitem == 0)
        {
            SpawnPlayer(playerid);
            TogglePlayerSpectating(playerid, false);
            SetPlayerTeam(playerid, 0);
            return 1;
        }
    }
}



Re: Small Issue - iFiras - 24.01.2015

Quote:
Originally Posted by Ciarannn
View Post
I don't know if this will make a difference, but you may as well try it:

pawn Code:
if(dialogid == DIALOG_SELECT)
{
    if(!response) return KickPlayer(playerid,500);
    if(reponse)
    {
        if(listitem == 0)
        {
            SpawnPlayer(playerid);
            TogglePlayerSpectating(playerid, false);
            SetPlayerTeam(playerid, 0);
            return 1;
        }
    }
}
Does not work...


Re: Small Issue - Ciarannn - 24.01.2015

Quote:
Originally Posted by iFiras
View Post
Does not work...
I misspelt response in the if(response), try again after fixing it.


Re: Small Issue - iFiras - 24.01.2015

Quote:
Originally Posted by Ciarannn
View Post
I misspelt response in the if(response), try again after fixing it.
I already did, I've noticed that already.
What I don't understand is that the server closes the connection after turning the spectating mode off.
Did someone else encounter this before?