Prevent Spawning -
Wesley221 - 20.06.2011
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;
}
Re: Prevent Spawning -
Alvord - 20.06.2011
I'm just wondering why your MaxTeamCount is 0?
Re: Prevent Spawning -
Wesley221 - 20.06.2011
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
Re: Prevent Spawning -
Alvord - 20.06.2011
I see...
Have you used SpawnPlayer() in other parts of the script?
Re: Prevent Spawning -
Wesley221 - 20.06.2011
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;
}
Re: Prevent Spawning -
Steven82 - 20.06.2011
Maybe try putting this on, OnPlayerRequestSpawn?
Re: Prevent Spawning -
Wesley221 - 20.06.2011
Check my edit
Re: Prevent Spawning -
Wesley221 - 20.06.2011
Bump, what could be the problem?
Re: Prevent Spawning -
=WoR=Varth - 20.06.2011
PlayerSpectatePlayer?
Or maybe spawn them in sky and freeze them. Then SetPlayerCameraPos.
Re: Prevent Spawning -
Wesley221 - 21.06.2011
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