Automatic re-spec?
#1

Код:
new String[128], Float:SpecX[MAX_PLAYERS], Float:SpecY[MAX_PLAYERS], Float:SpecZ[MAX_PLAYERS], vWorld[MAX_PLAYERS], Inter[MAX_PLAYERS];
new IsSpecing[MAX_PLAYERS], Name[MAX_PLAYER_NAME], IsBeingSpeced[MAX_PLAYERS],spectatorid[MAX_PLAYERS];

if(IsSpecing[playerid] == 1)
{
        SetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);
	SetPlayerInterior(playerid,Inter[playerid]);
	SetPlayerVirtualWorld(playerid,vWorld[playerid]);		
        IsSpecing[playerid] = 0;
	IsBeingSpeced[spectatorid[playerid]] = 0;
}

public OnPlayerDisconnect(playerid, reason)
{
	if(IsBeingSpeced[playerid] == 1)
	{
	    foreach(Player,i)
	    {
	    	if(spectatorid[i] == playerid)
			{
				TogglePlayerSpectating(i,false);// This justifies what's above, if it's not off then you'll be either spectating your connect screen, or somewhere in blueberry (I don't know why)
			}
		}
	}
	return 1;
}

COMMAND:spec(playerid, params[])
{
	new id;
	if(pInfo[playerid][Adminlevel] == 0)return 0;
	if(sscanf(params,"u", id))return SendClientMessage(playerid, Grey, "Usage: /spec [id]");
	if(id == playerid)return SendClientMessage(playerid,Grey,"You cannot spec yourself.");
	if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, Grey, "Player not found!");
	if(IsSpecing[playerid] == 1)return SendClientMessage(playerid,Grey,"You are already specing someone.");
	GetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);
	Inter[playerid] = GetPlayerInterior(playerid);
	vWorld[playerid] = GetPlayerVirtualWorld(playerid);
	TogglePlayerSpectating(playerid, true);
	if(IsPlayerInAnyVehicle(id))
	{
	    if(GetPlayerInterior(id) > 0)
	    {
			SetPlayerInterior(playerid,GetPlayerInterior(id));
		}
		if(GetPlayerVirtualWorld(id) > 0)
		{
		    SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));
		}
	    PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));
	}
	else
	{
	    if(GetPlayerInterior(id) > 0)
	    {
			SetPlayerInterior(playerid,GetPlayerInterior(id));
		}
		if(GetPlayerVirtualWorld(id) > 0)
		{
		    SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));
		}
	    PlayerSpectatePlayer(playerid,id);
	}
	GetPlayerName(id, Name, sizeof(Name));
	format(String, sizeof(String),"You have started to spectate %s.",Name);
	SendClientMessage(playerid,0x0080C0FF,String);
	IsSpecing[playerid] = 1;
	IsBeingSpeced[id] = 1;
	spectatorid[playerid] = id;
 	return 1;
}

COMMAND:specoff(playerid, params[])
{
	if(pInfo[playerid][Adminlevel] == 0)return 0;
	if(IsSpecing[playerid] == 0)return SendClientMessage(playerid,Grey,"You are not spectating anyone.");
	TogglePlayerSpectating(playerid, 0);
	return 1;
}

How could I make an admin automatically re-spectate a player when they respawn? I asked this question once before and I didn't get a proper answer as to how to pull it off. A lot of my server admins are complaining about this lately, and after trying to fix it on my own a few times I cannot seem to figure out the proper method to do this.
Reply
#2

I can explain it in a simple way.
Make a universay player id , where you used new id; make it universal for SPEC CMD.

On player Death again set the admin spectate to 1 by a timer of 10seconds ( Maybe less, 10 is good for the player to get spawn , lag depends ) and as soon as the player respawns the admin specs him again.
Reply
#3

OnPlayerSpawn

foreach(Player,i)
{
if(spectatorid[playerid] == i)
{
PlayerSpectatePlayer(i,playerid);
}
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)