AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Drop then remove C4 (https://forums.alliedmods.net/showthread.php?t=49403)

Mini_Midget 01-03-2007 08:48

Drop then remove C4
 
I'm not very good with entities but is this the correct way for dropping the C4 then removing it?
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <engine>

public plugin_init() {
    
register_event("StatusIcon""c4_dropped""be""1=1""1=2""2=c4")
}

public 
c4_dropped(id) {
    
engclient_cmd(id"drop""weapon_c4")
    
set_task(0.1"delete_c4")
}
public 
delete_c4() {
    new 
ent find_ent_by_class(-1"weaponbox")
    while (
ent 0) {
        new 
model[33]
        
entity_get_string(entEV_SZ_modelmodel32)
        if (
equali(model"models/w_backpack.mdl")) {
            
remove_entity(ent)
            return 
PLUGIN_CONTINUE
        
}
        
ent find_ent_by_class(ent"weaponbox")
    }
    return 
PLUGIN_CONTINUE


Also, is there a way to remove hostages as well?

SweatyBanana 01-03-2007 09:07

Re: Drop then remove C4
 
http://forums.alliedmods.net/showthread.php?t=40164

VEN 01-03-2007 10:35

Re: Drop then remove C4
 
Quote:

engclient_cmd(id, "drop", "weapon_c4")
set_task(0.1, "delete_c4")

You do not need a task because the backack is created right after drop emulation.

Also in the article [HOWTO] detect weapon drop details [including drop type, weapon type, etc] i've wrote that
Quote:

Note: The weaponbox entity is not the actual weapon, it is the "box" entity that "contain" the weapon_* entity, i.e. the actual weapon entity.
In other words your backpack isn't the only entity that should be removed. There are also a weapon_c4 entity that is linked to a weaponbox, i.e. your backpack. There is a safe weaponbox/weapon_* entity deletion method: just force weaponbox Think and it will remove the entity pair almost instantly and safely using the default game methods.

Quote:

Also, is there a way to remove hostages as well?
Hook Spawn in plugin_precache and remove/supercede the corresponding entity - the most safe way.

kramesa 09-08-2012 12:41

Re: Drop then remove C4
 
What the best method to remove C4?

ConnorMcLeod 09-08-2012 12:59

Re: Drop then remove C4
 
PHP Code:

Strip_User_C4id )
{
    new 
fwd register_forward(FM_SetModel"C4_Drop_SetModel"true)
    
engclient_cmd(id"drop""weapon_c4")
    
unregister_forward(FM_SetModelfwdtrue)
}

public 
C4_Drop_SetModelent model[] )
{
    if( !
equal(model"model/weaponbox.mdl") )
    {
        
dllfunc(DLLFunc_Thinkent)
    }



Lolz0r 09-09-2012 07:58

Re: Drop then remove C4
 
Quote:

Originally Posted by ConnorMcLeod (Post 1794386)
PHP Code:

Strip_User_C4id )
{
    new 
fwd register_forward(FM_SetModel"C4_Drop_SetModel"true)
    
engclient_cmd(id"drop""weapon_c4")
    
unregister_forward(FM_SetModelfwdtrue)
}

public 
C4_Drop_SetModelent model[] )
{
    if( !
equal(model"model/weaponbox.mdl") )
    {
        
dllfunc(DLLFunc_Thinkent)
    }



And see this : http://forums.alliedmods.net/showpos...08&postcount=8

ConnorMcLeod 09-09-2012 10:09

Re: Drop then remove C4
 
Roughly the same method.

Lolz0r 09-10-2012 19:14

Re: Drop then remove C4
 
Now I saw that he only wants to remove it, wouldn't it be better in his occasion ? :

PHP Code:

#include <amxmodx>
#include <fakemeta_util>

public plugin_init() 
{
    
register_plugin("C4 Remove""0.1""ConnorMcLeod")
    
register_event("StatusIcon""GotBomb""be""1=1""1=2""2=c4")
}

public 
GotBomb(id

    
fm_strip_user_gun(idCSW_C4)



ConnorMcLeod 09-11-2012 02:19

Re: Drop then remove C4
 
Most of fm_ stocks are not recommanded to use, that one belongs to those ones.

kramesa 10-02-2012 15:36

Re: Drop then remove C4
 
This code is correct?

Code:
#include <amxmodx> #include <fakemeta> public plugin_init()     register_event("StatusIcon", "c4Dropped", "be", "1=1", "1=2", "2=c4");     public c4Dropped(id) {     new fwd = register_forward(FM_SetModel, "C4_Drop_SetModel", true);     engclient_cmd(id, "drop", "weapon_c4");     unregister_forward(FM_SetModel, fwd, true); } public C4_Drop_SetModel(ent , model[]) {     if(!equal(model, "model/weaponbox.mdl"))         dllfunc(DLLFunc_Think, ent); }

Stack error!


All times are GMT -4. The time now is 06:35.

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