Raised This Month: $ Target: $400
 0% 

Saving ip's into nvault


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Santaaa
BANNED
Join Date: May 2012
Old 07-08-2012 , 00:30   Re: Saving ip's into nvault
Reply With Quote #8

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <colorchat>
#include <nvault>

#define PLUGIN "K/D Ratio"
#define VERSION "1.0"
#define AUTHOR "Santaa"

new const Prefix[] = "[Test]";

new 
Kills[33], Deaths[33]

new 
g_vault

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_vault nvault_open("KDRATIO")
    
    if (
g_vault == INVALID_HANDLE)
    {
        
set_fail_state("Error loading logs")
    }
    
    
register_clcmd("say /ratio""Showratio")
    
    
register_event("DeathMsg""eDeath""a")
}

public 
client_putinserver(id)
{
    
LoadData(id)
}

public 
client_disconnect(id)
{
    
SaveData(id)
}

public 
Showratio(id)
{
    new 
name[32]
    
get_user_name(idname31)
    
    new 
Float:Ratio float(Kills[id]) / float(Deaths[id])
    
    
ColorChat(idGREY"%s ^1You have ^4%i^1 kills, ^4%i^1 deaths, ratio: ^4%.2f"PrefixKills[id], Deaths[id], Ratio);
    
ColorChat(0GREY"%s ^4%s ^1has a ratio of: ^4%.2f"PrefixnameRatio);
}

public 
eDeath()
{
    new 
killer read_data(1)
    new 
victim read_data(2)
    
    
Kills[killer]++
    
    
Deaths[victim]++
}

public 
SaveData(id)
{
    new 
ip[46]
    
get_user_ip(idipcharsmax(ip), 1)
    
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-KDRATIO"ip)
    
format(vaultdata,255,"%i#%i#"Kills[id], Deaths[id])
    
nvault_set(g_vault,vaultkey,vaultdata)
    return 
PLUGIN_CONTINUE
}

public 
LoadData(id)
{
    new 
ip[46]
    
get_user_ip(idipcharsmax(ip), 1)
    
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-PointMod"ip)
    
format(vaultdata,255,"%i#%i#"Kills[id], Deaths[id])
    
nvault_get(g_vault,vaultkey,vaultdata,255)
    
    
replace_all(vaultdata255"#"" ")
    
    new 
kills[32], deaths[32]
    
    
parse(vaultdatakills31deaths31)
    
    
Kills[id] = str_to_num(kills)
    
Deaths[id] = str_to_num(deaths)
    
    return 
PLUGIN_CONTINUE

Santaaa 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 15:13.


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