AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   put in the plugins <nvault> save system (https://forums.alliedmods.net/showthread.php?t=187520)

jar_09 06-14-2012 10:26

put in the plugins <nvault> save system
 
...

Backstabnoob 06-14-2012 15:14

Re: put in the plugins <fvault> save system
 
Post in suggestions/requests.

jar_09 06-18-2012 19:05

Re: put in the plugins <fvault> save system
 
Quote:

Originally Posted by Backstabnoob (Post 1728782)
Post in suggestions/requests.

ok

some moderator could move the post to suggestions / requests please.

Napoleon_be 06-19-2012 09:04

Re: put in the plugins <nvault> save system
 
Just the define, or just the bool, floats and array? or both?

jar_09 06-19-2012 10:03

Re: put in the plugins <nvault> save system
 
Quote:

Originally Posted by Napoleon_be (Post 1731627)
Just the define, or just the bool, floats and array? or both?

would both, I want to save is the adr (GetADR (id)) of each player

Exolent[jNr] 06-19-2012 10:24

Re: put in the plugins <nvault> save system
 
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);
    }




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

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