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
gObjViewportClose(lpObj)¶
Closes the viewport for a player. Clears their visibility from all nearby players and items.
- Parameters:
lpObj(GameObject): Player object.
- Returns:
void
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
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
gObjViewportListProtocolDestroy(lpObj)¶
Sends viewport destroy packets to the client, removing nearby objects from the player's screen.
- Parameters:
lpObj(GameObject): Player object.
- Returns:
void
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
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
gObjViewportListDestroy(aIndex)¶
Destroys all viewport entries within the map view range. Processes player, monster, and item viewports.
- Parameters:
aIndex(integer): Object index.
- Returns:
void
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
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:
boolean—trueif the target is within the attacker's viewport.
if gObjViewportAttackAreaUsed(aIndex, bIndex) then
-- Target is in viewport range, proceed with attack
end
Help