mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-24 13:55:36 +03:00
forwards change
This commit is contained in:
parent
ed7b584b49
commit
3c99a32272
@ -276,3 +276,43 @@ void CPlayer::killPlayer(){
|
||||
pEdict->v.weapons = 0;
|
||||
}
|
||||
|
||||
// *****************************************************
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
@ -184,5 +184,27 @@ 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
|
||||
|
||||
|
@ -391,6 +391,30 @@ static cell AMX_NATIVE_CALL TFC_UserKill(AMX *amx, cell *params){ // player,wid
|
||||
return 1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Native list.
|
||||
AMX_NATIVE_INFO base_Natives[] = {
|
||||
{"tfc_setmodel", TFC_SetModel},
|
||||
@ -406,6 +430,8 @@ AMX_NATIVE_INFO base_Natives[] = {
|
||||
{"tfc_userkill" , TFC_UserKill},
|
||||
|
||||
{"tfc_setpddata", TFC_SetPDdata },
|
||||
|
||||
{"register_forward",register_forward },
|
||||
//******************* 19 :)
|
||||
{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;
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ int gmsgAmmoPickup;
|
||||
int mState;
|
||||
int mPlayerIndex;
|
||||
|
||||
int iFDamage;
|
||||
int iFDeath;
|
||||
Forward g_death_info;
|
||||
Forward g_damage_info;
|
||||
|
||||
RankSystem g_rank;
|
||||
Grenades g_grenades;
|
||||
@ -353,9 +353,6 @@ void FN_AMXX_Detach() {
|
||||
g_grenades.clear();
|
||||
g_rank.clear();
|
||||
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_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
|
||||
// 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 :)
|
||||
|
@ -81,8 +81,8 @@ extern CPlayer* mPlayer;
|
||||
extern int mPlayerIndex;
|
||||
extern int mState;
|
||||
|
||||
extern int iFDamage;
|
||||
extern int iFDeath;
|
||||
extern Forward g_death_info;
|
||||
extern Forward g_damage_info;
|
||||
|
||||
//extern int gmsgCurWeapon;
|
||||
//extern int gmsgDamage;
|
||||
|
@ -225,11 +225,11 @@ 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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user