HLPlayer

From Valve Developer Community
(Redirected from Python HLPlayer)
Jump to navigation Jump to search
Wikipedia - Letter.png
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)
Dead End - Icon.png
This article has no Wikipedia icon links to other VDC articles. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024

This is the basic interface for hl2 players

#include <boost/python.hpp>
namespace bp = boost::python;

BOOST_PYTHON_MODULE(HLPlayer)
{
	//because CommitSuicide is overloaded we must tell it which one to use
	void (CBasePlayer::*CommitSuicideFP)(bool, bool) = &CBasePlayer::CommitSuicide;

	bp::class_<CBasePlayer, bp::bases<CBaseEntity> , boost::noncopyable>("CBasePlayer", bp::no_init)
		.def("DeathCount", &CBasePlayer::DeathCount)
		.def("ArmorValue", &CBasePlayer::ArmorValue)
		.def("ResetDeathCount", &CBasePlayer::ResetDeathCount)
		.def("CommitSuicide", CommitSuicideFP)
		.def("GetPlayerName", &CBasePlayer::GetPlayerName)
		.def("GetHealth", &CBasePlayer::GetHealth);

	bp::class_<CHL2_Player, bp::bases<CBasePlayer>, boost::noncopyable >("CHL2_Player", bp::no_init)
		.def("Weapon_Switch", &CHL2_Player::Weapon_Switch);
}