<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to RID</title><link>https://sourceforge.net/p/hercules/wiki/RID/</link><description>Recent changes to RID</description><atom:link href="https://sourceforge.net/p/hercules/wiki/RID/feed" rel="self"/><language>en</language><lastBuildDate>Mon, 20 Feb 2023 05:03:12 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/hercules/wiki/RID/feed" rel="self" type="application/rss+xml"/><item><title>RID modified by Brynner</title><link>https://sourceforge.net/p/hercules/wiki/RID/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;{{OtherUse|the script state reference id|game object id|GID}}&lt;/p&gt;
&lt;p&gt;Most scripting commands and functions will want to request data about a&lt;br/&gt;
character, store variables referenced to that character, send stuff to the&lt;br/&gt;
client connected to that specific character. Whenever a script is invoked by a&lt;br/&gt;
character, it is passed a so-called RID - this is the account ID number of a&lt;br/&gt;
character that caused the code to execute by clicking on it, walking into it's&lt;br/&gt;
&lt;a class="alink" href="/p/hercules/wiki/OnTouch/"&gt;[OnTouch]&lt;/a&gt; zone, or otherwise.&lt;/p&gt;
&lt;h1 id="usage"&gt;Usage&lt;/h1&gt;
&lt;p&gt;When writing simple &lt;a class="" href="../NPCs"&gt;NPC&lt;/a&gt; only, this topic will not require much&lt;br/&gt;
attention. However, when using &lt;a class="" href="/p/hercules/wiki/Functions/"&gt;Functions&lt;/a&gt;, &lt;a class="" href="../Timers"&gt;Timers&lt;br/&gt;
(Scripting)&lt;/a&gt;, or clock-based script activation, one requires to be&lt;br/&gt;
aware of all cases when a script execution can be triggered without a RID&lt;br/&gt;
attached. This will make a lot of commands and functions unusable, since they&lt;br/&gt;
request data from a specific character, send data to a specific client, or&lt;br/&gt;
store variables specific to a character, which are unavailable, if there's no&lt;br/&gt;
RID, which refers to the character to work with, unless &lt;a class="alink" href="/p/hercules/wiki/Attachrid/"&gt;[Attachrid]&lt;/a&gt; is used&lt;br/&gt;
to explicitly attach a character to the script first.&lt;/p&gt;
&lt;p&gt;Whenever is stated &lt;em&gt;invoking character&lt;/em&gt; or &lt;em&gt;currently attached character&lt;/em&gt; , it&lt;br/&gt;
actually means &lt;em&gt;the character whose RID is currently attached to the running&lt;br/&gt;
script&lt;/em&gt;. The script function &lt;a class="alink" href="/p/hercules/wiki/Playerattached/"&gt;[Playerattached]&lt;/a&gt; can be used to check which is&lt;br/&gt;
the currently attached player to the script (it will return 0 if the there is&lt;br/&gt;
no player attached or the attached player no longer is logged on to the map-&lt;br/&gt;
server). The function &lt;a class="alink" href="/p/hercules/wiki/Detachrid/"&gt;[Detachrid]&lt;/a&gt; will explicitly set the RID to 0, so care&lt;br/&gt;
must be taken, that follow-up commands do not depend on a character being&lt;br/&gt;
attached, especially access to &lt;a class="" href="../temporary%20character%20variables"&gt;Variables&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[Category:Basics]&lt;/span&gt; &lt;span&gt;[Category:Scripting]&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Brynner</dc:creator><pubDate>Mon, 20 Feb 2023 05:03:12 -0000</pubDate><guid>https://sourceforge.net923c80d5180d1d34764afe7382c9fcab5cc62013</guid></item></channel></rss>