# SimpleScript.OnChatOptionsAttribute

Kind: Class · Namespace: Sansar.Simulation · Assembly: Sansar.Simulation.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-class" data-pagefind-filter="kind:Class">Class</span>
<span data-pagefind-filter="namespace:Sansar.Simulation">Namespace <a href="/scripting/api/sansar.simulation"><code>Sansar.Simulation</code></a></span>
<span>Inherits <a href="/scripting/api/sansar.simulation/simplescript.simplescriptoptionsattribute">SimpleScript.SimpleScriptOptionsAttribute</a></span>
</div>

<span id="T:Sansar.Simulation.SimpleScript.OnChatOptionsAttribute"></span>

Set options for OnChat() overrides, or use to create more simple chat handlers.

```csharp
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=true)]
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
protected class SimpleScript.OnChatOptionsAttribute : SimpleScript.SimpleScriptOptionsAttribute
```

## Remarks

This attribute is optional when overriding OnChat which by default will respond to all chat on the default channel (Chat.DefaultChannel) and all sources.

 Add this attribute to any method that matches Action&lt;ChatData&gt; to create extra chat event subscriptions.

```csharp
[OnChatOptions(Channel=5)]
void ChatFrom5(ChatData data)
{
   // chat from channel 5.
}
  
void OnChat(ChatData data)
{
   // chat from the default channel (0)
}
```

## Example

```csharp
// Only listen for chat on Channel 10 from scripts.
[OnChatOptions(Channel=10, Source="script")]
protected override OnChat(ChatData data)
```

## Members at a glance

| Kind | Members |
|---|---|
| **Constructors** | [OnChatOptionsAttribute](#onchatoptionsattribute) |
| **Properties** | [Channel](#channel) · [Source](#source) |

## Constructors

### OnChatOptionsAttribute

<div class="api-card">
<span id="M:Sansar.Simulation.SimpleScript.OnChatOptionsAttribute.#ctor"></span>
<span id="C:Sansar.Simulation.SimpleScript.OnChatOptionsAttribute()"></span>

```csharp signature
public SimpleScript.OnChatOptionsAttribute()
```

Set options for OnChat events

</div>


## Properties

### Channel

<div class="api-card">
<span id="P:Sansar.Simulation.SimpleScript.OnChatOptionsAttribute.Channel"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
public int Channel { get; set; }
```

Specify a specific channel to listen for messages on.

**Value:** [int](https://learn.microsoft.com/dotnet/api/system.int32) — The channel to listen for chat on.

<details class="api-remarks"><summary>Remarks</summary>

By default listens for chat on Chat.DefaultChannel (0).

</details>

<details class="api-example" open><summary>Example</summary>

```csharp
// Only listen for chat on Channel 10.
[OnChatOptions(Channel=10)]
protected override OnChat(ChatData data)
```

</details>

</div>

### Source

<div class="api-card">
<span id="P:Sansar.Simulation.SimpleScript.OnChatOptionsAttribute.Source"></span>
<div class="api-badges"><span class="api-badge api-deprecated">Deprecated</span></div>

```csharp signature
[System.Obsolete("SimpleScript is deprecated and will not receive new features. Please use SceneObjectScript or ObjectScript.", false)]
public string Source { get; set; }
```

string source of the chat: system, user or script.

**Value:** [string](https://learn.microsoft.com/dotnet/api/system.string) — The source chat to listen for: &quot;script&quot;, &quot;user&quot; or &quot;system&quot;

<details class="api-remarks"><summary>Remarks</summary>

Restricts which chat messages will trigger OnChat. \[OnChatOptions(Source=&quot;user&quot;)\] will only run OnChat for chat from users, while &quot;script&quot; will respond to other script messages, and &quot;system&quot; will only respond to system messages.

</details>

</div>




<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>