Skip to content

Commit bbfa601

Browse files
Fix Event_System links
1 parent 16297f1 commit bbfa601

10 files changed

+38
-28
lines changed

web/astro.config.mjs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,27 @@ export default defineConfig({
6767
{
6868
label: 'Functions',
6969
items: [
70-
{label: 'All functions', link: '/reference/Scripting_Functions'},
71-
{label: 'Shared functions', link: '/reference/Shared_Scripting_Functions'},
72-
{label: 'Client functions', link: '/reference/Client_Scripting_Functions'},
73-
{label: 'Server functions', link: '/reference/Server_Scripting_Functions'},
70+
{label: 'All Functions', link: '/reference/Scripting_Functions'},
71+
{label: 'Shared Functions', link: '/reference/Shared_Scripting_Functions'},
72+
{label: 'Client Functions', link: '/reference/Client_Scripting_Functions'},
73+
{label: 'Server Functions', link: '/reference/Server_Scripting_Functions'},
7474
]
7575
},
7676
{
7777
label: 'Events',
7878
items: [
79-
{label: 'All events', link: '/reference/Scripting_Events'},
80-
{label: 'Client events', link: '/reference/Client_Scripting_Events'},
81-
{label: 'Server events', link: '/reference/Server_Scripting_Events'},
79+
{label: 'Event System', link: '/reference/Event_System'},
80+
{label: 'All Events', link: '/reference/Scripting_Events'},
81+
{label: 'Client Events', link: '/reference/Client_Scripting_Events'},
82+
{label: 'Server Events', link: '/reference/Server_Scripting_Events'},
8283
]
8384
},
8485
{
8586
label: 'Elements',
8687
items: [
87-
{label: 'Element types', link: '/reference/Element'},
88-
{label: 'Element tree', link: '/reference/Element_tree'},
89-
{label: 'Entity', link: '/reference/Entity'},
88+
{label: 'Element Types', link: '/reference/Element'},
89+
{label: 'Element Tree', link: '/reference/Element_tree'},
90+
{label: 'Entities', link: '/reference/Entity'},
9091
]
9192
},
9293
{

web/src/pages/reference/Client_Scripting_Events.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const theseEvents = eventsByTypeByCategory.client;
1010
---
1111
<StarlightPage frontmatter={{
1212
template: 'doc',
13-
title: 'Client events',
13+
title: 'Client Events',
1414
tableOfContents: false,
1515
}}>
1616
<p>This page lists all <span class="side-client"><strong>client-side</strong></span> events available in the <a href="/reference/Lua_API">Lua API</a> organized by category.</p>

web/src/pages/reference/Client_Scripting_Functions.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const theseFunctions = functionsByTypeByCategory.client;
1010
---
1111
<StarlightPage frontmatter={{
1212
template: 'doc',
13-
title: 'Client functions',
13+
title: 'Client Functions',
1414
tableOfContents: false,
1515
}}>
1616
<p>This page lists all <span class="side-client"><strong>client-side</strong></span> functions available in the <a href="/reference/Lua_API">Lua API</a> organized by category.</p>

web/src/pages/reference/Event_System.astro

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
3+
import { Code } from '@astrojs/starlight/components';
34
---
45
<StarlightPage frontmatter={{
56
template: 'doc',
@@ -12,19 +13,19 @@ The event system is at the core of MTA scripting. Events work closely in conjunc
1213

1314
<h2 id="event-handlers">Event handlers</h2>
1415
<p>
15-
To use the event system, you attach event handlers to elements in the element tree using <code>addEventHandler</code>. When you do this, your function will get triggered for all the events triggered on that element, its parents (and their parents, etc.) and its children (and their children). As such, an event handler attached to the <em>root</em> element will be triggered when an event occurs for any element. As a consequence you should generally use as specific a handler as you can. If you wish to just see when the player enters a specific marker, just attach the event handler to that marker.
16+
To use the event system, you attach event handlers to elements in the element tree using <a href="/reference/addEventHandler">addEventHandler</a>. When you do this, your function will get triggered for all the events triggered on that element, its parents (and their parents, etc.) and its children (and their children). As such, an event handler attached to the <em>root</em> element will be triggered when an event occurs for any element. As a consequence you should generally use as specific a handler as you can. If you wish to just see when the player enters a specific marker, just attach the event handler to that marker.
1617
</p>
1718

1819
<p>Each event handler has three 'hidden' variables:</p>
1920
<ul>
2021
<li><strong>source</strong>: This is the element that the event originated from.</li>
21-
<li><strong>this</strong>: This is the element that the handler is being triggered on (i.e. the one you attached it to with <code>addEventHandler</code>).</li>
22-
<li><strong>eventName</strong>: This is the string of the name of the event that was called upon (i.e. the event name that was added with <code>addEventHandler</code>).</li>
22+
<li><strong>this</strong>: This is the element that the handler is being triggered on (i.e. the one you attached it to with <a href="/reference/addEventHandler">addEventHandler</a>).</li>
23+
<li><strong>eventName</strong>: This is the string of the name of the event that was called upon (i.e. the event name that was added with <a href="/reference/addEventHandler">addEventHandler</a>).</li>
2324
</ul>
2425

2526
<p>Additionally, the server-side event system also has one more 'hidden' variable:</p>
2627
<ul>
27-
<li><strong>client</strong>: This is the client that triggered the event using <code>triggerServerEvent</code>. This is not set if the event was not triggered from a client.</li>
28+
<li><strong>client</strong>: This is the client that triggered the event using <a href="/reference/triggerServerEvent">triggerServerEvent</a>. This is not set if the event was not triggered from a client.</li>
2829
</ul>
2930

3031
<p>
@@ -41,17 +42,17 @@ It is <strong>important</strong> to note that events follow the element hierarch
4142
<li>You can attach an event handler to your resource's root element to get all the events triggered by elements your resource contains.</li>
4243
<li>You can create 'dummy' elements to catch events from a group of child elements.</li>
4344
<li>
44-
You can use dummy elements specified in a .map file (e.g. <code>&lt;flag&gt;</code>) and create 'real' representations for them (e.g. objects) and make these real elements children of the dummy element. Event handlers can then be attached to the dummy element and it will receive all the events of the real elements.
45+
You can use dummy elements specified in a .map file (e.g. "flag") and create 'real' representations for them (e.g. objects) and make these real elements children of the dummy element. Event handlers can then be attached to the dummy element and it will receive all the events of the real elements.
4546
This is useful for when one resource manages the representation of the element (creating the objects, for example), while another wants to handle special events. This could be a map resource that wants to handle a flag being captured in a specific way - the map resource would (generally) not be aware of the way the flag is represented.
4647
This doesn't matter as it can just attach handlers to its dummy flag element while the other gamemode resource can handle the representation.
4748
</li>
4849
</ul>
4950

5051
<p>
51-
The function you attached to an event gets called and passed a bunch of arguments. These arguments are event-specific. Each event has specific parameters, for instance <code>onClientGUIClick</code> has 4 parameters, which are:
52+
The function you attached to an event gets called and passed a bunch of arguments. These arguments are event-specific. Each event has specific parameters, for instance <a href="/reference/onClientGUIClick">onClientGUIClick</a> has 4 parameters, which are:
5253
</p>
5354

54-
<pre><code class="language-lua">string button, string state, int absoluteX, int absoluteY</code></pre>
55+
<Code code="string button, string state, int absoluteX, int absoluteY" lang="lua" />
5556

5657
<p>
5758
The function you attached to this event will be passed these parameters as arguments. You must remember that each event has different parameters.
@@ -64,16 +65,16 @@ MTA has a number of built in events. These are listed on the pages <a href="/ref
6465

6566
<h2 id="custom-events">Custom events</h2>
6667
<p>
67-
You can create your own events that can be triggered across all resources. This is an important way to communicate with other resources and allow them to hook into your code. To add your own custom event, just call the <code>addEvent</code> function. You can then use the <code>triggerEvent</code> function to trigger that event any time you want - either using a timer, or based on a more general event.
68+
You can create your own events that can be triggered across all resources. This is an important way to communicate with other resources and allow them to hook into your code. To add your own custom event, just call the <a href="/reference/addEvent">addEvent</a> function. You can then use the <a href="/reference/triggerEvent">triggerEvent</a> function to trigger that event any time you want - either using a timer, or based on a more general event.
6869
</p>
6970

7071
<p>
71-
For example, you could be making a Capture the Flag game mode and want to trigger an event when a player captures the flag. You could do this by attaching a event handler to the standard MTA <code>onMarkerHit</code> event and checking that the player entering the marker has the flag. If they do, you can then trigger your more specific <em>onFlagCaptured</em> event and other resources could handle this as they please.
72+
For example, you could be making a Capture the Flag game mode and want to trigger an event when a player captures the flag. You could do this by attaching a event handler to the standard MTA <a href="/reference/onMarkerHit">onMarkerHit</a> event and checking that the player entering the marker has the flag. If they do, you can then trigger your more specific <em>onFlagCaptured</em> event and other resources could handle this as they please.
7273
</p>
7374

7475
<h2 id="canceling">Canceling</h2>
7576
<p>
76-
Events can be canceled with <code>cancelEvent</code>. This can have a variety of effects, but in general this means that the server will not perform whatever action it would usually do. For example, canceling <code>onPickupUse</code> would prevent a player being given what they tried to pick up, canceling <code>onVehicleStartEnter</code> would prevent the player entering the vehicle. You can check if the currently active event has been canceled using <code>wasEventCanceled</code>. It's important to note that canceling an event <strong>does not</strong> prevent other event handlers being triggered.
77+
Events can be canceled with <a href="/reference/cancelEvent">cancelEvent</a>. This can have a variety of effects, but in general this means that the server will not perform whatever action it would usually do. For example, canceling <a href="/reference/onPickupUse">onPickupUse</a> would prevent a player being given what they tried to pick up, canceling <a href="/reference/onVehicleStartEnter">onVehicleStartEnter</a> would prevent the player entering the vehicle. You can check if the currently active event has been canceled using <a href="/reference/wasEventCancelled">wasEventCancelled</a>. It's important to note that canceling an event <strong>does not</strong> prevent other event handlers being triggered.
7778
</p>
7879

7980
</StarlightPage>

web/src/pages/reference/Scripting_Events.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const eventsByCategory = getEventsByCategory();
88
---
99
<StarlightPage frontmatter={{
1010
template: 'doc',
11-
title: 'All events',
11+
title: 'All Events',
1212
tableOfContents: false,
1313
}}>
1414
<p>This page lists all <span class="side-client"><strong>client-side</strong></span> and <span class="side-server"><strong>server-side</strong></span> events available in the <a href="/reference/Lua_API">Lua API</a> organized by category.</p>

web/src/pages/reference/Scripting_Functions.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const functionsByCategory = getFunctionsByCategory();
99
---
1010
<StarlightPage frontmatter={{
1111
template: 'doc',
12-
title: 'All functions',
12+
title: 'All Functions',
1313
tableOfContents: false,
1414
}}>
1515
<p>This page lists all <span class="side-client"><strong>client-side</strong></span>, <span class="side-server"><strong>server-side</strong></span> and <span class="side-shared"><strong>shared</strong></span> functions available in the <a href="/reference/Lua_API">Lua API</a> organized by category.</p>

web/src/pages/reference/Server_Scripting_Events.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const theseEvents = eventsByTypeByCategory.server;
1010
---
1111
<StarlightPage frontmatter={{
1212
template: 'doc',
13-
title: 'Server events',
13+
title: 'Server Events',
1414
tableOfContents: false,
1515
}}>
1616
<p>This page lists all <span class="side-server"><strong>server-side</strong></span> events available in the <a href="/reference/Lua_API">Lua API</a> organized by category.</p>

web/src/pages/reference/Server_Scripting_Functions.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const theseFunctions = functionsByTypeByCategory.server;
1010
---
1111
<StarlightPage frontmatter={{
1212
template: 'doc',
13-
title: 'Server functions',
13+
title: 'Server Functions',
1414
tableOfContents: false,
1515
}}>
1616
<p>This page lists all <span class="side-server"><strong>server-side</strong></span> functions available in the <a href="/reference/Lua_API">Lua API</a> organized by category.</p>

web/src/pages/reference/Shared_Scripting_Functions.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const theseFunctions = functionsByTypeByCategory.shared;
1010
---
1111
<StarlightPage frontmatter={{
1212
template: 'doc',
13-
title: 'Shared functions',
13+
title: 'Shared Functions',
1414
tableOfContents: false,
1515
}}>
1616
<p>This page lists all <span class="side-shared"><strong>shared</strong></span> functions available in the <a href="/reference/Lua_API">Lua API</a> organized by category.</p>

web/src/pages/reference/[event].astro

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import fs from "fs";
55
import path from "path";
66
import { Code } from '@astrojs/starlight/components';
77
import { renderInlineMarkdown, getSeeAlsoLinksForItem } from '@src/utils/general';
8+
import { Icon } from '@astrojs/starlight/components';
89
910
1011
import NoteBox from '@src/components/NoteBox.astro';
@@ -105,7 +106,7 @@ if (Array.isArray(event.data.notes) && event.data.notes.length > 0) {
105106
<!-- Canceling (optional) -->
106107
{event.data.canceling && (
107108
<>
108-
<h4>Canceling</h4>
109+
<h4>Canceling <a href="/reference/Event_System#canceling"><Icon size="1.6rem" name="information" class="help-icon" /></a></h4>
109110
<p>{event.data.canceling}</p>
110111
</>
111112
)}
@@ -115,3 +116,10 @@ if (Array.isArray(event.data.notes) && event.data.notes.length > 0) {
115116
<SeeAlsoSection seeAlsoLinks={getSeeAlsoLinksForItem(event)} currentId={event.id} />
116117
</StarlightPage>
117118
</div>
119+
120+
<style>
121+
.help-icon {
122+
display: inline-block;
123+
vertical-align: middle;
124+
}
125+
</style>

0 commit comments

Comments
 (0)