Hey all,
I've been wanting to add a HUD to a spectator's screen that differs per player that he is spectating.
Let's just say a HUD with their clientNum.
Now, I wanted to use self.spectatorClient, but them fellows over at IW decided to make that write-only (what purpose does this have, if anyone can enlighten me)
So now I need a viable method of doing this. I was thinking of creating my own spectatorListener (listening to the buttons, and editing spectatingClientNum accordingly), but I first wanted to know whether there was already some kind of built-in feature to support this; like what I initially thought could be done with self.spectatorClient
Regards,
Ridgepig
self.spectatorClient
Moderator: Core Staff
-
- CJ Wannabe
- Posts: 8
- Joined: April 23rd, 2013, 7:14 am
Re: self.spectatorClient
Tried something similar a month ago, although was instead for a hud element to display the amount of players spectating a person. Works if each player joins one after another, but on map change the self.spectatorClient order would change for unknown reasons.
Code: Select all
init()
{
level thread onPlayerConnect();
}
onPlayerConnect()
{
for( ;; )
{
level waittill( "connecting", player );
player thread spectatorCheck();
player thread spectatorMonitor();
}
}
spectatorCheck()
{
self endon( "disconnect" );
self waittill( "spawned_player" );
self.spectators = addTextHud( self, 50, 248, 1, "center", "middle", 1.4, 884 );
for( ;; )
{
self.spectators setText( spectatingPlayerList( self ) );
wait 0.05;
}
}
spectatorMonitor()
{
self endon( "disconnect" );
self endon( "spawned_player" );
self.spectatorNum = -1;
self.spectatorClient = -1;
self waittill( "joined_spectators" );
for( ;; )
{
if( self attackButtonPressed() )
{
if( self.spectatorNum >= level.players.size )
{
self.spectatorNum = 0;
self spectatorMonitorFunc( 1 );
}
else
self spectatorMonitorFunc( 1 );
iPrintLnBold( self.spectatorNum );
}
else if( self adsButtonPressed() )
{
if( self.spectatorNum <= 0 )
{
self.spectatorNum = level.players.size;
self spectatorMonitorFunc( -1 );
}
else
self spectatorMonitorFunc( -1 );
iPrintLnBold( self.spectatorNum );
}
else if( self meleeButtonPressed() ) //reset for free spectate
{
self.spectatorNum = -1;
self.spectatorClient = -1;
}
wait 0.05;
}
}
spectatorMonitorFunc( direction )
{
while( level.players[self.spectatorNum].sessionstate == "spectator" ) //can't spectate spectators
self.spectatorNum += direction;
self.spectatorClient = self.spectatorNum;
}
spectatingPlayerList( sPlayer )
{
list = "";
for( i = 0; i < level.players.size; i++ )
if( level.players[i] getEntityNumber() == sPlayer getEntityNumber() )
self.playerNum = i;
for( i = 0; i < level.players.size; i++ )
if( level.players[i].spectatorNum == self.playerNum )
list += level.players[i].name + " ";
return list;
}
addTextHud( who, x, y, alpha, alignX, alignY, fontScale, sort )
{
hud = newClientHudElem( who );
hud.x = x;
hud.y = y;
hud fadeOverTime( 0.5 );
hud.alpha = alpha;
hud.alignX = alignX;
hud.alignY = alignY;
hud.fontScale = fontScale;
hud.sort = sort;
return hud;
}
Who is online
Users browsing this forum: No registered users and 5 guests