Category: Player / View
Since engine version: 5.0 OC


Changes zoom or zoom limits vor all viewports of a player to direct values.


bool SetPlayerZoom(int player, int zoom, int precision, int flags);


Player whose zoom or zoom limits are to be adjusted. NO_OWNER for all players.
New zoom factor. A factor of zero disables direct zoom definition and reverts to the default method of calculating zoom by view range.
[opt] Value by which zoom is divided to achieve fractional numbers.
Flags controlling function behaviour:
Flag Description
PLRZOOM_Direct The zoom does not scroll slowly towards the new value, but is set directly.
PLRZOOM_NoIncrease The new zoom is only to be set if it is smaller than the current value.
PLRZOOM_NoDecrease The new zoom is only to be set if it is greater than the current value.
PLRZOOM_LimitMin Set the minimum limit for zooming. The player cannot zoom out further than this.
PLRZOOM_LimitMax Set the maximum limit for zooming. The player cannot zoom in further than this.
PLRZOOM_Set Set the current zoom. This flag is implied if neither PLRZOOM_LimitMin nor PLRZOOM_LimitMax is supplied but can be used if current zoom and limits should be set simultanuously.


Setting zoom to a direct value causes the game to look different depending on which screen resolution the player has configured. Use this function only if you want to achieve direct pixel correspondance between the game world and the screen, e.g. because your scenario provides low resolution graphics only or because your scenario should be played in certain screen resolutions only. Regular scenarios should use SetPlayerZoomByViewRange to achieve visuals whcih are independent of the player's monitor size.


func InitializePlayer(int plr)
  SetPlayerZoom(plr, 1,1, PLRZOOM_LimitMin | PLRZOOM_LimitMax);
  SetPlayerViewLock(plr, true);
  return true;
Code for a scenario script: The zoom is fixed to 1, i.e. one landscape pixel corresponds to one pixel on the screen. Zooming in or out is not possible.
See also: GetPlayerZoomLimits, SetFoW, SetLightRange, SetPlayerViewLock, SetPlayerZoomByViewRange, SetPlrView
Sven2, 2014-03