/****************************************/
/* */
/* This plugin allows you to set the */
/* time after which the weapons on the */
/* map will re-emerge. This is suitable */
/* for deathmatch / surf servers. */
/* */
/****************************************/
/* ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ */
/****************************************/
/* */
/* CVARS: */
/* wr_mode - 1/0 (Default 1) */
/* Enable/Disable plugin */
/* */
/* wr_resp_time 30.0 (Default: 30.0) */
/* time for weapon respawn */
/* minimum 5.0 - maximum none */
/* */
/****************************************/
/* ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ */
/****************************************/
/* */
/* YOU CAN EDIT: */
/* #define MAX_ENTITIES 64 */
/* 64 - is number how many weapons */
/* will be respawned */
/* */
/****************************************/
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
#define PLUGIN "Weapon Respawner"
#define VERSION "1.0"
#define AUTHOR "HoLLyWooD"
#define m_Type 34
#define m_Count 35
#define count 1
#define XTRA_OFS_ARMOURY 4
#define TASK_SPAWN 240
// Number of maximum weapons to respawn
#define MAX_ENTITIES 64
new Float:g_fOrigin[MAX_ENTITIES][3]; // Origin finded weapons
new g_szEntModel[MAX_ENTITIES][128]; // Temp model finded weapons
new g_EntType[MAX_ENTITIES]; // Type of finded weapons
new total = 0;
new pcvar_mode, pcvar_time, mode, Float:resp_time;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
// For search servers with this plugin
register_cvar( "wr_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY );
// Cvars
pcvar_mode = register_cvar("wr_mode", "1");
pcvar_time = register_cvar("wr_resp_time", "30.0");
// Load cvars
load_cvars();
// Events
register_logevent("event_round_end",2,"1=Round_End");
register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
// Save information about weapon entities on map
static ent;
while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "armoury_entity")) != 0){
pev(ent, pev_model, g_szEntModel[total], 127);
pev(ent, pev_origin, g_fOrigin[total]);
g_EntType[total] = get_pdata_int(ent, m_Type, XTRA_OFS_ARMOURY);
total++;
}
// For first ( one ) player on map
if(task_exists(TASK_SPAWN)) remove_task(TASK_SPAWN);
if(mode) set_task(resp_time, "spawn", TASK_SPAWN, _, _, "b");
}
public event_round_start(){
// Update cvars
load_cvars();
if(task_exists(TASK_SPAWN)) remove_task(TASK_SPAWN);
if(mode) set_task(resp_time, "spawn", TASK_SPAWN, _, _, "b");
}
public event_round_end()
if(task_exists(TASK_SPAWN)) remove_task(TASK_SPAWN);
public load_cvars(){
mode = get_pcvar_num(pcvar_mode);
resp_time = ( get_pcvar_float(pcvar_time) > 5.0 ) ? get_pcvar_float(pcvar_time) : 5.0;
}
public spawn(){
static classname[32], ent;
for(new i=0;i<=total;i++){
// Find entities in radius of new weapon
while((ent = find_ent_in_sphere(ent, g_fOrigin[i], 10.0)) != 0 ){
entity_get_string(ent,EV_SZ_classname,classname,charsmax(classname));
// Remove weapons on this place
if(equali(classname,"armoury_entity")) set_pev(ent, pev_flags, pev(ent, pev_flags) | FL_KILLME);
}
// Create weapon
create_armoury_entity(g_fOrigin[i], g_EntType[i], g_szEntModel[i]);
}
}
stock create_armoury_entity(Float:flOrigin[3], const item, const szWmodel[]){
// Create weapon entity
new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "armoury_entity"));
// Set model & origin
set_pev(iEnt, pev_origin, flOrigin);
set_pev(iEnt, pev_model, szWmodel);
// Set type of entity and count
set_pdata_int(iEnt, m_Type, item, XTRA_OFS_ARMOURY);
set_pdata_int(iEnt, m_Count, count, XTRA_OFS_ARMOURY);
// Spawn entity
DispatchSpawn(iEnt);
}