AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [RESOLVED]deathmsg victim, never encountered? (https://forums.alliedmods.net/showthread.php?t=126501)

HLM 05-10-2010 02:59

[RESOLVED]deathmsg victim, never encountered?
 
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 == ) || (victimid == 0) )
        return 
PLUGIN_CONTINUE
    
if( (killerid == victimid ) )
        return 
PLUGIN_CONTINUE
    
    
//users should already connected and killer should be alive... duh.. >< just check for safety
    
if (!is_user_alive(killerid) || !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(killeridprint_chat"[OK] +%dhp!",floatround(rewardhp))
        }
    }
    if(
get_pcvar_num(amx_ok_bb_enable))
    {
        if(
killerid != victimid)
        {
            
get_user_name(victimid,victimname,31)
            new 
healthtransfer g_bhealth[victimid]/2
            
if(healthtransfer 1)
                
healthtransfer 1
            
new healthloss g_bhealth[victimid]/4
            
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)))
            }
        }
    }
    else if(
get_cvar_num("amx_ok_bb_enable") == 0)
    {
        
client_print(killerid,print_chat,"[OK] No blood rewarded, because blood bank is disabled")
        
    }
    return 
PLUGIN_CONTINUE 


nothing ever happens to player "victimid" it acts as if its not a real index, im confused

HLM 05-10-2010 03:24

Re: deathmsg victim, never encountered?
 
self resolved, removed the check, if user killerid was not alive, returning plugin_continue

Code:

if (!is_user_alive(killerid) || !is_user_connected(victimid))
        return PLUGIN_CONTINUE

EDIT: still open, temporary fix, it isnt lasting :(

edit2: fixed, in my else case, I wasnt subtracting lifeloss if the player was dying


All times are GMT -4. The time now is 03:37.

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