Prevent Spawning
#1

Hey guys,

I got a problem with spawning.
I'm trying to prevent a player from spawning, is the teamcount equals to the maxteamcount.
Note from wiki: "Returning 0 in this callback will prevent the player from spawning. The player can be forced to spawn when SpawnPlayer is used however the player will re-enter class selection the next time they die."
I've made it return 0 if the teamcount equals to maxteamcount, but they're still able to spawn
What to do?

pawn Код:
#define MaxTeamCount 0

OnGameModeInit
TeamCount = 0;

public OnPlayerRequestClass(playerid, classid)
{
    switch(classid)
    {
        case 0 .. 5:
        {
            if(TeamCount == MaxTeamCount)
            {
                GameTextForPlayer(playerid, "~r~Team is full~y~!", 1000, 3);
                SetPlayerInterior(playerid, 0);
                SetPlayerCameraPos(playerid, 1306.2509, 2194.7842, 12.3751); SetPlayerCameraLookAt(playerid, 1305.3710, 2195.2520, 12.0651);
                SetPlayerPos(playerid,1303.5723,2197.1284,11.0234); SetPlayerFacingAngle(playerid, 217.7654);
                return 0; // This should prevent the spawn
            }
            else
            {
                SetPlayerTeamFromClass(playerid, classid); SetPlayerPos(playerid,1303.5723,2197.1284,11.0234); SetPlayerFacingAngle(playerid, 217.7654);
                SetPlayerCameraPos(playerid, 1306.2509, 2194.7842, 12.3751); SetPlayerCameraLookAt(playerid, 1305.3710, 2195.2520, 12.0651); SetPlayerInterior(playerid, 0);
                return 1; // This will make the player spawn
            }
        }
    }
    return 1;
}
Reply
#2

I'm just wondering why your MaxTeamCount is 0?
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
Are there any return 1s in other scripts?
Nope, its a single GM with no FS's

Quote:
Originally Posted by Alvord
Посмотреть сообщение
I'm just wondering why your MaxTeamCount is 0?
Because i just started making it, and no-one was able to help. So changed it to 0, so i know the team was full for sure (to test the prevent-spawn)

Edit: Im gonna try to return the callback to 0, give me a minute
Another edit: Returning the callback to 0 doesnt make any changes
Reply
#4

I see...

Have you used SpawnPlayer() in other parts of the script?
Reply
#5

Nope, just the onplayerspawn teamcount, the requestclass and SetPlayerTeamFromClass

Edit:
I just used OnPlayerRequestSpawn, and it kinda works. Just now i got a problem.
When i try to spawn with the class, it suceeds, and it says "Team is full"
But now i made a different team, with the same codes, but now the MaxPlayers of that team is 10
No one joined that team, and when i try to spawn as that team, it says "Team is full".

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(Team1Count > MAXTEAM1)
    {
        GameTextForPlayer(playerid, "~r~Team is full~y~!", 1000, 3);
        return 0;
    }
    if(Team2Count > MAXTEAM2)
    {
        GameTextForPlayer(playerid, "~r~Team is full~y~!", 1000, 3);
        return 0;
    }
    if(Team1Count < MAXTEAM1)
    {
        return 1;
    }
    if(Team2Count < MAXTEAM2)
    {
        return 1;
    }
    return 1;
}
Reply
#6

Maybe try putting this on, OnPlayerRequestSpawn?
Reply
#7

Check my edit
Reply
#8

Bump, what could be the problem?
Reply
#9

PlayerSpectatePlayer?
Or maybe spawn them in sky and freeze them. Then SetPlayerCameraPos.
Reply
#10

No no, if the teamcount equals to the maxteamcount, it needs to stop spawning you.. I've seen it somewhere else before, but don't know what the problem is
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)