SA-MP Forums Archive
Spectating doesn't work - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Spectating doesn't work (/showthread.php?tid=171714)



Spectating doesn't work - LifeStyle - 27.08.2010

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



Re: Spectating doesn't work - Mean - 27.08.2010

Код:
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);
}



Re: Spectating doesn't work - Hiddos - 27.08.2010

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.


Re: Spectating doesn't work - LifeStyle - 27.08.2010

^ Correct


Re: Spectating doesn't work - LifeStyle - 28.08.2010

Bumpy :P


Re: Spectating doesn't work - Mike_Peterson - 28.08.2010

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


Re: Spectating doesn't work - LifeStyle - 28.08.2010

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

hope anyone has solutions


Re: Spectating doesn't work - LifeStyle - 29.08.2010

Anybody?


Re: Spectating doesn't work - Paladin - 29.08.2010

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