# Scripting

### Structure

> > #### *canJoin(player)*
> >
> > **Parameters**:
> >
> > * player: Player attempting to join the channel.
> >
> > **Return Value**:
> >
> > * **true**: Player will be allowed to join the channel.
> > * **false**: Player will not be allowed to join the channel.
>
> > #### *onSpeak(player, type, message)*
> >
> > **Parameters**:
> >
> > * **player**: Player who is speaking.
> > * **type**: Talk type (SpeakClasses enum in const.h).
> > * **message**: Message being sent to the channel.
> >
> > **Return Value**:
> >
> > * Talk type (SpeakClasses enum in const.h)
> > * > TALKTYPE\_SAY
> >   >
> >   > TALKTYPE\_WHISPER
> >   >
> >   > TALKTYPE\_YELL
> >   >
> >   > TALKTYPE\_PRIVATE\_FROM
> >   >
> >   > TALKTYPE\_PRIVATE\_TO
> >   >
> >   > TALKTYPE\_CHANNEL\_Y
> >   >
> >   > TALKTYPE\_CHANNEL\_O
> >   >
> >   > TALKTYPE\_PRIVATE\_NP
> >   >
> >   > TALKTYPE\_PRIVATE\_PN
> >   >
> >   > TALKTYPE\_BROADCAST
> >   >
> >   > TALKTYPE\_CHANNEL\_R1
> >   >
> >   > TALKTYPE\_PRIVATE\_RED\_FROM
> >   >
> >   > TALKTYPE\_PRIVATE\_RED\_TO
> >   >
> >   > TALKTYPE\_MONSTER\_SAY
> >   >
> >   > TALKTYPE\_MONSTER\_YELL
> >   >
> >   > TALKTYPE\_CHANNEL\_R2

### Example

```lua
function canJoin(player)
	return player:getName() == "Delusion"
end

function onSpeak(player, type, message)
	-- Force orange messages no matter what in the channel
	return TALKTYPE_CHANNEL_O
end
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://stigmax.gitbook.io/tfs-guide/interface-chatchannels/channel-scripting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
