Small Issue
#1

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.
Reply
#2

try this...

Quote:

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

Reply
#3

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.
Reply
#4

Try removing SetPlayerTeam?
Reply
#5

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?
Reply
#6

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;
        }
    }
}
Reply
#7

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...
Reply
#8

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

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)