Spectating doesn't work
#1

When everyone is dead in 1 team, it should spec the enemy's.
My problem is: It doesn't spec, but it makes anyone respawn. While they shouldn't. :S

pawn Код:
stock GetRandomTeamPlayerForPlayer(playerid)
{
    new rand = -1;
    new team = mTeam[playerid];
    new Float:health;
    while(rand == -1)
    {
        rand = random(MAX_PLAYERS);
        if(!IsPlayerConnected(rand)) rand = -1;
        if(TeamCounting[team] != 0 && team == mTeam[rand]) rand = -1;
        GetPlayerHealth(rand, health);
        if(health <= 0) rand = -1;
    }
    return rand;
}
pawn Код:
//onplayerdeath
GoSpec = GetRandomTeamPlayerForPlayer(playerid);
    TogglePlayerSpectating(playerid,1);
    PlayerSpectatePlayer(playerid,GoSpec);
Reply
#2

Код:
dcmd_lspec(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 2 || IsPlayerAdmin(playerid))
	{
		if(AccInfo[playerid][pGps] != -1)
		return SendClientMessage(playerid, red, "ERROR: First Disable the Gps System! (/gps off)");
		
	    if(!strlen(params) || !IsNumeric(params)) return
		SendClientMessage(playerid, LIGHTBLUE2, "Usage: /lspec [PlayerID]") &&
		SendClientMessage(playerid, orange, "Function: Will spec a specified Player");
		
		new specplayerid = ReturnUser(params);
		if(AccInfo[specplayerid][Level] == ServerInfo[MaxAdminLevel] && AccInfo[playerid][Level] != ServerInfo[MaxAdminLevel])
		return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
		
        if(IsPlayerConnected(specplayerid) && specplayerid != INVALID_PLAYER_ID)
		{
			if(specplayerid == playerid)
			return SendClientMessage(playerid, red, "ERROR: You cannot spectate Yourself");
			
			if(GetPlayerState(specplayerid) == PLAYER_STATE_SPECTATING && AccInfo[specplayerid][SpecID] != INVALID_PLAYER_ID)
			return SendClientMessage(playerid, red, "ERROR: Player spectating someone else");
			
			if(GetPlayerState(specplayerid) != 1 && GetPlayerState(specplayerid) != 2 && GetPlayerState(specplayerid) != 3)
			return SendClientMessage(playerid, red, "ERROR: Player not Spawned");
			
			if((AccInfo[specplayerid][Level] != ServerInfo[MaxAdminLevel]) || (AccInfo[specplayerid][Level] == ServerInfo[MaxAdminLevel] && AccInfo[playerid][Level] == ServerInfo[MaxAdminLevel]))
			{
				GetPlayerPos(playerid,Pos[playerid][0],Pos[playerid][1],Pos[playerid][2]);
				GetPlayerFacingAngle(playerid,Pos[playerid][3]);
				SendCommandToAdmins(playerid,"LSpec");
				SendClientMessage(playerid,blue,"|- Spectating On -|");
			 	return StartSpectate(playerid, specplayerid);
			}
			else return SendClientMessage(playerid,red,"ERROR: You cannot spectate the highest level admin");
		}
		else return ErrorMessages(playerid, 2);
	}
	else return ErrorMessages(playerid, 7);
}
Reply
#3

Basically, he's searching for a function that spectates a random team player, and if all his team players are dead then to spectate the enemy team, not a spectate command from world's worst admin system.
Reply
#4

^ Correct
Reply
#5

Bumpy :P
Reply
#6

offtopic: I dont think its hard to spectate team players ondeath but its alot harder to spectate enemy team members when all team players are dead.. and btw wouldnt the other team win when all team players are dead?
like deathmatch....

edit: sorry only read hiddos's post :P
Reply
#7

Yes they will. but there is a little time before restarting. like 15 seconds so they gotta spec them.

hope anyone has solutions
Reply
#8

Anybody?
Reply
#9

Try use your GetRandomTeamPlayerForPlayer(playerid) to also trigger spectating

What I would do is use the for function and check for the first available enemy team that is not being spectated and set the dead player to spectate them.

Код:
// Example: EXCUSE INDENTATION
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if([CHECK FOR ENEMY VARIABLE])
{
if([CHECK FOR BEING SPECTATED VARIABLE])
{
[SET ENEMY BEING SPECTATED VARIABLE TO 1]
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, i);
return 1;
}
}
}
}
That's what I would do at least...
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)