Minetest 5.9.0-dev
 
Loading...
Searching...
No Matches
s_player.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5This program is free software; you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation; either version 2.1 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU Lesser General Public License for more details.
14
15You should have received a copy of the GNU Lesser General Public License along
16with this program; if not, write to the Free Software Foundation, Inc.,
1751 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18*/
19
20#pragma once
21
22#include "cpp_api/s_base.h"
23#include "irr_v3d.h"
24#include "util/string.h"
25
26struct MoveAction;
28struct ItemStack;
29struct ToolCapabilities;
32
33class ScriptApiPlayer : virtual public ScriptApiBase
34{
35public:
36 virtual ~ScriptApiPlayer() = default;
37
38 void on_newplayer(ServerActiveObject *player);
39 void on_dieplayer(ServerActiveObject *player, const PlayerHPChangeReason &reason);
41 bool on_prejoinplayer(const std::string &name, const std::string &ip,
42 std::string *reason);
43 bool can_bypass_userlimit(const std::string &name, const std::string &ip);
44 void on_joinplayer(ServerActiveObject *player, s64 last_login);
45 void on_leaveplayer(ServerActiveObject *player, bool timeout);
46 void on_cheat(ServerActiveObject *player, const std::string &cheat_type);
48 float time_from_last_punch, const ToolCapabilities *toolcap,
49 v3f dir, s32 damage);
51 s32 on_player_hpchange(ServerActiveObject *player, s32 hp_change,
52 const PlayerHPChangeReason &reason);
54 const std::string &formname, const StringMap &fields);
55 void on_authplayer(const std::string &name, const std::string &ip, bool is_success);
56
57 // Player inventory callbacks
58 // Return number of accepted items to be moved
60 const MoveAction &ma, int count,
61 ServerActiveObject *player);
62 // Return number of accepted items to be put
64 const MoveAction &ma, const ItemStack &stack,
65 ServerActiveObject *player);
66 // Return number of accepted items to be taken
68 const MoveAction &ma, const ItemStack &stack,
69 ServerActiveObject *player);
70 // Report moved items
72 const MoveAction &ma, int count,
73 ServerActiveObject *player);
74 // Report put items
76 const MoveAction &ma, const ItemStack &stack,
77 ServerActiveObject *player);
78 // Report taken items
80 const MoveAction &ma, const ItemStack &stack,
81 ServerActiveObject *player);
82private:
84 const char *method, const InventoryLocation &loc,
85 const std::string &listname, int index, const ItemStack &stack,
86 ServerActiveObject *player);
87 void pushMoveArguments(const MoveAction &ma,
88 int count, ServerActiveObject *player);
89};
static v2f dir(const v2f &pos_dist)
Definition: camera.cpp:204
Definition: s_base.h:79
Definition: s_player.h:34
void on_joinplayer(ServerActiveObject *player, s64 last_login)
Definition: s_player.cpp:166
void player_inventory_OnPut(const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
Definition: s_player.cpp:362
s32 on_player_hpchange(ServerActiveObject *player, s32 hp_change, const PlayerHPChangeReason &reason)
Definition: s_player.cpp:96
virtual ~ScriptApiPlayer()=default
void player_inventory_OnMove(const MoveAction &ma, int count, ServerActiveObject *player)
Definition: s_player.cpp:349
int player_inventory_AllowMove(const MoveAction &ma, int count, ServerActiveObject *player)
Definition: s_player.cpp:304
bool on_prejoinplayer(const std::string &name, const std::string &ip, std::string *reason)
Definition: s_player.cpp:133
void on_dieplayer(ServerActiveObject *player, const PlayerHPChangeReason &reason)
Definition: s_player.cpp:42
bool on_punchplayer(ServerActiveObject *player, ServerActiveObject *hitter, float time_from_last_punch, const ToolCapabilities *toolcap, v3f dir, s32 damage)
Definition: s_player.cpp:58
bool can_bypass_userlimit(const std::string &name, const std::string &ip)
Definition: s_player.cpp:153
void pushPutTakeArguments(const char *method, const InventoryLocation &loc, const std::string &listname, int index, const ItemStack &stack, ServerActiveObject *player)
Definition: s_player.cpp:280
void on_leaveplayer(ServerActiveObject *player, bool timeout)
Definition: s_player.cpp:182
void on_newplayer(ServerActiveObject *player)
Definition: s_player.cpp:30
void on_playerReceiveFields(ServerActiveObject *player, const std::string &formname, const StringMap &fields)
Definition: s_player.cpp:212
int player_inventory_AllowPut(const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
Definition: s_player.cpp:319
void on_cheat(ServerActiveObject *player, const std::string &cheat_type)
Definition: s_player.cpp:196
void on_rightclickplayer(ServerActiveObject *player, ServerActiveObject *clicker)
Definition: s_player.cpp:83
void on_authplayer(const std::string &name, const std::string &ip, bool is_success)
Definition: s_player.cpp:239
void pushMoveArguments(const MoveAction &ma, int count, ServerActiveObject *player)
Definition: s_player.cpp:254
int player_inventory_AllowTake(const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
Definition: s_player.cpp:334
bool on_respawnplayer(ServerActiveObject *player)
Definition: s_player.cpp:120
void player_inventory_OnTake(const MoveAction &ma, const ItemStack &stack, ServerActiveObject *player)
Definition: s_player.cpp:375
Definition: serveractiveobject.h:55
core::vector3df v3f
Definition: irr_v3d.h:26
std::unordered_map< std::string, std::string > StringMap
Definition: string.h:78
Definition: inventorymanager.h:33
Definition: inventory.h:34
Definition: inventorymanager.h:143
Definition: player_sao.h:235
Definition: tool.h:61