Raised This Month: $ Target: $400
 0% 

Problem with the player explode on death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 10-03-2015 , 08:01   Problem with the player explode on death
Reply With Quote #1

When a zombie dies this plugin creating an explosion that should knock back humans.
The problem is that this sometimes happens(knock back humans), but not often(one in ten attempts approximately)but you should always happen when humans are in explode radius.
Does anyone know what could be the problem?
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <biohazard>

#define SOUND2 "garg/gar_stomp1.wav"
#define is_player(%0) (1 <= %0 <= giMaxplayers)


new cvar_radiusg_exploSprgiMaxplayers


public plugin_precache( )
{
        
g_exploSpr engfunc(EngFunc_PrecacheModel"sprites/shockwave.spr")

        
precache_sound(SOUND2)
}

public 
plugin_init( )
{
    
register_plugin"Zombie Explode""1.0""Krtola" )

        
register_event"DeathMsg""event_DeathMsg""a" )
    
        
cvar_radius register_cvar("zombie_explode_radius""999.0")        
    
        
giMaxplayers get_maxplayers()
}

public 
event_DeathMsg( )
{
    new 
id read_data)
    
    if( !
is_user_connectedid ) || !is_user_zombieid ) )
        return 
PLUGIN_HANDLED
        
    
static EntFloatoriginF[3]
    
pev(idpev_originoriginF)
        static 
FloatioriginF[3]

        
client_cmd(0"spk %s"SOUND2)

        
create_blast(originF)
    
    while( (
Ent engfunc(EngFunc_FindEntityInSphereEntoriginFget_pcvar_float(cvar_radius))) )
    {
        if(
is_player(Ent) && Ent != id)
        {      
            if(
is_user_zombie(Ent))
                return 
PLUGIN_CONTINUE

            pev
(Entpev_originioriginF)
            
            
originF[0] = (ioriginF[0] - originF[0]) * 10.0 
            originF
[1] = (ioriginF[1] - originF[1]) * 10.0 
            originF
[2] = (ioriginF[2] - originF[2]) + 500.0
            
            set_pev
(Entpev_velocityoriginF)
        }
    }
    
    return 
PLUGIN_HANDLED
}


create_blast(const Float:originF[3])
{
    
// Medium ring
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)
    
write_byte(TE_BEAMCYLINDER// TE id
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y
    
engfunc(EngFunc_WriteCoordoriginF[2]) // z
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x axis
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y axis
    
engfunc(EngFunc_WriteCoordoriginF[2]+199.0// z axis
    
write_short(g_exploSpr// sprite
    
write_byte(0// startframe
    
write_byte(0// framerate
    
write_byte(6// life
    
write_byte(40// width
    
write_byte(20// noise
    
write_byte(255// red
    
write_byte(0// green
    
write_byte(0// blue
    
write_byte(200// brightness
    
write_byte(0// speed
    
message_end()
    
    
// Largest ring
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)
    
write_byte(TE_BEAMCYLINDER// TE id
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y
    
engfunc(EngFunc_WriteCoordoriginF[2]) // z
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x axis
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y axis
    
engfunc(EngFunc_WriteCoordoriginF[2]+299.0// z axis
    
write_short(g_exploSpr// sprite
    
write_byte(0// startframe
    
write_byte(0// framerate
    
write_byte(6// life
    
write_byte(40// width
    
write_byte(20// noise
    
write_byte(255// red
    
write_byte(0// green
    
write_byte(0// blue
    
write_byte(100// brightness
    
write_byte(0// speed
    
message_end()
    
    
// Luz Dinamica
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)
    
write_byte(TE_DLIGHT// TE id
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y
    
engfunc(EngFunc_WriteCoordoriginF[2]) // z
    
write_byte(25// radio
    
write_byte(250// red
    
write_byte(250// green
    
write_byte(250// blue
    
write_byte(50// vida en 0.1, 30 = 3 segundos
    
write_byte(50// velocidad de decaimiento
    
message_end()


Last edited by Krtola; 10-03-2015 at 08:01.
Krtola is offline
Send a message via Skype™ to Krtola
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-03-2015 , 08:48   Re: Problem with the player explode on death
Reply With Quote #2

Try like this

Code:
originF[0] = put your desired value - get_distance_f(originF, ioriginF) * 0.5


Depresie is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 10-03-2015 , 18:50   Re: Problem with the player explode on death
Reply With Quote #3

The same problem is still there.
Krtola is offline
Send a message via Skype™ to Krtola
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-03-2015 , 20:09   Re: Problem with the player explode on death
Reply With Quote #4

replace only last part with the following
you had to create a new float for the knockback

Code:
            new Float:Knockback[3]
            Knockback[0] = put your desired value - get_distance_f(originF, ioriginF) * 0.5
            Knockback[1] = put your desired value - get_distance_f(originF, ioriginF) * 0.5
            Knockback[2] = put your desired value - get_distance_f(originF, ioriginF) * 0.5
            
            set_pev(Ent, pev_velocity, Knockback)
also leave me your skype via PM

Last edited by Depresie; 10-03-2015 at 20:14.
Depresie is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 10-04-2015 , 02:33   Re: Problem with the player explode on death
Reply With Quote #5

Will try this later.
Anyway,my first version always work when just 2 players play(1 human vs 1 zombies)
Maybe this has effect only on player who kill zombies?????
Krtola is offline
Send a message via Skype™ to Krtola
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-04-2015 , 12:32   Re: Problem with the player explode on death
Reply With Quote #6

nope, im sure it happens because you used the same float to store origin and to set velocity
just try to store the knockback value in a new float, it should work
Depresie is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-04-2015 , 14:03   Re: Problem with the player explode on death
Reply With Quote #7

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <biohazard>

#define SOUND2 "garg/gar_stomp1.wav"
#define is_player(%0) (1 <= %0 <= giMaxplayers)


new cvar_radiusg_exploSprgiMaxplayers
new cvar_explode_knocback


public plugin_precache( )
{
        
g_exploSpr engfunc(EngFunc_PrecacheModel"sprites/shockwave.spr")

        
precache_sound(SOUND2)
}

public 
plugin_init( )
{
    
register_plugin"Zombie Explode""1.0""Krtola" )

        
register_event"DeathMsg""event_DeathMsg""a" )
    
        
cvar_radius register_cvar("zombie_explode_radius""999.0")    
        
cvar_explode_knocback register_cvar("zombie_explode_knockback""500.0"
   
        
giMaxplayers get_maxplayers()
}

public 
event_DeathMsg()
{
    new 
id read_data(2)
    
    if (!
is_user_connected(id) || !is_user_zombie(id))
    {
        return
    }
    
    static 
Float:origin[3// 
    
pev(idpev_originorigin)
    
    
client_cmd(0"spk %s"SOUND2)

    
create_blast(origin)
     
    static 
victim
    victim 
= -1
     
    
while ((victim engfunc(EngFunc_FindEntityInSpherevictimoriginget_pcvar_float(cvar_radius))) != 0)
    {
        
// Only effect alive humans
        
if (!is_user_alive(victim) || is_user_zombie(victim))
            continue;
 
        static 
Float:orig[3], Float:knockback[3]
        
pev(victimpev_originorig)
        
knockback[0] = get_pcvar_float(cvar_explode_knockback) - get_distance_f(originorig) * 0.5
        knockback
[1] = get_pcvar_float(cvar_explode_knockback) - get_distance_f(originorig) * 0.5
        knockback
[2] = get_pcvar_float(cvar_explode_knockback) - get_distance_f(originorig) * 0.5
         
        set_pev
(victimpev_velocityknockback)
        
    }
}


create_blast(const Float:originF[3])
{
    
// Medium ring
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)
    
write_byte(TE_BEAMCYLINDER// TE id
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y
    
engfunc(EngFunc_WriteCoordoriginF[2]) // z
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x axis
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y axis
    
engfunc(EngFunc_WriteCoordoriginF[2]+199.0// z axis
    
write_short(g_exploSpr// sprite
    
write_byte(0// startframe
    
write_byte(0// framerate
    
write_byte(6// life
    
write_byte(40// width
    
write_byte(20// noise
    
write_byte(255// red
    
write_byte(0// green
    
write_byte(0// blue
    
write_byte(200// brightness
    
write_byte(0// speed
    
message_end()
    
    
// Largest ring
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)
    
write_byte(TE_BEAMCYLINDER// TE id
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y
    
engfunc(EngFunc_WriteCoordoriginF[2]) // z
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x axis
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y axis
    
engfunc(EngFunc_WriteCoordoriginF[2]+299.0// z axis
    
write_short(g_exploSpr// sprite
    
write_byte(0// startframe
    
write_byte(0// framerate
    
write_byte(6// life
    
write_byte(40// width
    
write_byte(20// noise
    
write_byte(255// red
    
write_byte(0// green
    
write_byte(0// blue
    
write_byte(100// brightness
    
write_byte(0// speed
    
message_end()
    
    
// Luz Dinamica
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)
    
write_byte(TE_DLIGHT// TE id
    
engfunc(EngFunc_WriteCoordoriginF[0]) // x
    
engfunc(EngFunc_WriteCoordoriginF[1]) // y
    
engfunc(EngFunc_WriteCoordoriginF[2]) // z
    
write_byte(25// radio
    
write_byte(250// red
    
write_byte(250// green
    
write_byte(250// blue
    
write_byte(50// vida en 0.1, 30 = 3 segundos
    
write_byte(50// velocidad de decaimiento
    
message_end()


Last edited by Depresie; 10-04-2015 at 14:21.
Depresie is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 10-05-2015 , 07:40   Re: Problem with the player explode on death
Reply With Quote #8

Problem is still here. Any other solution?
Krtola is offline
Send a message via Skype™ to Krtola
Depresie
Veteran Member
Join Date: Nov 2013
Old 10-05-2015 , 14:15   Re: Problem with the player explode on death
Reply With Quote #9

to debug further the problem, put a client_print under set_pev(victim, pev_velocity, knockback) in order to see if the function is called on every player in the radius
Depresie is offline
Reply



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 22:09.


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