How can it be HP steal if the player is dead?
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <crxranks>
#include <fun>
#include <hamsandwich>
#define PLUGIN_VERSION "1.0"
new Trie:g_tHealth
new Trie:g_tHealthHS
public plugin_init()
{
register_plugin("CRXRanks: Health on Kill", PLUGIN_VERSION, "OciXCrom")
register_cvar("CRXRanksHPOnKill", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
register_event("DeathMsg", "OnPlayerKilled", "a")
}
public plugin_cfg()
{
g_tHealth = TrieCreate()
g_tHealthHS = TrieCreate()
ReadFile()
}
public plugin_end()
{
TrieDestroy(g_tHealth)
TrieDestroy(g_tHealthHS)
}
ReadFile()
{
new szConfigsName[256], szFilename[256]
get_configsdir(szConfigsName, charsmax(szConfigsName))
formatex(szFilename, charsmax(szFilename), "%s/RankSystemHealthOnKill.ini", szConfigsName)
new iFilePointer = fopen(szFilename, "rt")
if(iFilePointer)
{
new szData[64], szValue[16], szValue2[8], szMap[32], szKey[32], bool:bRead = true, iSize
get_mapname(szMap, charsmax(szMap))
while(!feof(iFilePointer))
{
fgets(iFilePointer, szData, charsmax(szData))
trim(szData)
switch(szData[0])
{
case EOS, '#', ';': continue
case '-':
{
iSize = strlen(szData)
if(szData[iSize - 1] == '-')
{
szData[0] = ' '
szData[iSize - 1] = ' '
trim(szData)
if(contain(szData, "*") != -1)
{
strtok(szData, szKey, charsmax(szKey), szValue, charsmax(szValue), '*')
copy(szValue, strlen(szKey), szMap)
bRead = equal(szValue, szKey) ? true : false
}
else
{
static const szAll[] = "#all"
bRead = equal(szData, szAll) || equali(szData, szMap)
}
}
else continue
}
default:
{
if(!bRead)
continue
strtok(szData, szKey, charsmax(szKey), szValue, charsmax(szValue), '=')
trim(szKey); trim(szValue)
if(!szValue[0])
continue
parse(szValue, szValue, charsmax(szValue), szValue2, charsmax(szValue2))
TrieSetCell(g_tHealth, szKey, str_to_num(szValue))
TrieSetCell(g_tHealthHS, szKey, str_to_num(szValue2))
}
}
}
fclose(iFilePointer)
}
}
public OnPlayerKilled()
{
new iAttacker = read_data(1), iVictim = read_data(2)
if(is_user_connected(iAttacker) && iAttacker != iVictim)
{
new szLevel[8], iLevel = crxranks_get_user_level(iAttacker)
num_to_str(iLevel, szLevel, charsmax(szLevel))
new iHealth
TrieGetCell(read_data(3) ? g_tHealthHS : g_tHealth, szLevel, iHealth)
set_user_health(iAttacker, get_user_health(iAttacker) + iHealth)
}
}
Example RankSystemHealthOnKill.ini:
PHP Code:
#======================================================#
# CRXRanks: Health On Kill Configuration file #
#======================================================#
# This plugin requires OciXCrom's Rank System to work #
#======================================================#
# Add each health amount on a new line following the format:
# <level number> = <health on normal kill> <health on headshot>
1 = 0 0
2 = 1 2
3 = 2 3
4 = 5 10
__________________