Skip to content

Commit c1290fd

Browse files
committed
Exported more property and functions from IClient.
1 parent aa6f457 commit c1290fd

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

src/core/modules/players/players_wrap.cpp

100644100755
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ void export_client(scope _players)
219219
{
220220
class_<IClient, IClient*, bases<INetChannelHandler>, boost::noncopyable> Client("Client", no_init);
221221

222+
Client.add_property(
223+
"slot",
224+
&IClient::GetPlayerSlot,
225+
"Return the client's slot.(usually entity number-1)"
226+
);
227+
222228
Client.add_property(
223229
"name",
224230
&IClient::GetClientName,
@@ -248,6 +254,52 @@ void export_client(scope _players)
248254
&IClientExt::Disconnect
249255
);
250256

257+
Client.def("is_connected",
258+
&IClient::IsConnected,
259+
"Return True if client has established network channels."
260+
);
261+
262+
Client.def("is_spawned",
263+
&IClient::IsSpawned,
264+
"Return True if client is downloading signon data."
265+
);
266+
267+
Client.def("is_active",
268+
&IClient::IsActive,
269+
"Return True if client active is ingame, receiving snapshots."
270+
);
271+
272+
Client.def("is_fake_client",
273+
&IClient::IsFakeClient,
274+
"Return True if client is not a real player."
275+
);
276+
277+
Client.def("is_hltv",
278+
&IClient::IsHLTV,
279+
"Return True if client is a HLTV proxy."
280+
);
281+
282+
Client.def("is_human_player",
283+
#if defined(ENGINE_BLADE) || defined(ENGINE_CSGO) || defined(ENGINE_LEFT4DEAD2)
284+
&IClient::IsHumanPlayer,
285+
#else
286+
&IClientExt::IsHumanPlayer,
287+
#endif
288+
"Return True if client is not a fake client and is not a HLTV proxy."
289+
);
290+
291+
Client.def("is_hearing_client",
292+
&IClient::IsHearingClient,
293+
"Return True if client hears this player.",
294+
args("index")
295+
);
296+
297+
Client.def("is_proximity_hearing_client",
298+
&IClient::IsProximityHearingClient,
299+
"Return True if client hears this player by proximity.",
300+
args("index")
301+
);
302+
251303
// TODO: Export more
252304

253305
Client ADD_MEM_TOOLS(IClient);

src/core/modules/players/players_wrap.h

100644100755
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ class IClientExt
7676
make_tuple(ptr(pClient), reason)
7777
);
7878
}
79+
80+
#if !defined(ENGINE_BLADE) && !defined(ENGINE_CSGO) && !defined(ENGINE_LEFT4DEAD2)
81+
static bool IsHumanPlayer(IClient* pClient)
82+
{
83+
if (!pClient->IsConnected() || pClient->IsFakeClient() || pClient->IsHLTV())
84+
return false;
85+
86+
return true;
87+
}
88+
#endif
7989
};
8090

8191

0 commit comments

Comments
 (0)