summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/APIDump/Hooks
diff options
context:
space:
mode:
Diffstat (limited to 'MCServer/Plugins/APIDump/Hooks')
-rw-r--r--MCServer/Plugins/APIDump/Hooks/OnPlayerMoving.lua4
-rw-r--r--MCServer/Plugins/APIDump/Hooks/OnServerPing.lua50
-rw-r--r--MCServer/Plugins/APIDump/Hooks/OnSpawningEntity.lua5
3 files changed, 56 insertions, 3 deletions
diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerMoving.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerMoving.lua
index 2756529ef..4385bf94d 100644
--- a/MCServer/Plugins/APIDump/Hooks/OnPlayerMoving.lua
+++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerMoving.lua
@@ -11,9 +11,11 @@ return
Params =
{
{ Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has moved. The object already has the new position stored in it." },
+ { Name = "OldPosition", Type = "{{Vector3d}}", Notes = "The old position." },
+ { Name = "NewPosition", Type = "{{Vector3d}}", Notes = "The new position." },
},
Returns = [[
- If the function returns true, movement is prohibited. FIXME: The player's client is not informed.</p>
+ If the function returns true, movement is prohibited.</p>
<p>
If the function returns false or no value, other plugins' callbacks are called and finally the new
position is permanently stored in the cPlayer object.</p>
diff --git a/MCServer/Plugins/APIDump/Hooks/OnServerPing.lua b/MCServer/Plugins/APIDump/Hooks/OnServerPing.lua
new file mode 100644
index 000000000..76b6d1517
--- /dev/null
+++ b/MCServer/Plugins/APIDump/Hooks/OnServerPing.lua
@@ -0,0 +1,50 @@
+return
+{
+ HOOK_SERVER_PING =
+ {
+ CalledWhen = "Client pings the server from the server list.",
+ DefaultFnName = "OnServerPing", -- also used as pagename
+ Desc = [[
+ A plugin may implement an OnServerPing() function and register it as a Hook to process pings from
+ clients in the server server list. It can change the logged in players and player capacity, as well
+ as the server description and the favicon, that are displayed to the client in the server list.
+ ]],
+ Params = {
+ { Name = "ClientHandle", Type = "{{cClientHandle}}", Notes = "The client handle that pinged the server" },
+ { Name = "ServerDescription", Type = "string", Notes = "The server description" },
+ { Name = "OnlinePlayersCount", Type = "number", Notes = "The number of players currently on the server" },
+ { Name = "MaxPlayersCount", Type = "number", Notes = "The current player cap for the server" },
+ { Name = "Favicon", Type = "string", Notes = "The base64 encoded favicon to be displayed in the server list for compatible clients" },
+ },
+ Returns = [[
+ The plugin can return whether to continue processing of the hook with other plugins, the server description to
+ be displayed to the client, the currently online players, the player cap and the base64/png favicon data, in that order.
+ ]],
+ CodeExamples = {
+ {
+ Title = "Change information returned to the player",
+ Desc = "Tells the client that the server description is 'test', there are one more players online than there actually are, and that the player cap is zero. It also changes the favicon data.",
+ Code = [[
+function OnServerPing(ClientHandle, ServerDescription, OnlinePlayers, MaxPlayers, Favicon)
+ -- Change Server Description
+ ServerDescription = "Test"
+
+ -- Change online / max players
+ OnlinePlayers = OnlinePlayers + 1
+ MaxPlayers = 0
+
+ -- Change favicon
+ if cFile:IsFile("my-favicon.png") then
+ local FaviconData = cFile:ReadWholeFile("my-favicon.png")
+ if (FaviconData ~= "") and (FaviconData ~= nil) then
+ Favicon = Base64Encode(FaviconData)
+ end
+ end
+
+ return false, ServerDescription, OnlinePlayers, MaxPlayers, Favicon
+end
+ ]],
+ },
+ },
+ }, -- HOOK_SERVER_PING
+}
diff --git a/MCServer/Plugins/APIDump/Hooks/OnSpawningEntity.lua b/MCServer/Plugins/APIDump/Hooks/OnSpawningEntity.lua
index c4bff3916..e2bd1c940 100644
--- a/MCServer/Plugins/APIDump/Hooks/OnSpawningEntity.lua
+++ b/MCServer/Plugins/APIDump/Hooks/OnSpawningEntity.lua
@@ -6,8 +6,9 @@ return
DefaultFnName = "OnSpawningEntity", -- also used as pagename
Desc = [[
This hook is called before the server spawns an {{cEntity|entity}}. The plugin can either modify the
- entity before it is spawned, or disable the spawning altogether. If the entity spawning is a
- monster, the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}} hook is called before this hook.</p>
+ entity before it is spawned, or disable the spawning altogether. You can't disable the spawning if the
+ entity is a player. If the entity spawning is a monster, the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}}
+ hook is called before this hook.</p>
<p>
See also the {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} hook for a similar hook called after the
entity is spawned.