/**
* Modified by Safety1st
* 6/23/2015
*
* Home post:
* http://c-s.net.ua/forum/index.php?act=findpost&pid=591184
*
* Changes are:
* - added feature to exclude bomb from auto-removing
* - added feature to include shield to auto-removing
* - minor changes
*/
/**
* The game itself remove dropped weapons after 5 minutes. It is too long time for servers with deathmatch mode.
* Firstly weaponbox is created with its default model then the game assigns custom model to it
* (model of the weapon it holds). The idea is simple: we catch custom model assigning and modify autoremoving time.
* Unfortunately for shield it is not suitable because it doesn't receive custom model. Therefore we can't catch 'right' moment and
* must use delay to definitely set our autoremoving time AFTER the game does.
*
* See CSSDK\player.cpp (CBasePlayer::DropPlayerItem and CBasePlayer::DropShield) for more information.
*/
/* Copyright © 2015 Safety1st
Remove Dropped Weapons is free software;
you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <amxmodx>
#include <engine>
#include <fakemeta>
/*---------------EDIT ME------------------*/
#define WPN_REMOVE_TIME 10 // set auto-removing time
//#define EXCLUDE_BOMB // uncomment to exclude bomb from auto-removing
//#define INCLUDE_SHIELD // uncomment to include shield to auto-removing
/*----------------------------------------*/
#define PLUGIN "Remove Dropped Weapons"
#define AUTHOR "WPMG PRoSToTeM@ / Safety1st"
#define VERSION "0.13b"
#if defined EXCLUDE_BOMB
#include <cstrike>
new giStartEnt, giMaxEntities
#endif
#if defined INCLUDE_SHIELD
static const gszWpnShieldClass[] = "weapon_shield"
static szClassName[14]
#else
static szClassName[10]
#endif
public plugin_init() {
register_plugin( PLUGIN, VERSION, AUTHOR )
register_forward( FM_SetModel, "SetModelPre", 0 )
#if defined EXCLUDE_BOMB
giStartEnt = get_maxplayers() + 1
giMaxEntities = global_get( glb_maxEntities )
#endif
}
public SetModelPre( const ent, const model[] ) {
static const szWpnboxClass[] = "weaponbox"
entity_get_string( ent, EV_SZ_classname, szClassName, charsmax(szClassName) )
if( !strcmp( szClassName, szWpnboxClass ) ) {
// it is a weaponbox
#if defined EXCLUDE_BOMB
new i
for( i = giStartEnt; i < giMaxEntities; i++ ) {
// search for an entity that is owned by the weaponbox, this should be a weapon_* entity
if( is_valid_ent(i) && entity_get_edict( i, EV_ENT_owner ) == ent ) {
if( cs_get_weapon_id(i) == CSW_C4 )
return
else
break
}
}
#endif
entity_set_float( ent, EV_FL_nextthink, get_gametime() + WPN_REMOVE_TIME.0 )
}
#if defined INCLUDE_SHIELD
else if( !strcmp( szClassName, gszWpnShieldClass ) )
set_task( 0.1, "ChangeNextThinkTime", ent )
#endif
}
#if defined INCLUDE_SHIELD
public ChangeNextThinkTime( const ent ) {
/* 100 ms is too big time comparing with server FPS.
So we must make sure that shield entity still exists. */
if( is_valid_ent(ent) ) {
entity_get_string( ent, EV_SZ_classname, szClassName, charsmax(szClassName) )
if( !strcmp( szClassName, gszWpnShieldClass ) )
entity_set_float( ent, EV_FL_nextthink, get_gametime() + WPN_REMOVE_TIME.0 )
}
}
#endif