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-20-2015 , 17:21   [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #1

Please can someone make a plugin which ranks players based on their knife kills, like with a cvar /knife10 which will show the top 10 knife killers. Thanks you guys in Advance
Klatypaus is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 05-20-2015 , 17:28   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #2

I guess that you can use csstats to do that, i will try to help you later.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
xxxperts
Senior Member
Join Date: Oct 2013
Location: India
Old 05-21-2015 , 06:42   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #3

i have made something like this before, if i found that i will post it.
__________________
All my work is here
xxxperts is offline
Klatypaus
Member
Join Date: Jan 2015
Old 05-21-2015 , 11:20   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #4

Quote:
Originally Posted by ^SmileY View Post
I guess that you can use csstats to do that, i will try to help you later.
Yes please thank you

Quote:
Originally Posted by xxxperts View Post
i have made something like this before, if i found that i will post it.
I have searched alot but I still havent found it yet :/
Klatypaus is offline
Klatypaus
Member
Join Date: Jan 2015
Old 05-23-2015 , 11:23   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #5

anybody?
Klatypaus is offline
xxxperts
Senior Member
Join Date: Oct 2013
Location: India
Old 05-23-2015 , 12:31   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #6

i have question for you, how would you like to save your data.?,

i mean by name or steam id.?
__________________
All my work is here
xxxperts is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 05-23-2015 , 14:31   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #7

Quote:
Originally Posted by xxxperts View Post
i have question for you, how would you like to save your data.?,

i mean by name or steam id.?
Man, se statsx that have rank by weapon. Only needs to retrive top knife killers at motd.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Klatypaus
Member
Join Date: Jan 2015
Old 05-25-2015 , 06:10   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #8

Quote:
Originally Posted by xxxperts View Post
i have question for you, how would you like to save your data.?,

i mean by name or steam id.?
Steamid will be better and unique
Klatypaus is offline
nnajko
Senior Member
Join Date: May 2009
Location: Sweden
Old 05-26-2015 , 16:31   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #9

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);


Last edited by nnajko; 05-26-2015 at 16:34.
nnajko is offline
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 #10

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
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