Raised This Month: $51 Target: $400
 12% 

Explode an entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 08-08-2013 , 08:12   Explode an entity
Reply With Quote #1

How to explode a custom entity by a command?

PHP Code:
new entity

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /beep""boom")
    
register_clcmd("say /set""drop")
    
// Add your code here...
}
public 
drop()
{
    
entity create_entity("info_target")
    
entity_set_string(entityEV_SZ_classname"bomb_entity")
    
entity_set_model(entityg_c5_model[2])    
    
entity_set_size(entityFloat:{-2.5, -2.5, -1.5}, Float:{2.52.51.5})
    
entity_set_int(entityEV_INT_solid2)
    
entity_set_int(entityEV_INT_movetype6)
    
entity_set_vector(entityEV_VEC_originvOrigin)
}
public 
boom()
{
    
//explode an entity

Randomize is offline
DWIGHTpN
Senior Member
Join Date: Jan 2013
Location: Romania.
Old 08-08-2013 , 11:09   Re: Explode an entity
Reply With Quote #2

From message_const.inc , use:
PHP Code:
#define    TE_EXPLOSION                3        // Additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps
// write_byte(TE_EXPLOSION)
// write_coord(position.x)
// write_coord(position.y)
// write_coord(position.z)
// write_short(sprite index)
// write_byte(scale in 0.1's)
// write_byte(framerate)
// write_byte(flags) 
Flags:
PHP Code:
#define TE_EXPLFLAG_NONE            0        // All flags clear makes default Half-Life explosion
#define TE_EXPLFLAG_NOADDITIVE      1        // Sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite)
#define TE_EXPLFLAG_NODLIGHTS       2        // Do not render dynamic lights
#define TE_EXPLFLAG_NOSOUND         4        // Do not play client explosion sound
#define TE_EXPLFLAG_NOPARTICLES     8        // Do not draw particles 
sprite index:
PHP Code:
new g_sprite// This is sprite index
public plugin_precache() {
      
g_sprite precache_model("sptrite directory");

After explosion, use remove_entity( entity ).
You want to kill/slap(with damage) players, when this entity explode?

Last edited by DWIGHTpN; 08-08-2013 at 11:10.
DWIGHTpN is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 08-08-2013 , 11:15   Re: Explode an entity
Reply With Quote #3

Yes I want to slap/kill them. What I've done is like this:
PHP Code:
public explode_bomb(id)
{
    if(!
is_valid_ent(c5_entity))
    {
        
client_print(print_chat "* Invalid ENTITY: %i" c5_entity);
    }
    new 
ent_c5 entity_get_int(c5_entityEV_ENT_owner)
    
    new 
Float:fOrigin[3]
    new 
iOrigin[3]
    
    new 
g_players[32], g_playersnumx
    get_players
(g_playersg_playersnum"a")
    
    
entity_get_vector(c5_entityEV_VEC_originfOrigin)
    
FVecIVec(fOriginiOrigin)
    
    for(
0<= g_playersnumx++)
    {
        new 
g_players[x]

        new 
g_distance floatround(entity_range(c5_entityi))

        if (
g_distance <= 300)
        {
            if(
get_user_team(id) != get_user_team(i))
            {
                
user_silentkill(i)
                
make_deathmsg(idi0"grenade")
                
set_user_frags(idget_user_frags(id) + 1)
                
emit_sound(idCHAN_AUTOg_c5_hit[random_num(02)], 1.0ATTN_NORM0PITCH_NORM)
                
cs_set_user_money(idcs_get_user_money(id) + 300)
            }
            else
            {
                if(
get_user_team(id) != get_user_team(i))
                {
                    
set_user_health(iget_user_health(i) - 100)
                    
emit_sound(idCHAN_AUTOg_c5_hit[random_num(02)], 1.0ATTN_NORM0PITCH_NORM)
                }
            }
        }
    }
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITYiOrigin)
    
write_byte (TE_EXPLOSION)
    
write_coord(iOrigin[0])
    
write_coord(iOrigin[1])
    
write_coord(iOrigin[2])
    
write_short(explode)
    
write_byte (30)
    
write_byte (15)
    
write_byte (0)
    
message_end()

    
message_begin(MSG_BROADCASTSVC_TEMPENTITYiOrigin)
    
write_byte (TE_SMOKE)
    
write_coord(iOrigin[0])
    
write_coord(iOrigin[1])
    
write_coord(iOrigin[2])
    
write_short(smoke)
    
write_byte (100)
    
write_byte (15)
    
message_end()
    
    
engclient_cmd(id"lastinv")
    
cs_set_user_bpammo(idCSW_HEGRENADE0)
    
remove_entity(c5_entity)
    
    
g_has_dectonator[id] = false
    g_has_planted
[id] = false
    g_bought
[id] = false

Randomize is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 08-09-2013 , 07:35   Re: Explode an entity
Reply With Quote #4

Nevermind, this have been solved.
Let me change the question, I make an entity is able to be shot and explode by engine. I use:
PHP Code:
RegisterHam(Ham_TraceAttack"info_target""damage_entity"
and it worked. But the problem is when I attacked with single shot, it explodes.

Do I need to use this?
PHP Code:
        entity_set_float(c5_entityEV_FL_health100.0)
        
entity_set_float(c5_entityEV_FL_dmg_take10.0
Randomize 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 13:47.


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