Raised This Month: $ Target: $400
 0% 

[REQ] Need someone to create this small easy plugin regarding knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Klatypaus
Member
Join Date: Jan 2015
Old 05-27-2015 , 10:25   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #1

Quote:
Originally Posted by nnajko View Post
This should work...
You also need nVault Utility

It updates the top once every map.

PHP Code:
#include <amxmodx>
#include <nvault>
#include <nvault_util>

const MAXPLAYERS 32;

new 
knife_kills[MAXPLAYERS 1];

new 
top_player_kills[10];
new 
top_player_names[10][35];

new 
nvault_file;
new 
total_entries;

public 
plugin_init() 
{
    
register_plugin("Knife Top 10""1.0""dnk.");
    
    
register_event("DeathMsg""eventDeath""a");
    
    
register_concmd("say /knife10""commandTop10");
    
register_concmd("say_team /knife10""commandTop10");
    
    
nvault_file nvault_open("KnifeTop");
    
    if( 
nvault_file == INVALID_HANDLE )
    {
        
set_fail_state("Could not load nvault");
    }
    
    
total_entries loadTop();
}

public 
client_connect(id)
{
    if( 
is_player(id) )
        
playerLoad(id);
}

public 
client_disconnect(id)
{
    if( 
is_player(id) )
        
playerSave(id);
}

public 
eventDeath()
{
    new 
killer read_data(0);
    new 
victim read_data(1);
    
    if( 
is_player(killer) && is_player(victim) )
    {
        new 
weapon[32];
        
read_data(4weaponcharsmax(weapon));
        
        if( 
equal(weapon"knife") )
        {
            if( 
get_user_team(killer) != get_user_team(victim) )
            {
                
knife_kills[killer]++;
            }
        }
    }
}

public 
commandTop10(id)
{
    new 
html[2500], len;
    
len copy(htmlcharsmax(html), "<html><body><h2>Top 10</h2><br><table><tr><th>#.</th><th>Name</th><th>Kills</th></tr>");
    
    for( new 
010i++ )
    {
        if( 
total_entries )
        {
            
len += formatex(html[len], charsmax(html) - len"<tr><td>%i.</td><td>%s</td><td>%i</td></tr>", (1), top_player_names[i], top_player_kills[i]);
        }
        else
        {
            
len += copy(html[len], charsmax(html) - len"<tr><td></td><td></td><td></td></tr>");
        }
    }
    
    
len += copy(html[len], charsmax(html) - len"</table></body></html>");
    
    
show_motd(idhtml"Top 10");
    
    return 
PLUGIN_HANDLED;
}

public 
loadTop()
{
    new Array:
array_kills ArrayCreate(1);
    new Array:
array_names ArrayCreate(35);
    
    new 
vault_file nvault_util_open("KnifeTop");
    new 
vault_count nvault_util_count(vault_file);
    new 
position;
    new 
steam[35], timestampdata[128];
    for( new 
0vault_counti++ )
    {
        
position nvault_util_read(vault_filepositionsteamcharsmax(steam), datacharsmax(data), timestamp);
        
        new 
num[5];
        
strbreak(datanumcharsmax(num), datacharsmax(data));
        
ArrayPushCell(array_killsstr_to_num(num));
        
replace_all(datacharsmax(data), " """);
        
ArrayPushString(array_namesdata);
    }
    
    
nvault_util_close(vault_file);
    
    new 
kills;
    for( new 
0j< (vault_count 1); i++ )
    {
        
kills ArrayGetCell(array_killsi);
        
        for( 
1vault_countj++ )
        {
            if( 
kills ArrayGetCell(array_killsj) )
            {
                
ArraySwap(array_killsij);
                
ArraySwap(array_namesij);
                
i--;
                break;
            }
        }
    }
    
    for( new 
010i++ )
    {
        if( 
vault_count )
        {
            
top_player_kills[i] = ArrayGetCell(array_killsi);
            new 
name[35];
            
ArrayGetString(array_namesinamecharsmax(name));
            
top_player_names[i] = name;
        }
    }
    
    return 
vault_count;
}

public 
playerSave(id)
{
    new 
steamid[35], value[128], name[35];
    
get_user_authid(idsteamidcharsmax(steamid));
    
get_user_name(idnamecharsmax(name));
    
replace_all(namecharsmax(name), "&""&amp;");
    
replace_all(namecharsmax(name), "<""&lt;");
    
replace_all(namecharsmax(name), ">""&gt;");
    
formatex(valuecharsmax(value), "%i %s"knife_kills[id], name);
    
nvault_set(nvault_filesteamidvalue);
}

public 
playerLoad(id)
{
    new 
steamid[35], data[128];
    
get_user_authid(idsteamidcharsmax(steamid));
    if( 
nvault_get(nvault_filesteamiddatacharsmax(data)) )
    {
        static 
num[5];
        
strbreak(datanumcharsmax(num), datacharsmax(data));
        
knife_kills[id] = str_to_num(num);
    }
    else
    {
        
knife_kills[id] = 0;
    }
}

bool:is_player(id)
{
    return (
<= id <= MAXPLAYERS);

thank you for the effort , but could you make it that it updates every round like in csstats... thanks alot though but I will need the top knife killers to be updated every round
Klatypaus is offline
xxxperts
Senior Member
Join Date: Oct 2013
Location: India
Old 05-29-2015 , 04:47   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #2

Quote:
Originally Posted by Klatypaus View Post
thank you for the effort , but could you make it that it updates every round like in csstats... thanks alot though but I will need the top knife killers to be updated every round
i think that can't be done with nvault.
__________________
All my work is here
xxxperts is offline
Klatypaus
Member
Join Date: Jan 2015
Old 05-31-2015 , 06:02   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #3

Quote:
Originally Posted by xxxperts View Post
i think that can't be done with nvault.
ok but any other way? Because we rarely change the map on my server and also live updates of the top knifers will be better
Klatypaus is offline
Reply



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 20:21.


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