HLPlayer: Difference between revisions
Jump to navigation
Jump to search
m (moved Python HLPlayer to HLPlayer) |
No edit summary |
||
Line 2: | Line 2: | ||
<source lang=cpp> | <source lang=cpp> | ||
#include <boost/python.hpp> | |||
namespace bp = boost::python; | |||
BOOST_PYTHON_MODULE(HLPlayer) | BOOST_PYTHON_MODULE(HLPlayer) | ||
{ | { | ||
Line 7: | Line 10: | ||
void (CBasePlayer::*CommitSuicideFP)(bool, bool) = &CBasePlayer::CommitSuicide; | void (CBasePlayer::*CommitSuicideFP)(bool, bool) = &CBasePlayer::CommitSuicide; | ||
class_<CBasePlayer, bases<CBaseEntity> , boost::noncopyable>("CBasePlayer", no_init) | bp::class_<CBasePlayer, bp::bases<CBaseEntity> , boost::noncopyable>("CBasePlayer", bp::no_init) | ||
.def("DeathCount", &CBasePlayer::DeathCount) | .def("DeathCount", &CBasePlayer::DeathCount) | ||
.def("ArmorValue", &CBasePlayer::ArmorValue) | .def("ArmorValue", &CBasePlayer::ArmorValue) | ||
Line 15: | Line 18: | ||
.def("GetHealth", &CBasePlayer::GetHealth); | .def("GetHealth", &CBasePlayer::GetHealth); | ||
class_<CHL2_Player, bases<CBasePlayer>, boost::noncopyable >("CHL2_Player", no_init) | bp::class_<CHL2_Player, bp::bases<CBasePlayer>, boost::noncopyable >("CHL2_Player", bp::no_init) | ||
.def("Weapon_Switch", &CHL2_Player::Weapon_Switch); | .def("Weapon_Switch", &CHL2_Player::Weapon_Switch); | ||
} | } |
Revision as of 03:51, 4 September 2009
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);
}