<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="_md_docs_2core_2add_task" xml:lang="en-US">
<title>addTask</title>
<indexterm><primary>addTask</primary></indexterm>
<section xml:id="_md_docs_2core_2add_task_1autotoc_md81">
<title>autotoc_md81</title>
<para>title: ArmaRAMDb - Add Task icon: mdi:file-text-outline </para>
</section>
<section xml:id="_md_docs_2core_2add_task_1autotoc_md82">
<title>excerpt: Add task to queue.</title></section>
<section xml:id="_md_docs_2core_2add_task_1autotoc_md83">
<title>ramdb_db_fnc_addTask</title><section xml:id="_md_docs_2core_2add_task_1autotoc_md84">
<title>Description</title>
<para>Adds a task to the database operation queue. This function is used to schedule database operations that can be processed sequentially, providing a way to manage multiple database requests in an organized manner.</para>
</section>
<section xml:id="_md_docs_2core_2add_task_1autotoc_md85">
<title>Syntax</title>
<para><literallayout><computeroutput>[_taskType,&#32;_key,&#32;_keyField,&#32;_index,&#32;_value,&#32;_function,&#32;_call,&#32;_netId]&#32;call&#32;ramdb_db_fnc_addTask
</computeroutput></literallayout></para>
</section>
<section xml:id="_md_docs_2core_2add_task_1autotoc_md86">
<title>Parameters</title>
<para><informaltable frame="all">
    <tgroup cols="4" align="left" colsep="1" rowsep="1">
      <colspec colname='c1'/>
      <colspec colname='c2'/>
      <colspec colname='c3'/>
      <colspec colname='c4'/>
<thead>
      <row  class='markdownTableHead'>
<entry>
<para>Parameter   </para>
</entry><entry>
<para>Type   </para>
</entry><entry>
<para>Description   </para>
</entry><entry>
<para>Default    </para>
</entry></row>
</thead><tbody>
      <row  class='markdownTableRowOdd'>
<entry>
<para><computeroutput>_taskType</computeroutput>   </para>
</entry><entry>
<para>String   </para>
</entry><entry>
<para>Type of operation to perform (e.g., &quot;hgetall&quot;)   </para>
</entry><entry>
<para>&quot;&quot;    </para>
</entry></row>
      <row  class='markdownTableRowEven'>
<entry>
<para><computeroutput>_key</computeroutput>   </para>
</entry><entry>
<para>String   </para>
</entry><entry>
<para>Name of the stored key   </para>
</entry><entry>
<para>&quot;&quot;    </para>
</entry></row>
      <row  class='markdownTableRowOdd'>
<entry>
<para><computeroutput>_keyField</computeroutput>   </para>
</entry><entry>
<para>String   </para>
</entry><entry>
<para>Field name for hash operations   </para>
</entry><entry>
<para>&quot;&quot;    </para>
</entry></row>
      <row  class='markdownTableRowEven'>
<entry>
<para><computeroutput>_index</computeroutput>   </para>
</entry><entry>
<para>Number   </para>
</entry><entry>
<para>Index for list operations   </para>
</entry><entry>
<para>-1    </para>
</entry></row>
      <row  class='markdownTableRowOdd'>
<entry>
<para><computeroutput>_value</computeroutput>   </para>
</entry><entry>
<para>Array, String, Number, or Boolean   </para>
</entry><entry>
<para>Value to store (for set operations)   </para>
</entry><entry>
<para>[]    </para>
</entry></row>
      <row  class='markdownTableRowEven'>
<entry>
<para><computeroutput>_function</computeroutput>   </para>
</entry><entry>
<para>String   </para>
</entry><entry>
<para>Name of function to call with the result   </para>
</entry><entry>
<para>&quot;&quot;    </para>
</entry></row>
      <row  class='markdownTableRowOdd'>
<entry>
<para><computeroutput>_call</computeroutput>   </para>
</entry><entry>
<para>Boolean   </para>
</entry><entry>
<para>Whether to call the function directly (true) or spawn (false)   </para>
</entry><entry>
<para>false    </para>
</entry></row>
      <row  class='markdownTableRowEven'>
<entry>
<para><computeroutput>_netId</computeroutput>   </para>
</entry><entry>
<para>String   </para>
</entry><entry>
<para>NetID of the target to receive the result   </para>
</entry><entry>
<para>&quot;&quot;   </para>
</entry></row>
    </tbody>
    </tgroup>
</informaltable>
</para>
</section>
<section xml:id="_md_docs_2core_2add_task_1autotoc_md87">
<title>Return Value</title>
<para>None. The task is added to the queue and processed asynchronously.</para>
</section>
<section xml:id="_md_docs_2core_2add_task_1autotoc_md88">
<title>Examples</title><section xml:id="_md_docs_2core_2add_task_1autotoc_md89">
<title>Add a hash table retrieval task:</title>
<para><literallayout><computeroutput>[&quot;hgetall&quot;,&#32;&quot;&quot;,&#32;&quot;&quot;,&#32;-1,&#32;[],&#32;&quot;ramdb_db_fnc_test&quot;]&#32;call&#32;ramdb_db_fnc_addTask;
</computeroutput></literallayout></para>
</section>
<section xml:id="_md_docs_2core_2add_task_1autotoc_md90">
<title>Add a player-specific task that returns data to a specific client:</title>
<para><literallayout><computeroutput>[&quot;hgetallid&quot;,&#32;getPlayerUID&#32;player,&#32;&quot;&quot;,&#32;-1,&#32;[],&#32;&quot;ramdb_db_fnc_test&quot;,&#32;false,&#32;netId&#32;player]&#32;remoteExecCall&#32;[&quot;ramdb_db_fnc_addTask&quot;,&#32;2,&#32;false];
</computeroutput></literallayout></para>
</section>
<section xml:id="_md_docs_2core_2add_task_1autotoc_md91">
<title>Add a list operation task:</title>
<para><literallayout><computeroutput>[&quot;listadd&quot;,&#32;&quot;playerMessages&quot;,&#32;&quot;&quot;,&#32;-1,&#32;[&quot;New&#32;message&#32;content&quot;],&#32;&quot;&quot;]&#32;call&#32;ramdb_db_fnc_addTask;
</computeroutput></literallayout></para>
</section>
</section>
<section xml:id="_md_docs_2core_2add_task_1autotoc_md92">
<title>Notes</title>
<para><itemizedlist>
<listitem>
<para>Tasks are processed in the order they are added to the queue</para>
</listitem><listitem>
<para>If the queue is not currently being processed, this function will start the processing</para>
</listitem><listitem>
<para>The task type determines which database operation will be performed</para>
</listitem><listitem>
<para>This function is particularly useful for scheduling multiple related operations</para>
</listitem><listitem>
<para>All operations performed through the task queue are logged for debugging</para>
</listitem></itemizedlist>
</para>
</section>
<section xml:id="_md_docs_2core_2add_task_1autotoc_md93">
<title>Related Functions</title>
<para><itemizedlist>
<listitem>
<para><computeroutput>ramdb_db_fnc_processQueue</computeroutput>: Processes the pending tasks in the queue</para>
</listitem><listitem>
<para><computeroutput>ramdb_db_fnc_handler</computeroutput>: Handles the results of completed database operations</para>
</listitem><listitem>
<para><computeroutput>ramdb_db_fnc_scheduler</computeroutput>: Manages callback responses from the database</para>
</listitem></itemizedlist>
</para>
</section>
<section xml:id="_md_docs_2core_2add_task_1autotoc_md94">
<title>Links</title>
<para><link linkend="_md_docs_2core_2add_task">Add Task</link> | <link linkend="_md_docs_2core_2handler">Handler</link> | <link linkend="_md_docs_2core_2init">Init</link> | <link linkend="_md_docs_2core_2print_addon_name">Print Addon Name</link> | <link linkend="_md_docs_2core_2process_queue">Process Queue</link> | <link linkend="_md_docs_2core_2scheduler">Scheduler</link> | <link linkend="_md_docs_2core_2test">Test</link> </para>
</section>
</section>
</section>
