Raised This Month: $ Target: $400
 0% 

Remove weapon entity after death?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cader
Senior Member
Join Date: Mar 2007
Old 02-09-2009 , 08:45   Remove weapon entity after death?
Reply With Quote #1

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.
Cader is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 02-09-2009 , 09:11   Re: Remove weapon entity after death?
Reply With Quote #2

:-/
PHP Code:
static ent;
    while( ( 
ent engfuncEngFunc_FindEntityByStringent"classname""weaponbox" ) ) )
        
engfuncEngFunc_RemoveEntityent ); 
__________________

anakin_cstrike is offline
Cader
Senior Member
Join Date: Mar 2007
Old 02-09-2009 , 09:33   Re: Remove weapon entity after death?
Reply With Quote #3

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

Cader is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-09-2009 , 09:54   Re: Remove weapon entity after death?
Reply With Quote #4

I use this method in one of my plugins and it works perfectly.

http://forums.alliedmods.net/showthr...te+weapon+drop
__________________
Bugsy is offline
Cader
Senior Member
Join Date: Mar 2007
Old 02-09-2009 , 09:56   Re: Remove weapon entity after death?
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
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.
Cader is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-09-2009 , 09:58   Re: Remove weapon entity after death?
Reply With Quote #6

To do things safely and efficiently you sometimes need more than a small function.
__________________
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-09-2009 , 10:07   Re: Remove weapon entity after death?
Reply With Quote #7

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

__________________
Bugsy 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 17:03.


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