Raised This Month: $ Target: $400
 0% 

[ZP] Regeneration: some bugs


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Freddy2304
Junior Member
Join Date: Dec 2006
Old 06-07-2010 , 09:18   Re: [ZP] Regeneration: some bugs
Reply With Quote #2

After 2 days of hard work, i was able to add the delay function and the 0hp/kill bug is more or less fixed.
It only occurs when a zombie were slayed or slaped till death (during regeneration)

Now I have 2 request:
- the code badly needs optimizations
- detection of slay and slap (or any other type of damage e.g. napalm grenades) so that the bug is fixed completely

Please explain it very well because my knowledge about pawn is ....

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#include <hamsandwich>
#include <fun>

new g_Statusg_Timeg_Delayg_Amountg_ZombiePlagueg_Nemesis,  g_FirstZombieg_LastZombiebool:gamestarted=false;
new 
playerhp[33], playerhpOld[33], gotdamage[33];

public 
plugin_init()
{
    
register_plugin("ZP: Regeneration""1.2 Final Fixed (Fixed  again!)""hleV");
    
register_logevent("logevent_round_end"2"1=Round_End");
    
register_logevent("logevent_round_start"2"1=Round_Start");
    
RegisterHam(Ham_TakeDamage"player""bacon_takedamage_player"1);
    
g_Status register_cvar("zp_regeneration""1");
    
g_Time register_cvar("zp_regen_time""0.1");
    
g_Delay register_cvar("zp_regen_delay""2");
    
g_Amount register_cvar("zp_regen_amount""1");
    
g_Nemesis register_cvar("zp_regen_nemesis""1");
    
g_FirstZombie register_cvar("zp_regen_firstzombie""1");
    
g_LastZombie register_cvar("zp_regen_lastzombie""1");

    
g_ZombiePlague get_cvar_pointer("zp_on");
}

public 
logevent_round_end()
{
    
gamestarted false;
}

public 
logevent_round_start()
{
    
gamestarted true;
}

public 
bacon_takedamage_player(victiminflictorattacker,  Float:damagedamagetype)
{
    if(
gamestarted)
    {
        if (!
g_ZombiePlague || !get_pcvar_num(g_Status) ||  !is_user_connected(victim) || !is_user_alive(victim) ||  !zp_get_user_zombie(victim))
            return;

        
playerhpOld[victim] = get_user_health(victim);

        if (
playerhpOld[victim] < 1)
            return;

        if (!
get_pcvar_num(g_Nemesis) &&  zp_get_user_nemesis(victim))
            return;

        if (!
get_pcvar_num(g_FirstZombie) &&  zp_get_user_first_zombie(victim))
            return;

        if (!
get_pcvar_num(g_LastZombie) &&  zp_get_user_last_zombie(victim))
            return;
            
        if (
damagetype DMG_FALL)
            return;
        
        
remove_task(victim);
            
        if (
get_user_health(victim) < zp_get_zombie_maxhealth(victim)  && !task_exists(victim0))
        {
            
set_task(get_pcvar_float(g_Delay), "delay"victim__,  "a"1);
        }
    }
}

public 
delay(victim)
{
    
playerhp[victim] = get_user_health(victim);
    if(
playerhp[victim] == playerhpOld[victim])
    {
        
gotdamage[victim] = false;
        
set_task(get_pcvar_float(g_Time), "Regenerate"victim__,  "b");
    }
}

public 
Regenerate(victim)
{
    if (!
g_ZombiePlague || !get_pcvar_num(g_Status) ||  !is_user_connected(victim) || !is_user_alive(victim) ||  gotdamage[victim] || !gamestarted)
        return;

    
playerhp[victim] = get_user_health(victim);

    if (
playerhpOld[victim] < 1)
        return;

    new 
NeededHealth zp_get_zombie_maxhealth(victim) -  playerhp[victim];
    
    if (
NeededHealth <= get_pcvar_num(g_Amount))
    {
        
set_user_health(victimplayerhp[victim] + NeededHealth);
        
remove_task(victim);

        return;
    }
    
set_user_health(victimplayerhp[victim] + get_pcvar_num(g_Amount));

Freddy2304 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:16.


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