<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://g1r-mp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=OnClientCameraCommandResult</id>
	<title>OnClientCameraCommandResult - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://g1r-mp.com/wiki/index.php?action=history&amp;feed=atom&amp;title=OnClientCameraCommandResult"/>
	<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=OnClientCameraCommandResult&amp;action=history"/>
	<updated>2026-09-19T06:24:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://g1r-mp.com/wiki/index.php?title=OnClientCameraCommandResult&amp;diff=807&amp;oldid=prev</id>
		<title>QCherry: Document scripted camera API and events available from G1R:MP 0.1.3</title>
		<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=OnClientCameraCommandResult&amp;diff=807&amp;oldid=prev"/>
		<updated>2026-09-08T23:51:01Z</updated>

		<summary type="html">&lt;p&gt;Document scripted camera API and events available from G1R:MP 0.1.3&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= onClientCameraCommandResult =&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#fff5f5; border:1px solid #d13b3b; border-left:5px solid #d13b3b; color:#111111; padding:0.85rem 1rem; margin:0.75rem 0 1rem;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:#111111; font-weight:bold; letter-spacing:0.04em;&amp;quot;&amp;gt;AVAILABLE FROM UPDATE 0.1.3&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;color:#111111; margin-top:0.25rem;&amp;quot;&amp;gt;This event is available in G1R:MP 0.1.3 and later. The contract below includes the compatibility guarantees introduced in that update.&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reports execution progress or the outcome of a camera command submitted by the current client resource.&lt;br /&gt;
&lt;br /&gt;
== Availability ==&lt;br /&gt;
This event is available in &amp;#039;&amp;#039;&amp;#039;client-side&amp;#039;&amp;#039;&amp;#039; scripts.&lt;br /&gt;
&lt;br /&gt;
== Callback signature ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
onClientCameraCommandResult(number requestId, bool ok, string phase, string errorText, string stateJson)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Name !! Type !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;requestId&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; || Identifier returned by the originating camera function. Match this before handling the result.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ok&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt; || True for successful progress/results; false for execution errors or cancelled motion.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;phase&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; || state, applied, completed, reset, error or cancelled; see the operation-specific rules below.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;errorText&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; || Diagnostic reason; normally empty on success. Do not use this as a localized user-facing API contract.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;stateJson&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; || JSON camera-state snapshot when available; parse defensively with fromJSON. It can be empty if there is no valid snapshot.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Query once and correlate the response.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; line&amp;gt;&lt;br /&gt;
local pending&lt;br /&gt;
addEventHandler(&amp;quot;onClientCameraCommandResult&amp;quot;, resourceRoot,&lt;br /&gt;
    function(requestId, ok, phase, errorText, stateJson)&lt;br /&gt;
        if requestId ~= pending then return end&lt;br /&gt;
        if not ok then&lt;br /&gt;
            pending = nil&lt;br /&gt;
            outputDebugString(&amp;quot;Camera failed: &amp;quot; .. tostring(errorText), 2)&lt;br /&gt;
            return&lt;br /&gt;
        end&lt;br /&gt;
        if phase == &amp;quot;state&amp;quot; then&lt;br /&gt;
            pending = nil&lt;br /&gt;
            local state = getCameraState()&lt;br /&gt;
            if state and state.ready then&lt;br /&gt;
                outputDebugString(&amp;quot;FOV: &amp;quot; .. tostring(state.fov))&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end)&lt;br /&gt;
-- Call when the local game world and camera are ready.&lt;br /&gt;
pending = requestCameraState()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* Built-in local event: attach to resourceRoot; do not call addEvent to declare it and do not send it across the network.&lt;br /&gt;
* requestCameraState succeeds with state, which may contain ready=false before the local camera is ready. Position/rotation/LookAt/FOV/pose setters and stopCameraMovement succeed with applied.&lt;br /&gt;
* moveCameraTo, playCameraPath and orbitCamera first acknowledge applied. Non-looping movement later emits completed; loops continue until stopped, replaced, reset or invalidated and do not emit completed while looping.&lt;br /&gt;
* resetCameraPos succeeds with reset after the return transition. A superseded movement can emit ok=false/cancelled for its old requestId. An interrupted reset can emit ok=false/error.&lt;br /&gt;
* A request rejected synchronously with false has no valid requestId to await. Server-side mutation calls return only a queued boolean and do not produce this event in server Lua.&lt;br /&gt;
* A valid snapshot is cached before the callback. Getters see that snapshot inside the handler; phase applied/completed does not certify that the new view has rendered. Request another snapshot after the next frame or a short timer if required.&lt;br /&gt;
* Stale generations, wrong-resource and unknown-request results are discarded. Use [[onClientCameraReset]] to discard pending client-side work after forced cleanup.&lt;br /&gt;
* Snapshot fields and owner rules are documented in [[Scripted camera]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Events]]&lt;br /&gt;
[[Category:Client Events]]&lt;/div&gt;</summary>
		<author><name>QCherry</name></author>
	</entry>
</feed>