First of all, this Function is made by Stormeus( I got from public beta Script). I just extracted this function from the script. So I thought posting it here. Hope it might be useful for others :)
====Installation====
http://s14.postimg.org/u1skhm2q5/hint_spectate.png
http://s14.postimg.org/cagy35nbh/hint_specmenu.png
Put the hint_spectate.png and hint_specmenu.png in /store/sprites folder
///Official Events///
Global Variables:-
BIND_SPEC_TOGGLE <- null;
BIND_SPEC_NEXT <- null;
BIND_SPEC_PREV <- null;
SPRITE_SPECHINT <- null;
SPRITE_SPECTATEMENU <- null;
function onScriptLoad()
{
SPRITE_SPECHINT = CreateSprite("hint_spectate.png", -150, -384, 0, 0, 0, 255);
SPRITE_SPECTATEMENU = CreateSprite("hint_specmenu.png", -220, -384, 0, 0, 0, 255);
BIND_SPEC_TOGGLE = BindKey( true, 0x53, 0, 0 );
BIND_SPEC_NEXT = BindKey( true, 0x27, 0, 0 );
BIND_SPEC_PREV = BindKey( true, 0x25, 0, 0 );
}
function onPlayerRequestClass( player, classID, team, skin )
{
if(player.SpectateTarget == null)
SPRITE_SPECHINT.ShowForPlayer(player);
else if(player.SpectateTarget == null)
{
return 1;
}
}
function onPlayerSpawn( player )
{
player.SpectateTarget = null;
SPRITE_SPECHINT.HideFromPlayer(player);
SPRITE_SPECTATEMENU.HideFromPlayer(player);
}
function onKeyDown( player, key )
{
if ( key == BIND_SPEC_NEXT )
{
if( player.SpectateTarget != null && !player.Spawned )
{
local pTargetID = player.SpectateTarget.ID;
local pTargetFind = pTargetID + 1;
local pNewTarget = null;
while(pNewTarget == null && pTargetFind != pTargetID)
{
if(pTargetFind > GetMaxPlayers() - 1)
pTargetFind = 0;
pNewTarget = FindPlayer(pTargetFind++);
if(pNewTarget != null && !pNewTarget.Spawned)
pNewTarget = null;
}
if(pNewTarget == null || pNewTarget.ID == pTargetID)
ClientMessage( "[#ed4242]Error: [#e9e9e9]No one else can be spectated.", player, 0, 0, 0 );
else
{
player.SpectateTarget = pNewTarget;
local szMsg = "[#e9e9e9]You are now spectating [#80eb7a]" + pNewTarget.Name + " (" + pNewTarget.ID + ")";
MessagePlayer(szMsg, player);
}
return;
}
}
if ( key == BIND_SPEC_PREV )
{
if( player.SpectateTarget != null && !player.Spawned )
{
local pTargetID = player.SpectateTarget.ID;
local pTargetFind = pTargetID - 1;
local pNewTarget = null;
while(pNewTarget == null && pTargetFind != pTargetID)
{
if(pTargetFind < 0)
pTargetFind = GetMaxPlayers() - 1;
pNewTarget = FindPlayer(pTargetFind--);
if(pNewTarget != null && !pNewTarget.Spawned)
pNewTarget = null;
}
if(pNewTarget == null || pNewTarget.ID == pTargetID)
ClientMessage( "[#ed4242]Error: [#e9e9e9]No one else can be spectated.", player, 0, 0, 0 );
else
{
player.SpectateTarget = pNewTarget;
local szMsg = "[#e9e9e9]You are now spectating [#80eb7a]" + pNewTarget.Name + " (" + pNewTarget.ID + ")";
MessagePlayer(szMsg, player);
}
return;
}
}
if ( key == BIND_SPEC_TOGGLE )
{
if(!player.Spawned)
{
if(player.SpectateTarget != null)
{
SPRITE_SPECTATEMENU.HideFromPlayer(player);
SPRITE_SPECHINT.ShowForPlayer(player);
player.SpectateTarget = null;
}
else
{
local pTargetID = 0;
local pNewTarget = null;
while(pNewTarget == null && pTargetID < GetMaxPlayers())
{
pNewTarget = FindPlayer(pTargetID++);
if(pNewTarget != null && !pNewTarget.Spawned)
pNewTarget = null;
}
if(pNewTarget == null)
ClientMessage( "[#ed4242]Error: [#e9e9e9]No one can be spectated at this time.", player, 0, 0, 0 );
else
{
player.SpectateTarget = pNewTarget;
local szMsg = "[#e9e9e9]You are now spectating [#80eb7a]" + pNewTarget.Name + " (" + pNewTarget.ID + ")";
MessagePlayer(szMsg, player);
SPRITE_SPECTATEMENU.ShowForPlayer(player);
SPRITE_SPECHINT.HideFromPlayer(player);
}
}
return;
}
}
}
Quote from: soulshaker on Feb 25, 2015, 12:35 PMmy Stormeus
:D :D
It is not the spectate system from 0.3, so you better just change the title into "Spectate System from PB#3".
Quote from: sseebbyy on Feb 25, 2015, 12:39 PMQuote from: soulshaker on Feb 25, 2015, 12:35 PMmy Stormeus
:D :D
It was a typo :P
Quote from: sseebbyy on Feb 25, 2015, 12:39 PMIt is not the spectate system from 0.3, so you better just change the title into "Spectate System from PB#3".
done :)