AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Remove weapon entity after death? (https://forums.alliedmods.net/showthread.php?t=85363)

Cader 02-09-2009 08:45

Remove weapon entity after death?
 
Hello.

I made a plugin which enables a menu for weapons (like in csdm) and respawns you when you death.

So after 5 minutes later in any map, there are a lot of empty weapons on the floor dropped by death players.

How can I remove these weapons after his owner's death? I think CSDM does this.

anakin_cstrike 02-09-2009 09:11

Re: Remove weapon entity after death?
 
:-/
PHP Code:

static ent;
    while( ( 
ent engfuncEngFunc_FindEntityByStringent"classname""weaponbox" ) ) )
        
engfuncEngFunc_RemoveEntityent ); 


Cader 02-09-2009 09:33

Re: Remove weapon entity after death?
 
It does not work for me :=(

PHP Code:

public death_msg()
{
static 
ent;

    while( ( 
ent engfuncEngFunc_FindEntityByStringent"classname""weaponbox" ) ) )
        
engfuncEngFunc_RemoveEntityent );


   return 
PLUGIN_CONTINUE

}

public 
plugin_init()
{
   
register_event("DeathMsg","death_msg","a")
   return 
PLUGIN_CONTINUE



Bugsy 02-09-2009 09:54

Re: Remove weapon entity after death?
 
I use this method in one of my plugins and it works perfectly.

http://forums.alliedmods.net/showthr...te+weapon+drop

Cader 02-09-2009 09:56

Re: Remove weapon entity after death?
 
Quote:

Originally Posted by Bugsy (Post 758740)
I use this method in one of my plugins and it works perfectly.

http://forums.alliedmods.net/showthr...te+weapon+drop

Okay but I just need a small addition for my code. A small function.

Bugsy 02-09-2009 09:58

Re: Remove weapon entity after death?
 
To do things safely and efficiently you sometimes need more than a small function.

Bugsy 02-09-2009 10:07

Re: Remove weapon entity after death?
 
I edited the code a bit so when a weapon is dropped it will get deleted from the map. You can get it to work as you want it to with some extra variables and if statements.

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <cstrike>

// plugin's main information
#define PLUGIN_NAME "No Weapon Drop [edited]"
#define PLUGIN_VERSION "0.1"
#define PLUGIN_AUTHOR "VEN [edited by bugsy]"

new const g_wbox_class[] = "weaponbox"
new const g_wbox_model[] = "models/w_weaponbox.mdl"
new const g_model_prefix[] = "models/w_"

#define CLIENT_START_INDEX 1

new g_max_clients
new g_max_entities

public plugin_init() {
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)

    
register_forward(FM_SetModel"forward_set_model")

    
g_max_clients global_get(glb_maxClients)
    
g_max_entities global_get(glb_maxEntities)
}

public 
forward_set_model(ent, const model[]) 
{
    if (!
pev_valid(ent) || !equali(modelg_model_prefixsizeof g_model_prefix 1) || equali(modelg_wbox_model))
        return 
FMRES_IGNORED

    
new id pev(entpev_owner)
    if (!(
CLIENT_START_INDEX <= id <= g_max_clients))
        return 
FMRES_IGNORED

    
static class[32]
    
pev(entpev_classname, class, sizeof class - 1)
    if (!
equal(class, g_wbox_class))
        return 
FMRES_IGNORED

    
for (new g_max_clients 1g_max_entities; ++i) {
        if (!
pev_valid(i) || ent != pev(ipev_owner))
            continue

        
dllfunc(DLLFunc_Thinkent)
    
        return 
FMRES_IGNORED
    
}

    return 
FMRES_IGNORED




All times are GMT -4. The time now is 17:03.

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