mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2025-01-12 14:58:06 +03:00
added client_score forward
This commit is contained in:
parent
4c202dadb0
commit
c5d7417f8e
@ -367,6 +367,14 @@ void Forward::exec(int p1,int p2,int p3,int p4,int p5){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Forward::exec(int p1,int p2,int p3){
|
||||||
|
AmxCall* a = head;
|
||||||
|
while ( a ){
|
||||||
|
MF_AmxExec(a->amx, NULL, a->iFunctionIdx, 3,p1, p2, p3);
|
||||||
|
a = a->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Forward::exec(int p1,int p2){
|
void Forward::exec(int p1,int p2){
|
||||||
AmxCall* a = head;
|
AmxCall* a = head;
|
||||||
while ( a ){
|
while ( a ){
|
||||||
|
@ -74,11 +74,14 @@ public:
|
|||||||
int current;
|
int current;
|
||||||
int wpnModel;
|
int wpnModel;
|
||||||
|
|
||||||
int savedScore;
|
float savedScore;
|
||||||
|
int lastScore;
|
||||||
|
int sendScore;
|
||||||
|
|
||||||
bool ingame;
|
bool ingame;
|
||||||
bool bot;
|
bool bot;
|
||||||
float clearStats;
|
float clearStats;
|
||||||
|
float clearRound;
|
||||||
|
|
||||||
struct PlayerWeapon : public Stats {
|
struct PlayerWeapon : public Stats {
|
||||||
char* name;
|
char* name;
|
||||||
@ -178,6 +181,7 @@ public:
|
|||||||
void put( AMX *a , int i );
|
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,int p6);
|
||||||
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,int p3);
|
||||||
void exec(int p1,int p2);
|
void exec(int p1,int p2);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -205,11 +205,19 @@ 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;
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
if( MF_AmxFindPublic(amx, "client_score", &iFunctionIndex) == AMX_ERR_NONE )
|
||||||
|
g_score_info.put( amx , iFunctionIndex );
|
||||||
|
else
|
||||||
|
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,11 +81,13 @@ extern int gmsgPTeam;
|
|||||||
|
|
||||||
extern Forward g_death_info;
|
extern Forward g_death_info;
|
||||||
extern Forward g_damage_info;
|
extern Forward g_damage_info;
|
||||||
|
extern Forward g_score_info;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
extern int iFDamage;
|
extern int iFDamage;
|
||||||
extern int iFDeath;
|
extern int iFDeath;
|
||||||
|
extern int iFScore;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -51,11 +51,13 @@ int AxisScore;
|
|||||||
|
|
||||||
Forward g_death_info;
|
Forward g_death_info;
|
||||||
Forward g_damage_info;
|
Forward g_damage_info;
|
||||||
|
Forward g_score_info;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int iFDamage;
|
int iFDamage;
|
||||||
int iFDeath;
|
int iFDeath;
|
||||||
|
int iFScore;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -152,16 +154,32 @@ void PlayerPreThink_Post( edict_t *pEntity ) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||||
|
if ( !pPlayer->ingame )
|
||||||
|
return;
|
||||||
|
|
||||||
if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time && pPlayer->ingame){
|
if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time){
|
||||||
|
|
||||||
if ( !ignoreBots(pEntity) ){
|
if ( !ignoreBots(pEntity) ){
|
||||||
pPlayer->clearStats = 0.0f;
|
pPlayer->clearStats = 0.0f;
|
||||||
pPlayer->rank->updatePosition( &pPlayer->life );
|
pPlayer->rank->updatePosition( &pPlayer->life );
|
||||||
pPlayer->restartStats(false);
|
pPlayer->restartStats(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pPlayer->clearRound && pPlayer->clearRound < gpGlobals->time){
|
||||||
|
pPlayer->clearRound = 0.0f;
|
||||||
|
memset(&pPlayer->round,0,sizeof(pPlayer->round));
|
||||||
|
memset(pPlayer->weaponsRnd,0,sizeof(pPlayer->weaponsRnd));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pPlayer->sendScore && pPlayer->sendScore < gpGlobals->time){
|
||||||
|
pPlayer->sendScore = 0.0f;
|
||||||
|
#ifdef FORWARD_OLD_SYSTEM
|
||||||
|
g_score_info.exec( pPlayer->index, pPlayer->lastScore, pPlayer->savedScore );
|
||||||
|
#else
|
||||||
|
MF_ExecuteForward( iFScore,pPlayer->index, pPlayer->lastScore, pPlayer->savedScore );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +201,7 @@ void ServerDeactivate() {
|
|||||||
|
|
||||||
g_damage_info.clear();
|
g_damage_info.clear();
|
||||||
g_death_info.clear();
|
g_death_info.clear();
|
||||||
|
g_score_info.clear();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -398,7 +417,7 @@ void OnAmxxDetach() {
|
|||||||
void OnPluginsLoaded(){
|
void OnPluginsLoaded(){
|
||||||
iFDeath = MF_RegisterForward("client_death",ET_IGNORE,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);
|
||||||
iFDamage = MF_RegisterForward("client_damage",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);
|
||||||
|
iFScore = MF_RegisterForward("client_score",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,8 +42,7 @@ void Client_RoundState(void* mValue){
|
|||||||
for (int i=1;i<=gpGlobals->maxClients;i++){
|
for (int i=1;i<=gpGlobals->maxClients;i++){
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||||
if (pPlayer->ingame) {
|
if (pPlayer->ingame) {
|
||||||
memset(&pPlayer->round,0,sizeof(pPlayer->round));
|
pPlayer->clearRound = gpGlobals->time + 0.25f;
|
||||||
memset(pPlayer->weaponsRnd,0,sizeof(pPlayer->weaponsRnd));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,18 +69,18 @@ void Client_TeamScore(void* mValue){
|
|||||||
|
|
||||||
void Client_ObjScore(void* mValue){
|
void Client_ObjScore(void* mValue){
|
||||||
static CPlayer *pPlayer;
|
static CPlayer *pPlayer;
|
||||||
static int TMScore; //total map score :-)
|
static int score;
|
||||||
switch(mState++){
|
switch(mState++){
|
||||||
case 0:
|
case 0:
|
||||||
pPlayer = GET_PLAYER_POINTER_I(*(int*)mValue);
|
pPlayer = GET_PLAYER_POINTER_I(*(int*)mValue);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
TMScore = *(int*)mValue;
|
score = *(int*)mValue;
|
||||||
int score = TMScore - pPlayer->savedScore;
|
if ( (pPlayer->lastScore = score - pPlayer->savedScore) && isModuleActive() ){
|
||||||
if ( score && isModuleActive() ){
|
pPlayer->updateScore(pPlayer->current,pPlayer->lastScore);
|
||||||
pPlayer->updateScore(pPlayer->current,score);
|
pPlayer->sendScore = gpGlobals->time + 0.25f;
|
||||||
}
|
}
|
||||||
pPlayer->savedScore = TMScore;
|
pPlayer->savedScore = score;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user