new(old) register forwards system
This commit is contained in:
parent
e0a9c60bf1
commit
e4a735d447
|
@ -198,3 +198,44 @@ void CPlayer::saveShot(int weapon){
|
|||
}
|
||||
|
||||
|
||||
// *****************************************************
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,4 +124,26 @@ struct CPlayer {
|
|||
}
|
||||
};
|
||||
|
||||
// *****************************************************
|
||||
// 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
|
|
@ -337,6 +337,30 @@ static cell AMX_NATIVE_CALL ts_setup(AMX *amx, cell *params){ // index,pwupentin
|
|||
|
||||
}
|
||||
|
||||
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 base_Natives[] = {
|
||||
{ "ts_getwpnname", get_weapon_name },
|
||||
{ "ts_getwpnlogname", get_weapon_logname },
|
||||
|
@ -357,6 +381,8 @@ AMX_NATIVE_INFO base_Natives[] = {
|
|||
|
||||
{ "ts_setpddata",ts_setup },
|
||||
|
||||
{ "register_forward",register_forward },
|
||||
|
||||
//"*******************"
|
||||
{ NULL, NULL }
|
||||
};
|
|
@ -320,13 +320,13 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg
|
|||
int TA = 0;
|
||||
if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( 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;
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ CPlayer players[33];
|
|||
bool is_theonemode;
|
||||
bool rankBots;
|
||||
|
||||
int iFDeath;
|
||||
int iFDamage;
|
||||
Forward g_death_info;
|
||||
Forward g_damage_info;
|
||||
|
||||
int gKnifeOffset;
|
||||
|
||||
|
@ -311,9 +311,6 @@ void FN_AMXX_ATTACH() {
|
|||
void FN_AMXX_Detach() {
|
||||
g_rank.clear();
|
||||
g_rank.unloadCalc();
|
||||
}
|
||||
|
||||
void FN_AMXX_PLUGINSLOADED(){
|
||||
iFDeath = MF_RegisterForward("client_death",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
|
||||
iFDamage = MF_RegisterForward("client_damage",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
|
||||
g_damage_info.clear();
|
||||
g_death_info.clear();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#define FN_AMXX_DETTACH OnAmxxDettach
|
||||
// All plugins loaded
|
||||
// Do forward functions init here (MF_RegisterForward)
|
||||
#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
|
||||
//#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
|
||||
|
||||
/**** METAMOD ****/
|
||||
// If your module doesn't use metamod, you may close the file now :)
|
||||
|
|
|
@ -90,8 +90,8 @@ extern int mState;
|
|||
extern bool is_theonemode;
|
||||
extern bool rankBots;
|
||||
|
||||
extern int iFDeath;
|
||||
extern int iFDamage;
|
||||
extern Forward g_death_info;
|
||||
extern Forward g_damage_info;
|
||||
|
||||
struct weapon_t {
|
||||
bool melee; //
|
||||
|
|
|
@ -146,7 +146,7 @@ void Client_TSHealth_End(void* mValue){
|
|||
if ( weaponData[weapon].melee )
|
||||
pAttacker->saveShot(weapon);
|
||||
|
||||
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() )
|
||||
return;
|
||||
|
@ -217,7 +217,7 @@ void Client_TSHealth_End(void* mValue){
|
|||
}
|
||||
|
||||
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA);
|
||||
MF_ExecuteForward( iFDeath, pAttacker->index, mPlayer->index, weapon, aim, killFlags, TA );
|
||||
g_death_info.exec( pAttacker->index, mPlayer->index, weapon, aim, killFlags, TA );
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user