TogglePlayerSpectating bug (KICK PLAYERS!)
#1

Ok when you use TogglePlayerSpectating(playerid, false); OnPlayerSpawn is called, up there all right.

When you use TogglePlayerSpectating(playerid, true); in OnPlayerRequestClass and subsequently you use TogglePlayerSpectating(playerid, false); kick player only if it is the first time the player enter the server, if OnPlayerRequestClass is called by F4 reason no kick player.

Ok, sorry my bad english.

pawn Код:
new ads;

public OnPlayerConnect(playerid)
{
    ads = 1;
    //GameTextForPlayer(playerid,"~w~SA-MP: ~r~Bare Script",5000,5);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    if(ads == 1)
    {
        TogglePlayerSpectating(playerid, true);
        SetTimer("asdj", 1000, 0);
    }
    return 1;
}

forward asdj();
public asdj()
{
    ads = 0;
//Here kick player and OnPlayerSpawn/OnPlayerRequestClass is not called, only kick the player.
    TogglePlayerSpectating(0, false);
   
}
But if you put SpawnPlayer(playerid) below TogglePlayerSpectating(playerid, false), player hasn't kicked but OnPlayerSpawn is called twice.

pawn Код:
forward asdj();
public asdj()
{
    ads = 0;
//Here no kicks but OnPlayerSpawn is called twice.
    TogglePlayerSpectating(0, false);
SpawnPlayer(0);
   
}

By F4 no kick:
pawn Код:
public OnPlayerSpawn(playerid)
{
    ads = 1;
    SetPlayerPos(playerid, 324.7515, -1829.8098, 4.3855);
    SetPlayerInterior(playerid,0);
    TogglePlayerClock(playerid,0);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    if(ads == 1)
    {
        TogglePlayerSpectating(playerid, true);
        SetTimer("asdj", 1000, 0);
    }
   
    return 1;
}
forward asdj();
public asdj()
{
    ads = 0;
//no kick player
    TogglePlayerSpectating(0, false);
   
}
Sorry for my bad english.

I do not know if is a bug or script problem, but using this no kick (Onplayerspawn called twice)
TogglePlayerSpectating(0, false);
SpawnPlayer(0);
Reply
#2

It's a bug, you have to use SetSpawnInfo before TogglePlayerSpectating(0, false);
Reply
#3

Redirect_Left told me about this the other day, it is indeed a bug.

When you call TogglePlayerSpectating(...,false), it spawns the player. If you do this before the player has entered class selection, and before any spawn info has been set, the server doesn't know where to spawn the player (or what skin to apply, etc.), so it kicks them. It's probably to prevent against some sort of cheat.

If you want to spawn the player, the solution is to use SetSpawnInfo before TogglePlayerSpectating. If you want to return the player to class selection, use ForceClassSelection instead.
Reply
#4

If you are un-sure about big I and small l you could just compare them. They look really similar but small l is a little bit taller.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)