What should I do to get the podbots to attack the sandbags? Here is my code:
Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <engine>
// The sizes of models
#define PALLET_MINS Float:{ -27.260000, -22.280001, -22.290001 }
#define PALLET_MAXS Float:{ 27.340000, 26.629999, 29.020000 }
// from fakemeta util by VEN
#define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
#define fm_remove_entity(%1) engfunc(EngFunc_RemoveEntity, %1)
// this is mine
#define fm_drop_to_floor(%1) engfunc(EngFunc_DropToFloor,%1)
// cvars
new pnumplugin, remove_nrnd, maxpallets, phealth;
// num of pallets with bags
new palletscout = 0;
/* Models for pallets with bags .
Are available 2 models, will be set a random of them */
new g_models[][] =
{
"models/pallet_with_bags2.mdl",
"models/pallet_with_bags.mdl"
}
new g_bolsas[33];
const g_item_bolsas = 0
new g_BINDMODE, g_MSGMODE
public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
register_plugin("SandBags", "1.1", "LARP")
/* Register the cvars */
g_BINDMODE = register_cvar("zp_pb_bind","0"); //Auto bind L Key!
g_MSGMODE = register_cvar("zp_pb_msg","1"); //
pnumplugin = register_cvar("zp_pb_enable","1"); // 1 = ON ; 0 = OFF
remove_nrnd = register_cvar("zp_pb_remround","1");
maxpallets = register_cvar("zp_pb_limit","200"); // max number of pallets with bags
phealth = register_cvar("zp_pb_health","600"); // set the health to a pallet with bags
/* Game Events */
register_event("HLTV","event_newround", "a","1=0", "2=0"); // it's called every on new round
/* This is for menuz: */
register_menucmd(register_menuid("\ySand Bags:"), 1023, "menu_command" );
register_clcmd("say /pb","show_the_menu");
register_clcmd("/pb","show_the_menu");
}
public plugin_precache()
{
for(new i;i < sizeof g_models;i++)
engfunc(EngFunc_PrecacheModel,g_models[i]);
}
public show_the_menu(id,level,cid)
{
// check if user doesen't have admin
/*if( ! cmd_access( id,level, cid , 0 ))
return PLUGIN_HANDLED;
*/
// check if the plugin cvar is turned off
if( ! get_pcvar_num( pnumplugin ) )
return PLUGIN_HANDLED;
// check if user isn't alive
if( ! is_user_alive( id ) )
{
client_print( id, print_chat, "" ); //msg muerto
return PLUGIN_HANDLED;
}
new szMenuBody[256];
new keys;
new nLen = format( szMenuBody, 255, "\ySand Bags:^n" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. Place a Sandbags (%i Remaining)", g_bolsas[id] );
//nLen += format( szMenuBody[nLen], 255-nLen, "^n\w2. Remove a pallet with bags" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit" );
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<9)
show_menu( id, keys, szMenuBody, -1 );
// depends what you want, if is continue will appear on chat what the admin sayd
client_print(id, print_chat, "[ZP] The zombies can not use this command!")
return PLUGIN_HANDLED;
}
public menu_command(id,key,level,cid)
{
switch( key )
{
// place a pallet with bags
case 0:
{
new money = g_bolsas[id]
if ( money < 1 )
{
if ( get_pcvar_num(g_MSGMODE) == 1 )
{
set_hudmessage(0, 0, 100, 0.80, 0.80, 0, 6.0, 2.0, 1.0, 1.0)
show_hudmessage(id, "You do not have to^nplace sandbags")
return PLUGIN_CONTINUE
}
client_print(id, print_chat, "[ZP] You do not have to place sandbags!")
return PLUGIN_CONTINUE
}
g_bolsas[id]-= 1
place_palletwbags(id);
show_the_menu(id,level,cid);
return PLUGIN_CONTINUE
}
}
return PLUGIN_HANDLED;
}
public place_palletwbags(id)
{
if( palletscout == get_pcvar_num(maxpallets) )
{
client_print(id,print_chat,"[ZP] For security reasons only allow %d Sandbags on the server!",get_pcvar_num(maxpallets));
return PLUGIN_HANDLED;
}
// create a new entity
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "func_wall"));
// set a name to the entity
set_pev(ent,pev_classname,"amxx_pallets");
// set model
engfunc(EngFunc_SetModel,ent,g_models[random(sizeof g_models)]);
// register a new var. for origin
static Float:xorigin[3];
get_user_hitpoint(id,xorigin);
// check if user is aiming at the air
if(engfunc(EngFunc_PointContents,xorigin) == CONTENTS_SKY)
{
client_print(id,print_chat,"[ZP] You can not put sandbags in the sky!");
return PLUGIN_HANDLED;
}
// set sizes
static Float:p_mins[3], Float:p_maxs[3];
p_mins = PALLET_MINS;
p_maxs = PALLET_MAXS;
engfunc(EngFunc_SetSize, ent, p_mins, p_maxs);
set_pev(ent, pev_mins, p_mins);
set_pev(ent, pev_maxs, p_maxs );
set_pev(ent, pev_absmin, p_mins);
set_pev(ent, pev_absmax, p_maxs );
// set the rock of origin where is user placed
engfunc(EngFunc_SetOrigin, ent, xorigin);
// make the rock solid
set_pev(ent,pev_solid,SOLID_BBOX); // touch on edge, block
// set the movetype
set_pev(ent,pev_movetype,MOVETYPE_FLY); // no gravity, but still collides with stuff
// now the damage stuff, to set to take it or no
// if you set the cvar "pallets_wbags_health" 0, you can't destroy a pallet with bags
// else, if you want to make it destroyable, just set the health > 0 and will be
// destroyable.
new Float:p_cvar_health = get_pcvar_float(phealth);
switch(p_cvar_health)
{
case 0.0 :
{
set_pev(ent,pev_takedamage,DAMAGE_NO);
}
default :
{
set_pev(ent,pev_health,p_cvar_health);
set_pev(ent,pev_takedamage,DAMAGE_YES);
}
}
static Float:rvec[3];
pev(id,pev_v_angle,rvec);
rvec[0] = 0.0;
set_pev(ent,pev_angles,rvec);
// drop entity to floor
fm_drop_to_floor(ent);
// num ..
palletscout++;
// confirm message
if ( get_pcvar_num(g_MSGMODE) == 1 )
{
set_hudmessage(0, 0, 100, 0.80, 0.80, 0, 6.0, 2.0, 1.0, 1.0)
show_hudmessage(id, "You placed a SandBag^n%i Remaining", g_bolsas[id])
return PLUGIN_HANDLED
}
client_print(id, print_chat, "[ZP] You have placed a Sandbag.")
return PLUGIN_HANDLED;
}
stock get_user_hitpoint(id, Float:hOrigin[3])
{
if ( ! is_user_alive( id ))
return 0;
new Float:fOrigin[3], Float:fvAngle[3], Float:fvOffset[3], Float:fvOrigin[3], Float:feOrigin[3];
new Float:fTemp[3];
pev(id, pev_origin, fOrigin);
pev(id, pev_v_angle, fvAngle);
pev(id, pev_view_ofs, fvOffset);
xs_vec_add(fOrigin, fvOffset, fvOrigin);
engfunc(EngFunc_AngleVectors, fvAngle, feOrigin, fTemp, fTemp);
xs_vec_mul_scalar(feOrigin, 9999.9, feOrigin);
xs_vec_add(fvOrigin, feOrigin, feOrigin);
engfunc(EngFunc_TraceLine, fvOrigin, feOrigin, 0, id);
global_get(glb_trace_endpos, hOrigin);
return 1;
}
public event_newround()
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();
}
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);
palletscout = 0;
}
stock bool:is_hull_vacant(const Float:origin[3], hull,id) {
static tr
engfunc(EngFunc_TraceHull, origin, origin, 0, hull, id, tr)
if (!get_tr2(tr, TR_StartSolid) || !get_tr2(tr, TR_AllSolid)) //get_tr2(tr, TR_InOpen))
return true
return false
}
public cmd_bind(id)
{
if ( get_pcvar_num(g_BINDMODE) == 1 )
{
client_print(id, print_chat, "[ZP] You have %i sandbags, to use with the key 'L'", g_bolsas[id])
client_cmd(id,"bind l /pb")
return PLUGIN_HANDLED
}
client_print(id, print_chat, "[ZP] You have %i sandbags, to use type 'say /pb'", g_bolsas[id])
return PLUGIN_HANDLED
}