register_statsfwd
This commit is contained in:
parent
2a57fa02ca
commit
afce6de801
|
@ -70,8 +70,17 @@ native custom_wpn_shot( index,wid );
|
|||
native get_custom_wpnname( wId,name[],len );
|
||||
|
||||
/*
|
||||
* Usefull forwards
|
||||
* Forwards
|
||||
*/
|
||||
|
||||
forward grenade_throw( index,greindex,wId );
|
||||
|
||||
enum {
|
||||
CSF_DAMAGE = 0,
|
||||
CSF_DEATH,
|
||||
}
|
||||
|
||||
/* You must register client_* forwards using register_statsfwd native */
|
||||
native register_statsfwd( ftype )
|
||||
forward client_damage( attacker,victim,damage,wpnindex,hitplace,TA );
|
||||
forward client_death( killer,victim,wpnindex,hitplace,TK );
|
||||
forward grenade_throw( index,greindex,wId );
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#include <amxmodx>
|
||||
#include <csstats>
|
||||
|
||||
public plugin_init() {
|
||||
register_plugin("Stats Test","0.1","SidLuke")
|
||||
register_statsfwd( CSF_DAMAGE )
|
||||
register_statsfwd( CSF_DEATH )
|
||||
}
|
||||
|
||||
public client_damage( attacker,victim,damage,wpnindex,hitplace,TA ){
|
||||
|
|
|
@ -243,6 +243,49 @@ void CPlayer::saveBDefused(){
|
|||
}
|
||||
|
||||
|
||||
// *****************************************************
|
||||
// class Forward
|
||||
// *****************************************************
|
||||
|
||||
void Forward::put( AMX *a , int i ){
|
||||
head = new AmxCall( a, i , head );
|
||||
}
|
||||
|
||||
|
||||
void Forward::clear(){
|
||||
while ( head ) {
|
||||
AmxCall* a = head->next;
|
||||
delete head;
|
||||
head = a;
|
||||
}
|
||||
}
|
||||
|
||||
void Forward::exec(int p1,int p2,int p3,int p4,int p5,int p6){
|
||||
AmxCall* a = head;
|
||||
while ( a ){
|
||||
MF_AmxExec(a->amx, NULL, a->iFunctionIdx, 6,p1, p2, p3, p4, p5, p6);
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
|
||||
void Forward::exec(int p1,int p2,int p3,int p4,int p5){
|
||||
AmxCall* a = head;
|
||||
while ( a ){
|
||||
MF_AmxExec(a->amx, NULL, a->iFunctionIdx, 5,p1, p2, p3, p4, p5);
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
|
||||
void Forward::exec(int p1,int p2){
|
||||
AmxCall* a = head;
|
||||
while ( a ){
|
||||
MF_AmxExec(a->amx, NULL, a->iFunctionIdx, 2,p1, p2);
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************
|
||||
|
||||
bool ignoreBots (edict_t *pEnt, edict_t *pOther){
|
||||
if ( !rankBots && ( pEnt->v.flags & FL_FAKECLIENT || ( pOther && pOther->v.flags & FL_FAKECLIENT ) ) )
|
||||
return true;
|
||||
|
|
|
@ -87,6 +87,28 @@ public:
|
|||
void clear();
|
||||
};
|
||||
|
||||
// *****************************************************
|
||||
// class Forward
|
||||
// *****************************************************
|
||||
|
||||
class Forward
|
||||
{
|
||||
struct AmxCall {
|
||||
AMX *amx;
|
||||
int iFunctionIdx;
|
||||
AmxCall* next;
|
||||
AmxCall( AMX *a , int i, AmxCall* n ): amx(a), iFunctionIdx(i), next(n) {}
|
||||
} *head;
|
||||
public:
|
||||
Forward() { head = 0; }
|
||||
~Forward() { clear(); }
|
||||
void clear();
|
||||
void put( AMX *a , int i );
|
||||
void exec(int p1,int p2,int p3,int p4,int p5,int p6);
|
||||
void exec(int p1,int p2,int p3,int p4,int p5);
|
||||
void exec(int p1,int p2);
|
||||
};
|
||||
|
||||
#endif // CMISC_H
|
||||
|
||||
|
||||
|
|
|
@ -21,8 +21,9 @@ RankSystem g_rank;
|
|||
|
||||
Grenades g_grenades;
|
||||
|
||||
int iFDeath;
|
||||
int iFDamage;
|
||||
Forward g_death_info;
|
||||
Forward g_damage_info;
|
||||
|
||||
int iFGrenade;
|
||||
|
||||
bool rankBots;
|
||||
|
@ -141,9 +142,14 @@ void ServerDeactivate() {
|
|||
g_rank.clear(); // clear before save to file
|
||||
}
|
||||
g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("csstats")) );
|
||||
|
||||
g_damage_info.clear();
|
||||
g_death_info.clear();
|
||||
|
||||
// clear custom weapons info
|
||||
for ( i=MAX_WEAPONS;i<MAX_WEAPONS+MAX_CWEAPONS;i++)
|
||||
weaponData[i].ammoSlot = 0;
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
|
@ -327,7 +333,5 @@ void OnAmxxDetach() {
|
|||
}
|
||||
|
||||
void OnPluginsLoaded(){
|
||||
iFDamage = MF_RegisterForward("client_damage",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
|
||||
iFDeath = MF_RegisterForward("client_death",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
|
||||
iFGrenade = MF_RegisterForward("grenade_throw",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
|
||||
}
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
// Module info
|
||||
#define MODULE_NAME "CS Stats"
|
||||
#define MODULE_VERSION "0.1"
|
||||
#define MODULE_AUTHOR ""
|
||||
#define MODULE_URL "www.amxmodx.org"
|
||||
#define MODULE_VERSION "0.20"
|
||||
#define MODULE_AUTHOR "AMXx Dev Team"
|
||||
#define MODULE_URL "http://www.amxmodx.org/"
|
||||
#define MODULE_LOGTAG "CSSTATS"
|
||||
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
|
||||
#define MODULE_RELOAD_ON_MAPCHANGE
|
||||
|
|
|
@ -339,13 +339,13 @@ static cell AMX_NATIVE_CALL custom_wpn_dmg(AMX *amx, cell *params){ // wid,att,v
|
|||
int TA = 0;
|
||||
if ( (pVic->teamId == pAtt->teamId) && ( pVic != pAtt) )
|
||||
TA = 1;
|
||||
MF_ExecuteForward( iFDamage, pAtt->index, pVic->index, dmg, weapon, aim, TA );
|
||||
g_damage_info.exec( pAtt->index, pVic->index, dmg, weapon, aim, TA );
|
||||
|
||||
if ( pVic->IsAlive() )
|
||||
return 1;
|
||||
|
||||
pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA);
|
||||
MF_ExecuteForward( iFDeath, pAtt->index, pVic->index, weapon, aim, TA );
|
||||
g_death_info.exec( pAtt->index, pVic->index, weapon, aim, TA );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -380,6 +380,30 @@ static cell AMX_NATIVE_CALL get_custom_wpnname(AMX *amx, cell *params){
|
|||
return MF_SetAmxString(amx,params[2],weaponData[id].name,params[3]);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
|
||||
int iFunctionIndex;
|
||||
switch( params[1] ){
|
||||
case 0:
|
||||
if( MF_AmxFindPublic(amx, "client_damage", &iFunctionIndex) == AMX_ERR_NONE )
|
||||
g_damage_info.put( amx , iFunctionIndex );
|
||||
else
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
break;
|
||||
case 1:
|
||||
if( MF_AmxFindPublic(amx, "client_death", &iFunctionIndex) == AMX_ERR_NONE )
|
||||
g_death_info.put( amx , iFunctionIndex );
|
||||
else
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
break;
|
||||
default:
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO stats_Natives[] = {
|
||||
{ "get_stats", get_stats},
|
||||
{ "get_stats2", get_stats2},
|
||||
|
@ -400,6 +424,8 @@ AMX_NATIVE_INFO stats_Natives[] = {
|
|||
{ "custom_wpn_shot", custom_wpn_shot },
|
||||
{ "get_custom_wpnname", get_custom_wpnname },
|
||||
|
||||
{"register_statsfwd",register_forward },
|
||||
|
||||
///*******************
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
|
|
@ -26,8 +26,9 @@ extern bool rankBots;
|
|||
extern cvar_t* csstats_rankbots;
|
||||
extern cvar_t* csstats_pause;
|
||||
|
||||
extern int iFDeath;
|
||||
extern int iFDamage;
|
||||
extern Forward g_death_info;
|
||||
extern Forward g_damage_info;
|
||||
|
||||
extern int iFGrenade;
|
||||
|
||||
extern weaponsVault weaponData[MAX_WEAPONS+MAX_CWEAPONS];
|
||||
|
|
|
@ -90,11 +90,12 @@ void Client_Damage_End(void* mValue){
|
|||
TA = 0;
|
||||
if ( (mPlayer->teamId == pAttacker->teamId) && (mPlayer != pAttacker) )
|
||||
TA = 1;
|
||||
MF_ExecuteForward( iFDamage, pAttacker->index, mPlayer->index, damage, weapon, aim, TA );
|
||||
|
||||
g_damage_info.exec( pAttacker->index , mPlayer->index , damage, weapon, aim, TA );
|
||||
|
||||
if ( !mPlayer->IsAlive() ){
|
||||
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA);
|
||||
MF_ExecuteForward( iFDeath, pAttacker->index, mPlayer->index, weapon, aim, TA );
|
||||
g_death_info.exec( pAttacker->index, mPlayer->index, weapon, aim, TA );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +149,6 @@ void Client_AmmoPickup(void* mValue){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void Client_ScoreInfo(void* mValue){
|
||||
static int index;
|
||||
switch (mState++){
|
||||
|
|
|
@ -219,7 +219,7 @@ AMX_NATIVE_INFO base_Natives[] = {
|
|||
{ "dod_user_kill", user_kill },
|
||||
{ "dod_get_pronestate", get_user_pronestate },
|
||||
|
||||
{"register_forward",register_forward },
|
||||
{"register_statsfwd",register_forward },
|
||||
|
||||
///*******************
|
||||
{ NULL, NULL }
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
// Module info
|
||||
#define MODULE_NAME "DoDX"
|
||||
#define MODULE_VERSION "0.1"
|
||||
#define MODULE_VERSION "0.20"
|
||||
#define MODULE_AUTHOR "SidLuke"
|
||||
#define MODULE_URL "www.amxmodx.org"
|
||||
#define MODULE_URL "http://www.amxmodx.org/"
|
||||
#define MODULE_LOGTAG "DODX"
|
||||
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
|
||||
#define MODULE_RELOAD_ON_MAPCHANGE
|
||||
|
|
|
@ -431,7 +431,7 @@ AMX_NATIVE_INFO base_Natives[] = {
|
|||
|
||||
{"tfc_setpddata", TFC_SetPDdata },
|
||||
|
||||
{"register_forward",register_forward },
|
||||
{"register_statsfwd",register_forward },
|
||||
//******************* 19 :)
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
// Module info
|
||||
#define MODULE_NAME "TFCX"
|
||||
#define MODULE_VERSION "0.1"
|
||||
#define MODULE_AUTHOR "SidLuke"
|
||||
#define MODULE_URL "www.amxmodx.org"
|
||||
#define MODULE_VERSION "0.20"
|
||||
#define MODULE_AUTHOR "AMXx Dev Team"
|
||||
#define MODULE_URL "http://www.amxmodx.org/"
|
||||
#define MODULE_LOGTAG "TFCX"
|
||||
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
|
||||
#define MODULE_RELOAD_ON_MAPCHANGE
|
||||
|
|
|
@ -381,7 +381,7 @@ AMX_NATIVE_INFO base_Natives[] = {
|
|||
|
||||
{ "ts_setpddata",ts_setup },
|
||||
|
||||
{ "register_forward",register_forward },
|
||||
{ "register_statsfwd",register_forward },
|
||||
|
||||
//"*******************"
|
||||
{ NULL, NULL }
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
// Module info
|
||||
#define MODULE_NAME "TSX"
|
||||
#define MODULE_VERSION "0.1"
|
||||
#define MODULE_AUTHOR "SidLuke"
|
||||
#define MODULE_URL "www.amxmodx.org"
|
||||
#define MODULE_VERSION "0.2"
|
||||
#define MODULE_AUTHOR "AMXx Dev Team"
|
||||
#define MODULE_URL "http://www.amxmodx.org/"
|
||||
#define MODULE_LOGTAG "TSX"
|
||||
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
|
||||
#define MODULE_RELOAD_ON_MAPCHANGE
|
||||
|
|
Loading…
Reference in New Issue
Block a user