added client_score forward

This commit is contained in:
Lukasz Wlasinksi 2004-09-08 18:09:01 +00:00
parent 4c202dadb0
commit c5d7417f8e
6 changed files with 56 additions and 16 deletions

View File

@ -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){
AmxCall* a = head;
while ( a ){

View File

@ -74,11 +74,14 @@ public:
int current;
int wpnModel;
int savedScore;
float savedScore;
int lastScore;
int sendScore;
bool ingame;
bool bot;
float clearStats;
float clearRound;
struct PlayerWeapon : public Stats {
char* name;
@ -178,6 +181,7 @@ public:
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,int p3);
void exec(int p1,int p2);
};
#endif

View File

@ -205,11 +205,19 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
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:
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
#endif
return 1;
}

View File

@ -81,11 +81,13 @@ extern int gmsgPTeam;
extern Forward g_death_info;
extern Forward g_damage_info;
extern Forward g_score_info;
#else
extern int iFDamage;
extern int iFDeath;
extern int iFScore;
#endif

View File

@ -51,11 +51,13 @@ int AxisScore;
Forward g_death_info;
Forward g_damage_info;
Forward g_score_info;
#else
int iFDamage;
int iFDeath;
int iFScore;
#endif
@ -152,16 +154,32 @@ void PlayerPreThink_Post( edict_t *pEntity ) {
return;
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if ( !pPlayer->ingame )
return;
if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time && pPlayer->ingame){
if ( !ignoreBots(pEntity) ){
pPlayer->clearStats = 0.0f;
pPlayer->rank->updatePosition( &pPlayer->life );
pPlayer->restartStats(false);
if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time){
if ( !ignoreBots(pEntity) ){
pPlayer->clearStats = 0.0f;
pPlayer->rank->updatePosition( &pPlayer->life );
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);
}
@ -183,6 +201,7 @@ void ServerDeactivate() {
g_damage_info.clear();
g_death_info.clear();
g_score_info.clear();
#endif
@ -398,7 +417,7 @@ void OnAmxxDetach() {
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);
iFScore = MF_RegisterForward("client_score",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL,FP_DONE);
}
#endif

View File

@ -42,8 +42,7 @@ void Client_RoundState(void* mValue){
for (int i=1;i<=gpGlobals->maxClients;i++){
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->ingame) {
memset(&pPlayer->round,0,sizeof(pPlayer->round));
memset(pPlayer->weaponsRnd,0,sizeof(pPlayer->weaponsRnd));
pPlayer->clearRound = gpGlobals->time + 0.25f;
}
}
}
@ -70,18 +69,18 @@ void Client_TeamScore(void* mValue){
void Client_ObjScore(void* mValue){
static CPlayer *pPlayer;
static int TMScore; //total map score :-)
static int score;
switch(mState++){
case 0:
pPlayer = GET_PLAYER_POINTER_I(*(int*)mValue);
break;
case 1:
TMScore = *(int*)mValue;
int score = TMScore - pPlayer->savedScore;
if ( score && isModuleActive() ){
pPlayer->updateScore(pPlayer->current,score);
score = *(int*)mValue;
if ( (pPlayer->lastScore = score - pPlayer->savedScore) && isModuleActive() ){
pPlayer->updateScore(pPlayer->current,pPlayer->lastScore);
pPlayer->sendScore = gpGlobals->time + 0.25f;
}
pPlayer->savedScore = TMScore;
pPlayer->savedScore = score;
break;
}
}