SetPlrView

Category: Player / View
Since engine version: 4.6.5.0 CP

Description

Centers a player's view to the specified object. The view will follow this object until the next player command.

Syntax

bool SetPlrView (int iPlr, object pObj);

Parameters

iPlr:
Player whose view distance to want to set.
pObj:
Object to which to want to set the view.

Example

local oFeind;
// TimerCall eines automatischen Aussichtsturms
protected func Timer()
{
  // Bereits einen Feind gefunden?
  if(!oFeind)
  {
    // Alarm schlagen?
    while(oAlarm = FindObject(0, -100, -100, 200, 200, OCF_CrewMember(), 0, 0, 0, oAlarm))
      if(Hostile(GetOwner(oAlarm), GetOwner()))
      {
        // Ein feindlicher Clonk!
        SetPlrView(GetOwner(), oAlarm);
        Sound("Bing");
        break;
      }
  }
  else
  {
    if(ObjectDistance(oFeind) < 120)
    {
      // Noch einige ständige Effekte bei Alarm
      Sound("Bing");
      Message("!!! FEIND !!!", this());
    }
    else
    {
      // wenn er sich entfernt: Alarm beenden
      oFeind = 0;
    }
  }
}
				
Automatic watch tower: if an enemy clonk gets near the tower the player's view will be set to the attacker. Also, a sound is played and a message is popped up while the enemy is in range.
See also: GetPlrView, GetPlrViewMode, SetFoW, SetPlrViewRange
PeterW, April 2003