Skip to content

Viewport Functions

The viewport system controls which objects (players, monsters, items) are visible to each player. These functions manage viewport creation, destruction, and synchronization.

Advanced Use

Viewport functions are low-level and primarily used for custom teleport logic, instance maps, or forced appearance refreshes. Incorrect usage can cause invisible players or client desyncs.


gObjSetViewport(aIndex, state)

Sets the viewport state for a specific object, updating how nearby players see it.

  • Parameters:
    • aIndex (integer): Object index.
    • state (integer): Viewport state (VIEWPORT_CREATE, VIEWPORT_DESTROY, VIEWPORT_SEND).
  • Returns: void
-- Force a viewport state change
gObjSetViewport(aIndex, 1)

gObjViewportClose(lpObj)

Closes the viewport for a player. Clears their visibility from all nearby players and items.

  • Parameters:
    • lpObj (GameObject): Player object.
  • Returns: void
-- Close viewport before teleporting
gObjViewportClose(player)
gObjTeleport(aIndex, 0, 130, 130)

gObjClearViewport(lpObj)

Completely clears all viewport data for the given object — removes all tracked players, monsters, and items from their viewport list.

  • Parameters:
    • lpObj (GameObject): Player object.
  • Returns: void
gObjClearViewport(player)

gObjClearViewportOfMine(lpObj)

Removes this object from all other players' viewports. Other players will stop seeing this object until the viewport is rebuilt.

  • Parameters:
    • lpObj (GameObject): Player object.
  • Returns: void
-- Make a player temporarily invisible to others
gObjClearViewportOfMine(player)

gObjViewportListProtocolDestroy(lpObj)

Sends viewport destroy packets to the client, removing nearby objects from the player's screen.

  • Parameters:
    • lpObj (GameObject): Player object.
  • Returns: void
gObjViewportListProtocolDestroy(player)

gObjViewportListProtocolCreate(lpObj)

Sends viewport create packets to the client, refreshing the appearance of all nearby objects. Useful after changing a player's equipment, class, or visual state.

  • Parameters:
    • lpObj (GameObject): Player object.
  • Returns: void
-- Refresh a player's appearance for everyone nearby
gObjViewportListProtocolCreate(player)

gObjViewportListProtocol(aIndex)

Sends the full viewport protocol data to a player — destroys old viewport, then sends all player, monster, summon, item, guild, and gens data.

  • Parameters:
    • aIndex (integer): Object index.
  • Returns: void
-- Full viewport rebuild for a player
gObjViewportListProtocol(aIndex)

gObjViewportListDestroy(aIndex)

Destroys all viewport entries within the map view range. Processes player, monster, and item viewports.

  • Parameters:
    • aIndex (integer): Object index.
  • Returns: void
gObjViewportListDestroy(aIndex)

gObjViewportListCreate(aIndex)

Creates viewport entries for all objects within the map view range. Adds nearby players, monsters, and items to the viewport.

  • Parameters:
    • aIndex (integer): Object index.
  • Returns: void
gObjViewportListCreate(aIndex)

gObjViewportAttackAreaUsed(aIndex, bIndex)

Checks if the attack area between two objects is within viewport range.

  • Parameters:
    • aIndex (integer): Attacker object index.
    • bIndex (integer): Target object index.
  • Returns: booleantrue if the target is within the attacker's viewport.
if gObjViewportAttackAreaUsed(aIndex, bIndex) then
    -- Target is in viewport range, proceed with attack
end