PDA

View Full Version : Small Issue


iFiras
22/01/2015, 07:47 PM
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:
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.

Riso135
22/01/2015, 08:29 PM
try this...

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

iFiras
23/01/2015, 11:34 AM
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.

Runn3R
23/01/2015, 11:38 AM
Try removing SetPlayerTeam?

iFiras
23/01/2015, 12:03 PM
Try removing SetPlayerTeam?
Same thing.
I added SpawnPlayer(playerid);.
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?

Ciarannn
23/01/2015, 12:30 PM
I don't know if this will make a difference, but you may as well try it:

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

iFiras
24/01/2015, 04:04 PM
I don't know if this will make a difference, but you may as well try it:

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...

Ciarannn
24/01/2015, 06:29 PM
Does not work...

I misspelt response in the if(response), try again after fixing it.

iFiras
24/01/2015, 06:42 PM
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?