Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
|
01-30-2012
, 21:54
overkill, losing negative points?
|
#1
|
I have a heavily modified version of the overkill version available on these forums, here is my overkill code, the problem with it is the new feature I added, when the numbers become too large, you beging to lose negative values, meaning you are getting points when you should be losing them.
PHP Code:
public overkill()
{
if (!get_pcvar_num(amx_overkill))
return PLUGIN_CONTINUE
new killerid = read_data(1)
new victimid = read_data(2)
new victimname[32]
get_user_name(victimid,victimname,31)
if( (killerid == 0 ) || (victimid == 0) || (killerid == victimid ) )
return PLUGIN_CONTINUE
//users should already connected and killer should be alive... duh.. >< just check for safety
if(!is_user_connected(victimid))
return PLUGIN_CONTINUE
//Reward if it's a teamkill?
if (get_user_team(killerid) == get_user_team(victimid) && !get_pcvar_num(amx_ok_ff))
return PLUGIN_CONTINUE
g_health[victimid] = 100
new Float:hp = float(get_user_health(victimid) * -1)
if (!hp)
return PLUGIN_CONTINUE
new Float:rewardhp,Float:temp,Float:reward_cap = float(get_pcvar_num(amx_ok_reward_cap)),Float:perc = get_pcvar_num(amx_ok_perc) / 100.0,Float:perc_capped = get_pcvar_num(amx_ok_perc_capped) / 100.0,Float:tempperc
new inloop = 1
while (inloop)
{
if (hp <= reward_cap) {
temp = hp * perc
inloop = 0
}
else {
temp = reward_cap * perc
hp -= reward_cap
tempperc = perc
perc = perc - perc_capped
//client_print(killerid,print_chat,"perc %d hp %d",perc,hp)
if (perc < 0) {
tempperc = perc_capped + perc
temp += tempperc * hp
inloop=0
//client_print(killerid,print_chat,"in loop perc < 0 **perc=%d",perc)
}
}
rewardhp += temp
}
new Float:maxreward = float(get_pcvar_num(amx_ok_max))
if (maxreward)
rewardhp = rewardhp > maxreward ? maxreward : rewardhp
new Float:health = float(get_user_health(killerid))
health += rewardhp
new Float:life_cap = float(get_pcvar_num(amx_ok_life_cap))
if (life_cap)
health = health > life_cap ? life_cap : health
if(is_user_alive(killerid))
{
if(g_health[killerid] == life_cap)
{
client_print(killerid,print_chat, "[OK] Could not gain any more life, you are capped! (%d)",floatround(life_cap))
}
else
{
g_health[killerid] = (floatround(health))
set_user_health(killerid,floatround(health))
client_print(killerid, print_chat, "[OK] +%dhp!",floatround(rewardhp))
}
}
if(get_pcvar_num(amx_ok_bb_enable))
{
get_user_name(victimid,victimname,31)
new healthtransfer = g_bhealth[victimid]/2
if(healthtransfer < 1)
healthtransfer = 1
new healthloss =((g_bhealth[victimid]*10) / (25))
if(get_pcvar_num(amx_ok_bb_cap_override))
{
g_bhealth[victimid] -= healthloss
g_bhealth[killerid] += healthtransfer
client_print(killerid,print_chat,"[OK] (%d) +%d blood for killing %s.",g_bhealth[killerid],healthtransfer,victimname)
client_print(victimid,print_chat,"[OK] (%d) -%d blood.",g_bhealth[victimid],healthloss)
DisplayHud(victimid)
DisplayHud(killerid)
}
else if(!get_pcvar_num(amx_ok_bb_cap_override))
{
if((g_bhealth[killerid] + healthtransfer) <= (get_pcvar_num(amx_ok_bb_cap)))
{
g_bhealth[victimid] -= healthloss
g_bhealth[killerid] += healthtransfer
client_print(killerid,print_chat,"[OK] (%d) +%d blood for killing %s.",g_bhealth[killerid],healthtransfer,victimname)
client_print(victimid,print_chat,"[OK] (%d) -%d blood.",g_bhealth[victimid],healthloss)
DisplayHud(victimid)
DisplayHud(killerid)
}
else
{
g_bhealth[killerid] = (get_pcvar_num(amx_ok_bb_cap))
client_print(killerid,print_chat,"[OK] You could not gain any more Blood, because your current bank is full(%d)!",(get_pcvar_num(amx_ok_bb_cap)))
g_bhealth[victimid] -= healthloss
g_bhealth[killerid] = (get_pcvar_num(amx_ok_bb_cap))
client_print(victimid,print_chat,"[OK] (%d) -%d blood.",g_bhealth[victimid],healthloss)
DisplayHud(victimid)
DisplayHud(killerid)
}
}
}
return PLUGIN_CONTINUE
}
and here is the fragment of the code that is in need of attention from above.
PHP Code:
if(get_pcvar_num(amx_ok_bb_enable))
{
get_user_name(victimid,victimname,31)
new healthtransfer = g_bhealth[victimid]/2
if(healthtransfer < 1)
healthtransfer = 1
new healthloss =((g_bhealth[victimid]*10) / (25))
if(get_pcvar_num(amx_ok_bb_cap_override))
{
g_bhealth[victimid] -= healthloss
g_bhealth[killerid] += healthtransfer
client_print(killerid,print_chat,"[OK] (%d) +%d blood for killing %s.",g_bhealth[killerid],healthtransfer,victimname)
client_print(victimid,print_chat,"[OK] (%d) -%d blood.",g_bhealth[victimid],healthloss)
DisplayHud(victimid)
DisplayHud(killerid)
}
else if(!get_pcvar_num(amx_ok_bb_cap_override))
{
if((g_bhealth[killerid] + healthtransfer) <= (get_pcvar_num(amx_ok_bb_cap)))
{
g_bhealth[victimid] -= healthloss
g_bhealth[killerid] += healthtransfer
client_print(killerid,print_chat,"[OK] (%d) +%d blood for killing %s.",g_bhealth[killerid],healthtransfer,victimname)
client_print(victimid,print_chat,"[OK] (%d) -%d blood.",g_bhealth[victimid],healthloss)
DisplayHud(victimid)
DisplayHud(killerid)
}
else
{
g_bhealth[killerid] = (get_pcvar_num(amx_ok_bb_cap))
client_print(killerid,print_chat,"[OK] You could not gain any more Blood, because your current bank is full(%d)!",(get_pcvar_num(amx_ok_bb_cap)))
g_bhealth[victimid] -= healthloss
g_bhealth[killerid] = (get_pcvar_num(amx_ok_bb_cap))
client_print(victimid,print_chat,"[OK] (%d) -%d blood.",g_bhealth[victimid],healthloss)
DisplayHud(victimid)
DisplayHud(killerid)
}
}
}
I don't believe I have left out any majorly needed calls or functions or globals, but if you need more information please let me know so I can add it in hopes that I can get help with this, because I am stuck on this problem :/
__________________
|
|