simple change

This commit is contained in:
georgey 2025-01-06 12:32:35 +11:00
parent d77fa7e572
commit b1d6bae074
2 changed files with 32 additions and 6 deletions

View File

@ -4,7 +4,7 @@
Feel you could help? Please do by clicking on the page with a pencil on the right!
This can be done any page too.
This can be done on any page too.
# Server Scripting Reference
## Server Version 3.X
@ -265,6 +265,19 @@ For a list of events the server provides, see [here](/en/Scripting/new-lua-scrip
If the event with that name doesn't exist, it's created, and thus RegisterEvent cannot fail. This can be used to create custom events.
Example:
```lua
function ChatHandler(player_id, player_name, msg)
if msg == "damn" then
return 1
else
return 0
end
end
MP.RegisterEvent("onChatMessage", "ChatHandler")
```
#### `MP.CreateEventTimer(event_name: string, interval_ms: number, [strategy: number (since v3.0.2)])`
Starts a timer inside the server which triggers the event `event_name` every `interval_ms` milliseconds.
@ -351,6 +364,19 @@ In the game, this will not appear as a directed message.
You can use this, for example, to tell a player *why* you cancelled their vehicle spawn, chat message, or similar, or to display some information about your server.
Example:
```lua
function ChatHandler(player_id, player_name, msg)
if string.match(msg, "damn") then
MP.SendChatMessage(player_id, "Please do not use profanity.")
return 1
else
return 0
end
end
MP.RegisterEvent("onCh)
#### `MP.TriggerClientEvent(player_id: number, event_name: string, data: string) -> boolean`
*until v3.1.0*

View File

@ -331,11 +331,11 @@ markdown_extensions:
nav:
- Home: index.md
- Getting started:
- Getting Started:
- Playing BeamMP:
- Installing BeamMP: game/getting-started.md
- Error Codes: game/error-codes.md
- Customizing your setup: game/tailoring.md
- Customizing Your Setup: game/tailoring.md
- Using BeamMP: game/playing.md
- Running a Server:
- Server Installation: server/create-a-server.md
@ -362,7 +362,7 @@ nav:
- beamng/index.md
- Content Development:
- Introduction: beamng/dev/index.md
- Coding:
- Programming:
- UI Apps (HTML): beamng/dev/modding/ui-apps.md
- IMGUI Windows (Lua): beamng/dev/modding/imgui-windows.md
- Lua Mods (Scripts): beamng/dev/modding/lua-mods.md
@ -374,8 +374,8 @@ nav:
- Scripting Reference:
- Mod (In-Game): scripting/mod-reference.md
- Server:
- V3.X (Latest): scripting/server/latest-server-reference.md
- V2.X: scripting/server/v2-server-reference.md
- Version 3.X (Latest): scripting/server/latest-server-reference.md
- Version 2.X (Deprecated): scripting/server/v2-server-reference.md
- Contributing:
- Getting Started: contributing.md
- Community: