Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
s_player.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include "cpp_api/s_base.h"
8#include "irr_v3d.h"
9#include "util/string.h"
10
11struct MoveAction;
13struct ItemStack;
14struct ToolCapabilities;
17
18class ScriptApiPlayer : virtual public ScriptApiBase
19{
20public:
21 virtual ~ScriptApiPlayer() = default;
22
23 void on_newplayer(ServerActiveObject *player);
24 void on_dieplayer(ServerActiveObject *player, const PlayerHPChangeReason &reason);
26 bool on_prejoinplayer(const std::string &name, const std::string &ip,
27 std::string *reason);
28 bool can_bypass_userlimit(const std::string &name, const std::string &ip);
29 void on_joinplayer(ServerActiveObject *player, s64 last_login);
30 void on_leaveplayer(ServerActiveObject *player, bool timeout);
31 void on_cheat(ServerActiveObject *player, const std::string &cheat_type);
33 float time_from_last_punch, const ToolCapabilities *toolcap,
34 v3f dir, s32 damage);
36 s32 on_player_hpchange(ServerActiveObject *player, s32 hp_change,
37 const PlayerHPChangeReason &reason);
39 const std::string &formname, const StringMap &fields);
40 void on_authplayer(const std::string &name, const std::string &ip, bool is_success);
41
42 // Player inventory callbacks
43 // Return number of accepted items to be moved
45 const MoveAction &ma, int count,
46 ServerActiveObject *player);
47 // Return number of accepted items to be put
49 const MoveAction &ma, const ItemStack &stack,
50 ServerActiveObject *player);
51 // Return number of accepted items to be taken
53 const MoveAction &ma, const ItemStack &stack,
54 ServerActiveObject *player);
55 // Report moved items
57 const MoveAction &ma, int count,
58 ServerActiveObject *player);
59 // Report put items
61 const MoveAction &ma, const ItemStack &stack,
62 ServerActiveObject *player);
63 // Report taken items
65 const MoveAction &ma, const ItemStack &stack,
66 ServerActiveObject *player);
67private:
69 const char *method, const InventoryLocation &loc,
70 const std::string &listname, int index, const ItemStack &stack,
71 ServerActiveObject *player);
72 void pushMoveArguments(const MoveAction &ma,
73 int count, ServerActiveObject *player);
74};
static v2f dir(const v2f &pos_dist)
Definition camera.cpp:191
Definition s_base.h:64
Definition s_player.h:19
void on_joinplayer(ServerActiveObject *player, s64 last_login)
Definition s_player.cpp:151
void player_inventory_OnPut(const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
Definition s_player.cpp:347
s32 on_player_hpchange(ServerActiveObject *player, s32 hp_change, const PlayerHPChangeReason &reason)
Definition s_player.cpp:81
virtual ~ScriptApiPlayer()=default
void player_inventory_OnMove(const MoveAction &ma, int count, ServerActiveObject *player)
Definition s_player.cpp:334
int player_inventory_AllowMove(const MoveAction &ma, int count, ServerActiveObject *player)
Definition s_player.cpp:289
bool on_prejoinplayer(const std::string &name, const std::string &ip, std::string *reason)
Definition s_player.cpp:118
void on_dieplayer(ServerActiveObject *player, const PlayerHPChangeReason &reason)
Definition s_player.cpp:27
bool on_punchplayer(ServerActiveObject *player, ServerActiveObject *hitter, float time_from_last_punch, const ToolCapabilities *toolcap, v3f dir, s32 damage)
Definition s_player.cpp:43
bool can_bypass_userlimit(const std::string &name, const std::string &ip)
Definition s_player.cpp:138
void pushPutTakeArguments(const char *method, const InventoryLocation &loc, const std::string &listname, int index, const ItemStack &stack, ServerActiveObject *player)
Definition s_player.cpp:265
void on_leaveplayer(ServerActiveObject *player, bool timeout)
Definition s_player.cpp:167
void on_newplayer(ServerActiveObject *player)
Definition s_player.cpp:15
void on_playerReceiveFields(ServerActiveObject *player, const std::string &formname, const StringMap &fields)
Definition s_player.cpp:197
int player_inventory_AllowPut(const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
Definition s_player.cpp:304
void on_cheat(ServerActiveObject *player, const std::string &cheat_type)
Definition s_player.cpp:181
void on_rightclickplayer(ServerActiveObject *player, ServerActiveObject *clicker)
Definition s_player.cpp:68
void on_authplayer(const std::string &name, const std::string &ip, bool is_success)
Definition s_player.cpp:224
void pushMoveArguments(const MoveAction &ma, int count, ServerActiveObject *player)
Definition s_player.cpp:239
int player_inventory_AllowTake(const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
Definition s_player.cpp:319
bool on_respawnplayer(ServerActiveObject *player)
Definition s_player.cpp:105
void player_inventory_OnTake(const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
Definition s_player.cpp:360
Definition serveractiveobject.h:41
core::vector3df v3f
Definition irr_v3d.h:11
std::unordered_map< std::string, std::string > StringMap
Definition string.h:65
Definition inventorymanager.h:18
Definition inventory.h:19
Definition inventorymanager.h:128
Definition player_sao.h:227
Definition tool.h:46