OnClientCameraReset

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 23:51, 8 September 2026 by QCherry (talk | contribs) (Document scripted camera API and events available from G1R:MP 0.1.3)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

onClientCameraReset

AVAILABLE FROM UPDATE 0.1.3
This event is available in G1R:MP 0.1.3 and later. The contract below includes the compatibility guarantees introduced in that update.

Notifies an affected client resource that its camera ownership, cached state or pending requests have been forcibly invalidated.

Availability

This event is available in client-side scripts.

Callback signature

onClientCameraReset(string errorText, string stateJson)

Parameters

Name Type Description
errorText string Reason for the forced reset or invalidation, such as a connection/world/local-character change.
stateJson string Optional JSON snapshot. It can be empty, notably on IPC disconnect; do not assume it is valid JSON or a ready camera state.

Examples

Cancel your own pending cinematic state when camera ownership is lost.

local pendingMove
local cinematicTimer
addEventHandler("onClientCameraReset", resourceRoot, function(errorText, stateJson)
    pendingMove = nil
    if cinematicTimer then
        killTimer(cinematicTimer)
        cinematicTimer = nil
    end
    outputDebugString("Camera control ended: " .. tostring(errorText))
    -- Do not immediately reacquire: wait until the world/spawn is ready again.
end)

Notes

  • Built-in local client event delivered to resourceRoot; it is not a remotely triggerable server callback. Native forced cleanup targets the camera owner; IPC disconnect notifies all affected resources with cached state or pending requests, including query-only resources.
  • Resource ownership, pending requests and cached snapshots are invalidated before this callback. Do not continue an old path from an old requestId.
  • The event covers forced native lifecycle cleanup and IPC connection invalidation. A disconnect notification does not guarantee a newly rendered restored view at that instant.
  • An explicit resetCameraPos command is acknowledged by onClientCameraCommandResult with phase reset; do not wait for this forced-reset event to complete an ordinary reset.
  • World readiness and spawn completion must be re-established before requesting a new camera sequence. See Scripted camera.