dod_get_user_weapon added. Compile options for old/new forwards system
This commit is contained in:
parent
77c887d514
commit
8e23ca757a
|
@ -330,6 +330,8 @@ void CMapInfo::Init(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FORWARD_OLD_SYSTEM
|
||||||
|
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class Forward
|
// class Forward
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
@ -370,3 +372,5 @@ void Forward::exec(int p1,int p2){
|
||||||
a = a->next;
|
a = a->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -157,6 +157,8 @@ public:
|
||||||
void Init();
|
void Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef FORWARD_OLD_SYSTEM
|
||||||
|
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
// class Forward
|
// class Forward
|
||||||
// *****************************************************
|
// *****************************************************
|
||||||
|
@ -178,5 +180,6 @@ public:
|
||||||
void exec(int p1,int p2,int p3,int p4,int p5);
|
void exec(int p1,int p2,int p3,int p4,int p5);
|
||||||
void exec(int p1,int p2);
|
void exec(int p1,int p2);
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // CMISC_H
|
#endif // CMISC_H
|
|
@ -178,7 +178,29 @@ static cell AMX_NATIVE_CALL get_user_pronestate(AMX *amx, cell *params){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params){
|
||||||
|
int index = params[1];
|
||||||
|
if (index<1||index>gpGlobals->maxClients){
|
||||||
|
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||||
|
if (pPlayer->ingame){
|
||||||
|
int wpn = pPlayer->current;
|
||||||
|
cell *cpTemp = MF_GetAmxAddr(amx,params[2]);
|
||||||
|
*cpTemp = pPlayer->weapons[wpn].clip;
|
||||||
|
cpTemp = MF_GetAmxAddr(amx,params[3]);
|
||||||
|
*cpTemp = pPlayer->weapons[wpn].ammo;
|
||||||
|
return wpn;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
|
static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
|
||||||
|
|
||||||
|
#ifdef FORWARD_OLD_SYSTEM
|
||||||
|
|
||||||
int iFunctionIndex;
|
int iFunctionIndex;
|
||||||
switch( params[1] ){
|
switch( params[1] ){
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -199,6 +221,7 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
|
||||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,6 +237,7 @@ AMX_NATIVE_INFO base_Natives[] = {
|
||||||
{ "dod_get_user_score", get_user_score },
|
{ "dod_get_user_score", get_user_score },
|
||||||
{ "dod_get_user_class", get_user_class },
|
{ "dod_get_user_class", get_user_class },
|
||||||
{ "dod_get_user_team", get_user_team },
|
{ "dod_get_user_team", get_user_team },
|
||||||
|
{ "dod_get_user_weapon", get_user_weapon },
|
||||||
|
|
||||||
{ "dod_get_map_info", get_map_info },
|
{ "dod_get_map_info", get_map_info },
|
||||||
{ "dod_user_kill", user_kill },
|
{ "dod_user_kill", user_kill },
|
||||||
|
|
|
@ -383,13 +383,25 @@ 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;
|
||||||
|
|
||||||
|
#ifdef FORWARD_OLD_SYSTEM
|
||||||
g_damage_info.exec( pAtt->index, pVic->index, dmg, weapon, aim, TA );
|
g_damage_info.exec( pAtt->index, pVic->index, dmg, weapon, aim, TA );
|
||||||
|
#else
|
||||||
|
MF_ExecuteForward( iFDamage,pAtt->index, pVic->index, dmg, weapon, aim, TA );
|
||||||
|
#endif
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
#ifdef FORWARD_OLD_SYSTEM
|
||||||
g_death_info.exec( pAtt->index, pVic->index, weapon, aim, TA );
|
g_death_info.exec( pAtt->index, pVic->index, weapon, aim, TA );
|
||||||
|
#else
|
||||||
|
MF_ExecuteForward( iFDeath,pAtt->index, pVic->index, weapon, aim, TA );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,9 +73,19 @@ extern int AxisScore;
|
||||||
extern int gmsgScoreShort;
|
extern int gmsgScoreShort;
|
||||||
extern int gmsgPTeam;
|
extern int gmsgPTeam;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef FORWARD_OLD_SYSTEM
|
||||||
|
|
||||||
extern Forward g_death_info;
|
extern Forward g_death_info;
|
||||||
extern Forward g_damage_info;
|
extern Forward g_damage_info;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
extern int iFDamage;
|
||||||
|
extern int iFDeath;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
extern cvar_t* dodstats_maxsize;
|
extern cvar_t* dodstats_maxsize;
|
||||||
extern cvar_t* dodstats_rank;
|
extern cvar_t* dodstats_rank;
|
||||||
extern cvar_t* dodstats_reset;
|
extern cvar_t* dodstats_reset;
|
||||||
|
|
|
@ -47,9 +47,18 @@ int mPlayerIndex;
|
||||||
int AlliesScore;
|
int AlliesScore;
|
||||||
int AxisScore;
|
int AxisScore;
|
||||||
|
|
||||||
|
#ifdef FORWARD_OLD_SYSTEM
|
||||||
|
|
||||||
Forward g_death_info;
|
Forward g_death_info;
|
||||||
Forward g_damage_info;
|
Forward g_damage_info;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
int iFDamage;
|
||||||
|
int iFDeath;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
int gmsgCurWeapon;
|
int gmsgCurWeapon;
|
||||||
int gmsgHealth;
|
int gmsgHealth;
|
||||||
int gmsgResetHUD;
|
int gmsgResetHUD;
|
||||||
|
@ -164,9 +173,13 @@ void ServerDeactivate() {
|
||||||
|
|
||||||
g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("dodstats") ) );
|
g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("dodstats") ) );
|
||||||
|
|
||||||
|
#ifdef FORWARD_OLD_SYSTEM
|
||||||
|
|
||||||
g_damage_info.clear();
|
g_damage_info.clear();
|
||||||
g_death_info.clear();
|
g_death_info.clear();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// clear custom weapons info
|
// clear custom weapons info
|
||||||
for ( i=DODMAX_WEAPONS-DODMAX_CUSTOMWPNS;i<DODMAX_WEAPONS;i++)
|
for ( i=DODMAX_WEAPONS-DODMAX_CUSTOMWPNS;i<DODMAX_WEAPONS;i++)
|
||||||
weaponData[i].needcheck = false;
|
weaponData[i].needcheck = false;
|
||||||
|
@ -373,3 +386,13 @@ void OnAmxxDetach() {
|
||||||
g_grenades.clear();
|
g_grenades.clear();
|
||||||
g_rank.unloadCalc();
|
g_rank.unloadCalc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef FORWARD_OLD_SYSTEM
|
||||||
|
|
||||||
|
void OnPluginsLoaded(){
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
// metamod plugin?
|
// metamod plugin?
|
||||||
#define USE_METAMOD
|
#define USE_METAMOD
|
||||||
|
|
||||||
|
#define FORWARD_OLD_SYSTEM
|
||||||
|
|
||||||
// - AMXX Init functions
|
// - AMXX Init functions
|
||||||
// Also consider using FN_META_*
|
// Also consider using FN_META_*
|
||||||
// AMXX query
|
// AMXX query
|
||||||
|
@ -32,7 +34,10 @@
|
||||||
#define FN_AMXX_DETACH OnAmxxDetach
|
#define FN_AMXX_DETACH OnAmxxDetach
|
||||||
// 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
|
|
||||||
|
#ifndef FORWARD_OLD_SYSTEM
|
||||||
|
#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
|
||||||
|
#endif
|
||||||
|
|
||||||
/**** 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 :)
|
||||||
|
|
|
@ -97,7 +97,6 @@ void Client_CurWeapon(void* mValue){
|
||||||
case 1:
|
case 1:
|
||||||
if (!iState) break;
|
if (!iState) break;
|
||||||
iId = *(int*)mValue;
|
iId = *(int*)mValue;
|
||||||
mPlayer->current = iId;
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if ( !iState || !isModuleActive() )
|
if ( !iState || !isModuleActive() )
|
||||||
|
@ -106,6 +105,7 @@ void Client_CurWeapon(void* mValue){
|
||||||
|
|
||||||
if ( weaponData[iId].needcheck ){
|
if ( weaponData[iId].needcheck ){
|
||||||
iId = get_weaponid(mPlayer);
|
iId = get_weaponid(mPlayer);
|
||||||
|
mPlayer->current = iId;
|
||||||
}
|
}
|
||||||
if (iClip > -1) {
|
if (iClip > -1) {
|
||||||
if ( mPlayer->current == 17 ){
|
if ( mPlayer->current == 17 ){
|
||||||
|
@ -167,11 +167,22 @@ void Client_Health_End(void* mValue){
|
||||||
TA = 1;
|
TA = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FORWARD_OLD_SYSTEM
|
||||||
g_damage_info.exec( pAttacker->index, mPlayer->index, damage, weapon, aim, TA );
|
g_damage_info.exec( pAttacker->index, mPlayer->index, damage, weapon, aim, TA );
|
||||||
|
#else
|
||||||
|
MF_ExecuteForward( iFDamage,pAttacker->index, mPlayer->index, damage, weapon, aim, TA );
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( !mPlayer->IsAlive() ){
|
if ( !mPlayer->IsAlive() ){
|
||||||
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA);
|
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA);
|
||||||
|
|
||||||
|
#ifdef FORWARD_OLD_SYSTEM
|
||||||
g_death_info.exec( pAttacker->index, mPlayer->index, weapon, aim, TA );
|
g_death_info.exec( pAttacker->index, mPlayer->index, weapon, aim, TA );
|
||||||
|
#else
|
||||||
|
MF_ExecuteForward( iFDeath,pAttacker->index, mPlayer->index, weapon, aim, TA );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user