<?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=RequestCameraState</id>
	<title>RequestCameraState - 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=RequestCameraState"/>
	<link rel="alternate" type="text/html" href="https://g1r-mp.com/wiki/index.php?title=RequestCameraState&amp;action=history"/>
	<updated>2026-09-19T06:22:12Z</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=RequestCameraState&amp;diff=802&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=RequestCameraState&amp;diff=802&amp;oldid=prev"/>
		<updated>2026-09-08T23:50:53Z</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;= requestCameraState =&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 function 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;
Requests an asynchronous read-back of the local camera and local player position without taking camera ownership.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
number|false requestCameraState()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
This function does not accept parameters.&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
A positive requestId if queued, or false if the request cannot be submitted. A matching [[onClientCameraCommandResult]] with &amp;lt;code&amp;gt;ok=true, phase=&amp;quot;state&amp;quot;&amp;lt;/code&amp;gt; carries the snapshot; execution failure reports an error.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Read a snapshot once; do not issue another query unconditionally inside the result handler.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; line&amp;gt;&lt;br /&gt;
-- Client-side: run after the local world and player camera are ready.&lt;br /&gt;
local query&lt;br /&gt;
addEventHandler(&amp;quot;onClientCameraCommandResult&amp;quot;, resourceRoot,&lt;br /&gt;
    function(requestId, ok, phase, errorText, stateJson)&lt;br /&gt;
        if requestId ~= query then return end&lt;br /&gt;
        query = nil&lt;br /&gt;
        if not ok or phase ~= &amp;quot;state&amp;quot; then&lt;br /&gt;
            outputDebugString(&amp;quot;Camera query failed: &amp;quot; .. tostring(errorText), 2)&lt;br /&gt;
            return&lt;br /&gt;
        end&lt;br /&gt;
        local state = getCameraState()&lt;br /&gt;
        if not state or not state.ready then return end&lt;br /&gt;
        outputDebugString((&amp;quot;Player position: %.2f %.2f %.2f&amp;quot;):format(state.playerX, state.playerY, state.playerZ))&lt;br /&gt;
    end)&lt;br /&gt;
query = requestCameraState()&lt;br /&gt;
if not query then outputDebugString(&amp;quot;Camera query was not queued&amp;quot;, 2) end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* Client-side only. Equivalent spelling: &amp;lt;code&amp;gt;RequestCameraState&amp;lt;/code&amp;gt;.&lt;br /&gt;
* A query can be submitted before the local world/camera is ready, provided the IPC connection can accept it. A successful state response may have ready=false; check that field before using pose values or starting camera control. A successful Lua return is only a request ID, not an acknowledgement.&lt;br /&gt;
* Queries do not acquire the camera and can be issued by another resource while the current owner controls it.&lt;br /&gt;
* The resource cache is updated before the result callback, making [[getCameraPos]], [[getCameraRot]], [[getCameraFOV]] and [[getCameraState]] available there.&lt;br /&gt;
* Use the requestId to match replies and handle [[onClientCameraReset]] by discarding pending work. See [[Scripted camera]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua Functions]]&lt;br /&gt;
[[Category:Client Functions]]&lt;br /&gt;
[[Category:Camera Functions]]&lt;/div&gt;</summary>
		<author><name>QCherry</name></author>
	</entry>
</feed>