AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with the player explode on death (https://forums.alliedmods.net/showthread.php?t=272581)

Krtola 10-03-2015 08:01

Problem with the player explode on death
 
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()



Depresie 10-03-2015 08:48

Re: Problem with the player explode on death
 
Try like this

Code:

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



Krtola 10-03-2015 18:50

Re: Problem with the player explode on death
 
The same problem is still there.

Depresie 10-03-2015 20:09

Re: Problem with the player explode on death
 
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 :P

Krtola 10-04-2015 02:33

Re: Problem with the player explode on death
 
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?????

Depresie 10-04-2015 12:32

Re: Problem with the player explode on death
 
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 10-04-2015 14:03

Re: Problem with the player explode on death
 
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()



Krtola 10-05-2015 07:40

Re: Problem with the player explode on death
 
Problem is still here. Any other solution?

Depresie 10-05-2015 14:15

Re: Problem with the player explode on death
 
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


All times are GMT -4. The time now is 22:09.

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