AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [REQ] Need someone to create this small easy plugin regarding knife (https://forums.alliedmods.net/showthread.php?t=263204)

Klatypaus 05-20-2015 17:21

[REQ] Need someone to create this small easy plugin regarding knife
 
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

^SmileY 05-20-2015 17:28

Re: [REQ] Need someone to create this small easy plugin regarding knife
 
I guess that you can use csstats to do that, i will try to help you later.

xxxperts 05-21-2015 06:42

Re: [REQ] Need someone to create this small easy plugin regarding knife
 
i have made something like this before, if i found that i will post it.

Klatypaus 05-21-2015 11:20

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

Originally Posted by ^SmileY (Post 2299073)
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 (Post 2299235)
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 05-23-2015 11:23

Re: [REQ] Need someone to create this small easy plugin regarding knife
 
anybody?

xxxperts 05-23-2015 12:31

Re: [REQ] Need someone to create this small easy plugin regarding knife
 
i have question for you, how would you like to save your data.?,

i mean by name or steam id.?

^SmileY 05-23-2015 14:31

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

Originally Posted by xxxperts (Post 2300166)
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.

Klatypaus 05-25-2015 06:10

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

Originally Posted by xxxperts (Post 2300166)
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

nnajko 05-26-2015 16:31

Re: [REQ] Need someone to create this small easy plugin regarding knife
 
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);



Klatypaus 05-27-2015 10:25

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

Originally Posted by nnajko (Post 2301359)
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


All times are GMT -4. The time now is 20:21.

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