AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Doesn't want to count. (https://forums.alliedmods.net/showthread.php?t=208718)

Randomize 02-16-2013 21:27

Doesn't want to count.
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <hamsandwich>

#define PLUGIN "Kill Counter"
#define VERSION "1.0"
#define AUTHOR "DavidJr"

new PlayerKill[33];
new 
Kill;

new 
PlayerHeadshot[33];
new 
HeadshotSaveHeadshot;

new 
PlayerDeath[33];
new 
Death;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
Kill register_cvar("kill""1");
    
    
SaveHeadshot register_cvar("save_headshot""1");
    
Headshot register_cvar("headshot""1");
    
    
Death register_cvar("death""1");
    
    
RegisterHam(Ham_Killed"player""death"1// 0 = before death 1 = after  
    
register_event("DeathMsg""kill""a");
    
    
register_clcmd("say /rank""ShowHud");
    
register_clcmd("say_team /rank""ShowHud");
}
public 
kill()
{
    new 
Killer read_data(1)
    new 
hs read_data(3)
    new 
weapon[32]
    
read_data(4weapon31)
    
    
PlayerKill[Killer] += get_pcvar_num(Kill);
    
    if (
hs) {
        if (
get_pcvar_num(SaveHeadshot))
            
PlayerKill[Killer] += get_pcvar_num(Headshot);
    }
    
write_ini_from_plugin(Killer)]
}
public 
death(victimattackershouldgib)
{
    new 
victim read_data(2)
    
    
PlayerDeath[victim] += get_pcvar_num(Death);
    
    
write_ini_from_plugin(victim)
}
public 
write_ini_from_plugin(id){
    new 
path[128]
    
get_configsdir(pathcharsmax(path))
    
format(pathcharsmax(path), "%s/%s"path"status.ini")
    
    if (!
file_exists(path))
    {
        
write_file(path"", -1)
    }
    
    new 
linedata[100]
    
format(linedata,charsmax(linedata),"[status]")
    
write_file(pathlinedata0)
    
format(linedata,charsmax(linedata),"kill=%d",PlayerKill[id])
    
write_file(pathlinedata1)
    
format(linedata,charsmax(linedata),"headshot=%d",PlayerHeadshot[id])
    
write_file(pathlinedata2)
    
format(linedata,charsmax(linedata),"death=%d",PlayerDeath[id])
    
write_file(pathlinedata3)
}

public 
ShowHud(id){
    
set_hudmessage(2552552550.00.9006.03.00.01.0, -1)
    
show_hudmessage(id"Kill: %i, HS: %i, Death: %i",PlayerKill[id],PlayerHeadshot[id],PlayerDeath[id])


The code only work for Death, not Kill or Headshot, did I miss something?

Napoleon_be 02-17-2013 10:32

Re: Doesn't want to count.
 
If you're using hamsandwich, don't use the DeathMsg event and the Ham_Killed function. Just use the Ham_Killed function and that will do.

Also check if the killer is a player.


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

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