Raised This Month: $ Target: $400
 0% 

put in the plugins <nvault> save system


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-19-2012 , 10:24   Re: put in the plugins <nvault> save system
Reply With Quote #6

PHP Code:
#include <amxmodx>
#include <engine>
#include <nvault>
#include <hamsandwich>

#define MAX_PLAYERS 32

new bool:gSpawned[MAX_PLAYERS 1];
new 
Float:gRoundDamage[MAX_PLAYERS 1];
new 
Float:gTotalDamage[MAX_PLAYERS 1];
new 
gRoundsPlayed[MAX_PLAYERS 1];

new 
gMaxPlayers;

#define GetADR(%1) (gTotalDamage[%1] / gRoundsPlayed[%1])

new gVault;

public 
plugin_init() {
    
register_clcmd("say /adr""CmdShowAverage");
    
    
register_event("HLTV""EventNewRound""a""1=0""2=0");
    
    
RegisterHam(Ham_Spawn"player""FwdPlayerSpawnPost"1);
    
RegisterHam(Ham_TakeDamage"player""FwdPlayerDamagePost"1);
    
    
gMaxPlayers get_maxplayers();
    
    
gVault nvault_open("adr_stats");
}

public 
plugin_end() {
    
nvault_close(gVault);
}

public 
client_authorized(id) {
    
    new 
steamID[35];
    
get_user_authid(idsteamIDcharsmax(steamID));
    
    new 
data[64], timestamp;
    if(
nvault_lookup(gVaultsteamIDdatacharsmax(data), timestamp)) {
        new 
roundsPlayed[12];
        
strbreak(dataroundsPlayedcharsmax(roundsPlayed), datacharsmax(data));
        
        
gRoundsPlayed[id] = str_to_num(roundsPlayed);
        
gTotalDamage[id] = str_to_float(data);
    }
}

public 
client_disconnect(id) {
    
gSpawned[id] = false;
    
    new 
steamID[35];
    
get_user_authid(idsteamIDcharsmax(steamID));
    
    new 
data[64];
    
formatex(datacharsmax(data), "%d %f"gRoundsPlayed[id], gTotalDamage[id]);
    
    
nvault_set(gVaultsteamIDdata);
    
    
gRoundDamage[id] = 0.0;
    
gTotalDamage[id] = 0.0;
    
gRoundsPlayed[id] = 0;
}

public 
CmdShowAverage(id) {
    
client_print(idprint_chat"* Your average damage per round is %.1f"GetADR(id));
}

public 
EventNewRound() {
    for(new 
id 1id <= gMaxPlayersid++) {
        if(
gRoundDamage[id] > 0.0) {
            
gTotalDamage[id] += gRoundDamage[id];
            
gRoundDamage[id] = 0.0;
            
            
gRoundsPlayed[id]++;
        }
        else if(
gSpawned[id]) {
            
gRoundsPlayed[id]++;
        }
        
        
gSpawned[id] = false;
    }
}

public 
FwdPlayerSpawnPost(id) {
    if(
is_user_alive(id)) {
        
gSpawned[id] = true;
    }
}

public 
FwdPlayerDamagePost(victiminflictorattackerFloat:damagedamageBits) {
    if(
<= attacker <= gMaxPlayers && attacker != victim) {
        
gRoundDamage[attacker] += entity_get_float(victimEV_FL_dmg_take);
    }

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode