mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-24 13:55:36 +03:00
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
|
#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[] = {
|
AMX_NATIVE_INFO base_Natives[] = {
|
||||||
{ "ts_getwpnname", get_weapon_name },
|
{ "ts_getwpnname", get_weapon_name },
|
||||||
{ "ts_getwpnlogname", get_weapon_logname },
|
{ "ts_getwpnlogname", get_weapon_logname },
|
||||||
@ -357,6 +381,8 @@ AMX_NATIVE_INFO base_Natives[] = {
|
|||||||
|
|
||||||
{ "ts_setpddata",ts_setup },
|
{ "ts_setpddata",ts_setup },
|
||||||
|
|
||||||
|
{ "register_forward",register_forward },
|
||||||
|
|
||||||
//"*******************"
|
//"*******************"
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
@ -320,13 +320,13 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg
|
|||||||
int TA = 0;
|
int TA = 0;
|
||||||
if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) )
|
if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) )
|
||||||
TA = 1;
|
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() )
|
if ( pVic->IsAlive() )
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
pAtt->saveKill(pVic,weapon,( aim == 1 ) ? 1:0 ,TA);
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,8 @@ CPlayer players[33];
|
|||||||
bool is_theonemode;
|
bool is_theonemode;
|
||||||
bool rankBots;
|
bool rankBots;
|
||||||
|
|
||||||
int iFDeath;
|
Forward g_death_info;
|
||||||
int iFDamage;
|
Forward g_damage_info;
|
||||||
|
|
||||||
int gKnifeOffset;
|
int gKnifeOffset;
|
||||||
|
|
||||||
@ -311,9 +311,6 @@ void FN_AMXX_ATTACH() {
|
|||||||
void FN_AMXX_Detach() {
|
void FN_AMXX_Detach() {
|
||||||
g_rank.clear();
|
g_rank.clear();
|
||||||
g_rank.unloadCalc();
|
g_rank.unloadCalc();
|
||||||
}
|
g_damage_info.clear();
|
||||||
|
g_death_info.clear();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#define FN_AMXX_DETTACH OnAmxxDettach
|
#define FN_AMXX_DETTACH OnAmxxDettach
|
||||||
// All plugins loaded
|
// All plugins loaded
|
||||||
// Do forward functions init here (MF_RegisterForward)
|
// Do forward functions init here (MF_RegisterForward)
|
||||||
#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
|
//#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
|
||||||
|
|
||||||
/**** METAMOD ****/
|
/**** METAMOD ****/
|
||||||
// If your module doesn't use metamod, you may close the file now :)
|
// 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 is_theonemode;
|
||||||
extern bool rankBots;
|
extern bool rankBots;
|
||||||
|
|
||||||
extern int iFDeath;
|
extern Forward g_death_info;
|
||||||
extern int iFDamage;
|
extern Forward g_damage_info;
|
||||||
|
|
||||||
struct weapon_t {
|
struct weapon_t {
|
||||||
bool melee; //
|
bool melee; //
|
||||||
|
@ -146,7 +146,7 @@ void Client_TSHealth_End(void* mValue){
|
|||||||
if ( weaponData[weapon].melee )
|
if ( weaponData[weapon].melee )
|
||||||
pAttacker->saveShot(weapon);
|
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() )
|
if ( mPlayer->IsAlive() )
|
||||||
return;
|
return;
|
||||||
@ -217,7 +217,7 @@ void Client_TSHealth_End(void* mValue){
|
|||||||
}
|
}
|
||||||
|
|
||||||
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA);
|
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