Floating-point math and integer math are two very different operations. This is why you have to tag your floating-point variable with "Float:". So, you are doing integer math on floating-point values which will corrupt the floating-point value.
You should do something like this:
PHP Code:
#include <amxmodx>
enum _: structStats
{
Float: statDamage,
statKills
}
new g_iStats[structStats];
new g_iStatsRound[structStats];
public plugin_init()
{
register_concmd("float_test", "commandTest")
}
public commandTest( iPlayerID )
{
console_print(iPlayerID, "[0] statDamage: %.2f - statKills: %d", g_iStats[statDamage], g_iStats[statKills]);
new szStat[2], szValue[12];
read_argv(1, szStat, charsmax(szStat));
read_argv(2, szValue, charsmax(szValue));
server_print("%s (%d) ... %s (%f)", szStat, str_to_num(szStat), szValue, str_to_float(szValue))
if (str_to_num(szStat) == 0)
{
AddDamage(str_to_float(szValue))
}
else
{
AddKills(str_to_num(szValue))
}
console_print(iPlayerID, "[1] statDamage: %.2f - statKills: %d", g_iStats[statDamage], g_iStats[statKills]);
}
stock AddKills(iKills)
{
g_iStats[statKills] += iKills;
g_iStatsRound[statKills] += iKills;
}
stock AddDamage(Float:fDamage)
{
g_iStats[statDamage] += fDamage;
g_iStatsRound[statDamage] += fDamage;
}
__________________