Нашол здесь тутор.Зделал как написано,токо вот компилица с ошибками может есть ошибки в коде?
"Killing Monsters: How to Award Points to Players"
В combat.cpp, найдите:
C++ Source Code:
1
void CBaseMonster :: Killed( entvars_t *pevAttacker, int iGib )
2
{
3
unsignedint cCount = 0;
4
BOOL fDone = FALSE;
5
if ( HasMemory( bits_MEMORY_KILLED ) )
6
{
7
if ( ShouldGibMonster( iGib ) )
8
CallGibMonster();
9
return;
10
}
11
Remember( bits_MEMORY_KILLED );
// Now add this NEW CODE ----------------------------------
// Main points indicated in boldface - see details below
CBaseEntity *ep = CBaseEntity::Instance( pevAttacker );
if ( ep && ep->Classify() == CLASS_PLAYER )
{
CBasePlayer *PK = (CBasePlayer*)ep;
if (FClassnameIs(pev, "monster_hornet")) {/* no points for hornets*/}
else if (FClassnameIs(pev, "monster_alien_controller"))
{
UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s got the drop on %s ... \n",
( pevAttacker->netname && STRING(pevAttacker->netname)[0] != 0 ) ? STRING(pevAttacker->netname) : "unconnected" ), STRING(pev->classname));
PK->AddPoints(5, false);
}
else if (FClassnameIs(pev, "monster_alien_grunt"))
{
UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s eliminated %s ... \n",
( pevAttacker->netname && STRING(pevAttacker->netname)[0] != 0 ) ? STRING(pevAttacker->netname) : "unconnected" ),
STRING(pev->classname));
PK->AddPoints(5, false);
}
else if (FClassnameIs(pev, "monster_alien_slave"))
// ETC ETC. ... check as many different monsters as you like
Else { }
}
Main Points:
Instance::(pevAttacker) ... who is the attacker that killed this monster?
Classify() == CLASS_PLAYER ... is the attacker a player?
*PK ... a pointer to the player who is the attacker
FClassNameIs(pev, "monster_whatever") ... is the Class Name of pev (the killed monster) equal to "monster_whatever"?
UTIL_ClientPrintAll ... prints HUD message to all players -- e.g. "Player_Whoever got the drop on Monster_Whatever"
PK->AddPoints(x,false) ... adds x points to the killer's frag count
Else{ } ... empty default for the end, catch anything that doesn't fit the defined class names