PDA

View Full Version : [Subplugin Submission] [ZP] Extra Item: Sand Bags BETA!


LARP
10-26-2008, 00:13
ZP Extra Item: SandBags 1.1 Beta
Description:
Bags of sand to block roads and prevent infection (Human Item)
Automatic unstuck
Buy items on the menu extra and for use, write the command say /pb---------------------
Commands:
zp_pb_enable 1 = ON - 0 = OFF
zp_pb_remround 1 = Remove Sandbags to new round - 0 = Not remove
zp_pb_limit = Limits the sandbags, this is to prevent the rise of latency on the server (200 default)
zp_pb_health = Set the health to a SandBags (200 default)
zp_pb_stuck 1 = Automatic unstuck ON - 0 = Disabled
zp_pb_bind 1 = Enable the autobind to open menu (bind L) (0 default)
zp_pb_msg 1 = Enable HUD messages 0 = Disabled (1 Default)

COST: 18 ammopacks
For Change cost modify g_item_bolsas Line.

Original plugin Pallets with Bags (http://forums.alliedmods.net/showthread.php?p=455476) (BY SAMURAI)
-----------------------------Changelog:
------------------------------
1.1. - Added new client command in console /pb for autobind mode.
Added Autobind mode zp_pb_bind "1" (Default and recomend is "0").
Added HUD Messages optionals zp_pb_msg "1".
Now the menu starts automatically after buying the sandbags.
Now the menu, says the remaining sandbags.
Change cvars Autostuck to: zp_pb_stuckwait and zp_pb_stuckeffects.
Some messages have been removed.
------------------------------
1.0. - Beta Open :D
- Removed the command for 'remove sandbags' to avoid failures
------------------------------

Screenshots:
http://img227.**************/images/thpix.gif (http://g.**************/thpix.php)http://img509.**************/images/thpix.gif (http://g.**************/thpix.php)http://img100.**************/img100/5177/sandbag3al2.th.jpg (http://img100.**************/my.php?image=sandbag3al2.jpg)http://img509.**************/img509/5350/sandbag2jy7.th.jpg (http://img509.**************/my.php?image=sandbag2jy7.jpg) http://img100.**************/img100/5886/sandbaggo0uu2.th.jpg (http://img100.**************/my.php?image=sandbaggo0uu2.jpg)http://img100.**************/images/thpix.gif (http://g.**************/thpix.php)

Modules:

<amxmodx>
<amxmisc>
<fakemeta>
<xs>
<fun>
http://img100.**************/images/thpix.gif (http://g.**************/thpix.php)

Fry!
10-26-2008, 04:20
Very good. :)

ifx
10-26-2008, 05:46
haha, very very nice!

shadowski
10-26-2008, 07:58
haha great plugin! also could you add that you can place wooden boxes?

Sn!ff3r
10-28-2008, 04:17
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
//#include <fun>
#include <zombieplague.inc>

#define PLUGIN_NAME "Pallets with Bags"
#define PLUGIN_VERSION "0.2c"
#define PLUGIN_AUTHOR "SAMURAI"

// 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)

#define fm_get_user_noclip(%1) (pev(%1, pev_movetype) == MOVETYPE_NOCLIP)

// 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 stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "15 Sandbags" }
const g_item_bolsas = 18
new g_itemid_bolsas
new ZPSTUCK

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.0", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
ZPSTUCK = register_cvar("zp_pb_stuck","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","200"); // 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");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_autounstuckeffects","1")
cvar[2] = register_cvar("zp_autounstuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
new szMenuBody[256];
new keys;

new nLen = format( szMenuBody, 255, "\ySand Bags:^n" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. Place a Sandbags" );
//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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
new money = g_bolsas[id]
if ( money < 1 )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

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
client_print(id, print_chat, "[ZP] You have placed a Sandbags, you have %i remaining", g_bolsas[id])

return PLUGIN_HANDLED;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !fm_get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_bolsas)
{
g_bolsas[player]+= 15
client_print(player, print_chat, "[ZP] You have %i sandbags, to use type 'say / pb'", g_bolsas[player])
}

}
Fun module is useless.

EDIT: Samurai code is ok, but your... really poor.

MEN
10-28-2008, 09:40
Please add the auto bind key for place the Sand Bags!

Stixsmaster
10-28-2008, 16:30
The possibility to autobind /pb is possible but I dont think it should be done as there is not really any good key(s) specifically to bind it to in my opinion...so I dont mind having to type that in to use the sandbag menu to place and move them...

---Stixsmaster

LARP
10-28-2008, 18:03
Please add the auto bind key for place the Sand Bags!

What is the key that you consider to bind to default?

MEN
10-29-2008, 06:05
What is the key that you consider to bind to default?

I consider to bind "L" key to default. Or Place SandBag Menu should will appear at once after purchase SandBags. Something like that!

LARP
10-29-2008, 21:34
I consider to bind "L" key to default. Or Place SandBag Menu should will appear at once after purchase SandBags. Something like that!
Thanks for the suggestions, the changes will be implemented soon ..

Sn!ff3r
10-29-2008, 23:43
Do not bind player keys without his agree!

Mlk27
10-30-2008, 02:41
@LARP - read post #5

LARP
10-30-2008, 06:25
Do not bind player keys without his agree!
The administrator decide if it is forced or not.

@LARP - read post #5
If, reviews it and take it into account, thanks for the help.

Sn!ff3r
10-30-2008, 11:09
The administrator decide if it is forced or not. Please, read first forum rules about slowhacking.

Mephisto
10-31-2008, 11:22
Please, read first forum rules about slowhacking.

And the zombie plague menu? LOL

BloodMan
11-01-2008, 17:33
Nice plugin I'll definetley try it.

LARP
11-01-2008, 23:43
New Update v1.1
. Now the menu starts automatically after buying the sandbags.
. Added Autobind mode zp_pb_bind "1" (Default and recomend is "0").
. and more...

It is not possible to disable the function of the module, as it is central to the plugin.

Greetings and thanks for the suggestions. =)

Fry!
11-02-2008, 03:05
Do not bind player keys without his agree!

Sn!ff3r that is only server side like zombie plague menu, after disconnect nothing is changed.

G-Dog
11-02-2008, 05:04
wrong, Sn!ff3r is right in this case as the plugin is slowhackingclient_cmd(id,"bind l /pb")by default l is not bound, but this will overide a user's bind if they did bind it. Zombie Plague's menu on the other hand does NOT slowhack as instead of manually altering the bind it instead intercepts the server message "chooseteam" and blocks the original function server side. I would suggest to avoid the slowhacking thing to change register_clcmd("/pb","show_the_menu"); to something likeregister_clcmd("radio1","show_the_menu"); so that it intercepts radio1 message(default z).

Fry!
11-02-2008, 06:16
Then how about when you play zombie plague then press "m" and open a menu of zp list...

Sn!ff3r
11-03-2008, 13:33
I assinged it to impulse 201...

Then how about when you play zombie plague then press "m" and open a menu of zp list... ZP not bound any key - only catch "chooseteam" message from player.

LARP
11-25-2008, 20:44
Good,,,

Alguemnn
01-23-2009, 13:11
isnt a powerful item? Traping passages, the zombies can destroy the bags?

Fry!
01-23-2009, 13:12
No bags can't be destroyed only jump over them.

Igniuks
02-05-2009, 06:43
Where the heck do I edit the cost to this thing cant find it

Kachoo!
02-13-2009, 14:20
Great plugin man, im using it and it works fine ...

What should i do to use just one model of the sandbags ? That model without the piece of wood ...

And to change the 15 sands bags to 10.

Satoko
02-13-2009, 17:12
No bags can't be destroyed only jump over them.

well then the humans can win easily on maps with small rooms they all drop it at door and perhaps on windows and no zombie come in and that is very game killing.

Fry!
02-13-2009, 17:17
well then the humans can win easily on maps with small rooms they all drop it at door and perhaps on windows and no zombie come in and that is very game killing.

True. But I didn't made this plugin :D and could be possible that zombies could buy infection nades, you know that nades works through walls too. :D

Satoko
02-13-2009, 23:18
even when they buy that you cant throw them everywhere and the radius is not pretty big so the bags should be destroyable if you can't jump above.

Fry!
02-14-2009, 03:11
This is not Half-life 2 Engine this is Half-life engine so it's not possible to destroy things...

Satoko
02-14-2009, 08:07
This is not Half-life 2 Engine this is Half-life engine so it's not possible to destroy things...

then nobody needs that plugin if there is not any fair method of using it.

So you can't change the thing to something destroyable from half life?

Speed!
02-14-2009, 09:58
i didnt read all, but actually you can make bags destroyable, and also, aply an effect like the glass glatter (but one apropiated) for it

Kachoo!
02-14-2009, 13:08
I'm using this plugin. And the bags can be destroyed. Try it if you are human, with the knife its so easy to destroy.

Satoko
02-14-2009, 13:39
@Kachoo! and zombies can't destroy them? *to lazy to try it by my self now*

spedd
04-29-2009, 20:57
You can tell me how to dorobić this plugin options to receive the number of ammo packów xx how to make this command was very concerned because I want to do something with this one I have 2 options in the menu Dokup bag and after I click on a selected number of bags and receives ammo packi

spedd
04-30-2009, 06:58
is someone able to help?? Pliss Help

Mauricio
04-30-2009, 14:14
dont revive posts come on!!

and i dont know scripting sorry :D

spedd
04-30-2009, 19:05
wrote but no one is responsible and I am on the

Killer12201
05-03-2009, 13:27
When I get this plugin on my server it costs 0 ap?

powwoww
05-04-2009, 10:19
nice plugin but I think u cn set the ents Z-velocity to prevent the bags from flying !

seerax
05-10-2009, 03:23
In this plugin when zombie is destroying sandbags you can't hear the sound of hits - could this be fixed somehow? New playes may not know that they could be destroyed.
can you help me?

nycboy12
05-17-2009, 18:05
Sand Bags Jetpack

AiDec
12-07-2009, 22:47
hello I need comand in /pb menu BUY SAND BAGS , please help !!! :) karma +++

Tonda
12-27-2009, 12:23
Hi, is possible set: Player can create max 5 sandbags in the one round?

Mog12345
04-08-2010, 22:40
How come I can't change the cost of the sandbags from 0? I changed g_item_bolsas from 0 to 25 and still nothing....yes I recompiled.

gokajko
05-13-2011, 06:40
Can someone do a round sandbags limit?
Please PM!

sLq
05-19-2011, 19:11
error to compile /tmp/textQxpvHf.sma(22) : fatal error 100: cannot read from file: "zombieplague.inc"


HELP ?

this is my sma ===========================================

-----------------------------------
-*- [ZP] Sandbags -*-
-----------------------------------

~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~

Original by SAMURAI, Upgraded to zp by LARP
[email protected] (Chile) Languaje spanish!

============================================= ===================================*/


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <zombieplague.inc>

// 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 stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "15 Sandbags" }
const g_item_bolsas = 15
new g_itemid_bolsas
new ZPSTUCK, g_BINDMODE, g_MSGMODE

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.1", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
g_BINDMODE = register_cvar("zp_pb_bind","0"); //Auto bind L Key!
g_MSGMODE = register_cvar("zp_pb_msg","1"); //
ZPSTUCK = register_cvar("zp_pb_stuck","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","200"); // 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");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_pb_stuckeffects","1")
cvar[2] = register_cvar("zp_pb_stuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

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;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_bolsas)
{
g_bolsas[player]+= 15
cmd_bind(player)
set_task(0.3,"show_the_menu",player)
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(player, "Plugin By LARP^n Chile 2008")
}
}

}

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

}

lechoo
10-05-2011, 04:31
Hey, is this possible to edit this plugin like that:
When zombie destroys the sandbag, he gets 1 ammo pack as reward.
I really need this. :)

mottzi
10-12-2011, 06:25
This is not Half-life 2 Engine this is Half-life engine so it's not possible to destroy things...

Idiotic...

Xphen
04-13-2012, 21:57
How do I change the amount of sandbags given?
And the price?

KillerMasa
05-19-2012, 17:22
Can you change the sandbags work in normal server public ?

AmineKyo
05-19-2012, 17:33
Can you change the sandbags work in normal server public ?

The idea tooken from Public Server Plugin

EDIT : Original plugin Pallets with Bags (http://forums.alliedmods.net/showthread.php?p=455476) (BY SAMURAI)

KillerMasa
05-19-2012, 17:42
I don't saw it, any way thank you.

Crisislord
06-17-2012, 05:31
He said to modify the g_item_bolas to get the new cost but it doesn't work.
The cost remains 0.

Help plz host to fix this post update of plugin!

gogicaa
06-17-2012, 06:18
He said to modify the g_item_bolas to get the new cost but it doesn't work.
The cost remains 0.

Help plz host to fix this post update of plugin!
Change in .sma ...

lechoo
07-16-2012, 05:27
Hey, I'm using this plugin in my server, but I've got a problem. How to change ammount of bought SandBags? By deafult You buy 15 bags for 18 AP, I want to set 2 bags for 5 AP, but I can't find in .sma where to edit ammount of them.

FearyDust
02-16-2013, 16:32
Please someone make the plugin to give 2 sandbags when the extra item is bought

EDUTz
02-16-2013, 18:59
try this:

FearyDust
02-16-2013, 19:21
I tried editing the two "15" with "2" already, it's not working.

EDUTz
02-17-2013, 07:40
It works, you haven't tried at all what i gave you.

FearyDust
02-17-2013, 07:49
It's not working it costs 0 ammo.. when i change it to my plugin it's back to 30 ammo

EDUTz
02-17-2013, 17:44
const g_item_bolsas = 0
---------->
const g_item_bolsas = 15

then recompile

FearyDust
02-27-2013, 08:40
It costs 0 ammo again

EDUTz
02-27-2013, 16:05
change the price in zp_extraitems.

FearyDust
02-27-2013, 19:01
If you have bothered to read the last few posts, you would have undarstood that it's set on 30 and in my plugin (that is working) it's 30 now it's not working because of the edit if i put my old plugin it's 30 cuz of the cvar in extraitems...... sorry to be rood, but what you are doing it's even worst.. is there no coder in the forum that can help ?

EDUTz
02-27-2013, 21:08
I've just tested it and it works.

KuteManaal
03-14-2013, 06:24
pff my server is abusing this

FearyDust
03-15-2013, 07:32
I've just tested it and it works.

Yes it's working now thanks, can you tell me what part of the code must i change in order to make the bags more or less

EDUTz
03-19-2013, 20:42
Yes it's working now thanks, can you tell me what part of the code must i change in order to make the bags more or less

new palletscout = 2; //number of sandbags
const g_item_bolsas = 15 //price of sandbags
g_bolsas[player]+= 2 //hardcoded palets count

FearyDust
05-14-2013, 12:34
I need modification, so that every player may have only 1 sand bag per round ?

/*============================================ ====================================

-----------------------------------
-*- [ZP] Sandbags -*-
-----------------------------------

~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~

Original by SAMURAI, Upgraded to zp by LARP
[email protected] (Chile) Languaje spanish!

============================================= ===================================*/


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <zombieplague.inc>

// 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 = 2;

/* 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 stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "2 Sandbags" }
const g_item_bolsas = 30
new g_itemid_bolsas
new ZPSTUCK, g_BINDMODE, g_MSGMODE

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.1", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
g_BINDMODE = register_cvar("zp_pb_bind","0"); //Auto bind L Key!
g_MSGMODE = register_cvar("zp_pb_msg","1"); //
ZPSTUCK = register_cvar("zp_pb_stuck","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","200"); // 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");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_pb_stuckeffects","1")
cvar[2] = register_cvar("zp_pb_stuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

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;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_bolsas)
{
g_bolsas[player]+= 2
cmd_bind(player)
set_task(0.3,"show_the_menu",player)
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(player, "Plugin By LARP^n Chile 2008")
}
}

}

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

}

Catastrophe
05-14-2013, 13:00
try :-


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
//#include <fun>
#include <zombieplague.inc>

#define PLUGIN_NAME "Pallets with Bags"
#define PLUGIN_VERSION "0.2c"
#define PLUGIN_AUTHOR "SAMURAI"

// 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)

#define fm_get_user_noclip(%1) (pev(%1, pev_movetype) == MOVETYPE_NOCLIP)

// cvars
new pnumplugin, remove_nrnd, maxpallets, phealth;

// num of pallets with bags
new palletscout = 0;

new bool:done[33]

/* 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 stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "15 Sandbags" }
const g_item_bolsas = 18
new g_itemid_bolsas
new ZPSTUCK

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.0", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
ZPSTUCK = register_cvar("zp_pb_stuck","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","200"); // 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");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_autounstuckeffects","1")
cvar[2] = register_cvar("zp_autounstuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
new szMenuBody[256];
new keys;

new nLen = format( szMenuBody, 255, "\ySand Bags:^n" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. Place a Sandbags" );
//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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
new money = g_bolsas[id]
if ( money < 1 )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

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
client_print(id, print_chat, "[ZP] You have placed a Sandbags, you have %i remaining", g_bolsas[id])

return PLUGIN_HANDLED;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !fm_get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(player, itemid)
{
if(!done[player])
{
if (itemid == g_itemid_bolsas)
{
g_bolsas[player]+= 15
client_print(player, print_chat, "[ZP] You have %i sandbags, to use type 'say / pb'", g_bolsas[player])
done[player] = true
}
}
else
{

client_print(player, print_chat, "[ZP] Some one else has bought this ")
}

}

Cigojlo
05-16-2013, 16:10
Help for this pls, there is a options maximum sandbags(but this is for all) is it possible to code plugin 2 sandbags pere player per round?

Cigojlo
05-19-2013, 09:00
plssss any help

being noob
05-21-2013, 03:23
Help for this pls, there is a options maximum sandbags(but this is for all) is it possible to code plugin 2 sandbags pere player per round?

are u going to set every players max sandbag ammount each round?

maybe u should increase limit for vip :)

FearyDust
05-22-2013, 11:47
Does this cvar means that if i set it on "1" player will be able to buy only 1 time per round the sandbags !?

zp_pb_limit = Limits the sandbags, this is to prevent the rise of latency on the server (200 default)

Catastrophe
05-22-2013, 12:31
no that's just stuff that sets, models of pallets or smthing...

FearyDust
05-23-2013, 12:15
Catastrophe (https://forums.alliedmods.net/member.php?u=188268) on the first round everything is ok. All players can buy only 1 time the sandbags. On the second round only 1 player was able to buy sandbags 1 time, from 4 players and on the 3rd round, no one was able to buy even 1 time sandbags .. fix it plz

I need modification, so that every player may have only 1 sand bag per round ?

/*============================================ ====================================

-----------------------------------
-*- [ZP] Sandbags -*-
-----------------------------------

~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~

Original by SAMURAI, Upgraded to zp by LARP
[email protected] (Chile) Languaje spanish!

============================================= ===================================*/


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <zombieplague.inc>

// 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 = 2;

/* 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 stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "2 Sandbags" }
const g_item_bolsas = 30
new g_itemid_bolsas
new ZPSTUCK, g_BINDMODE, g_MSGMODE

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.1", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
g_BINDMODE = register_cvar("zp_pb_bind","0"); //Auto bind L Key!
g_MSGMODE = register_cvar("zp_pb_msg","1"); //
ZPSTUCK = register_cvar("zp_pb_stuck","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","200"); // 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");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_pb_stuckeffects","1")
cvar[2] = register_cvar("zp_pb_stuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

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;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_bolsas)
{
g_bolsas[player]+= 2
cmd_bind(player)
set_task(0.3,"show_the_menu",player)
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(player, "Plugin By LARP^n Chile 2008")
}
}

}

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

}

Cigojlo
05-26-2013, 14:04
Fear dust come on my thread Catastrophe make perfect code,its working for me try

FearyDust
05-31-2013, 11:11
Fear dust come on my thread Catastrophe make perfect code,its working for me try

Catastrophe (http://forums.alliedmods.net/member.php?u=188268) on the first round everything is ok. All players can buy only 1 time the sandbags. On the second round only 1 player was able to buy sandbags 1 time, from 4 players and on the 3rd round, no one was able to buy even 1 time sandbags .. fix it plz

Catastrophe
06-05-2013, 01:13
Catastrophe (http://forums.alliedmods.net/member.php?u=188268) on the first round everything is ok. All players can buy only 1 time the sandbags. On the second round only 1 player was able to buy sandbags 1 time, from 4 players and on the 3rd round, no one was able to buy even 1 time sandbags .. fix it plz


Which code are u talking abt? post it here... i'll try

Ju22dith
06-05-2013, 02:39
I will convert to 5.0 for youhttp://meron.gcapc.com/6.jpghttp://meron.gcapc.com/7.jpghttp://meron.gcapc.com/8.jpghttp://meron.gcapc.com/9.jpg

FearyDust
06-23-2013, 10:05
Catastrohpe, when i buy "Extra sandbags" for 25 ammo i get 2 sandbags to place. Can you make it, so that i can place only those 2 sandbags that i have bought for 25 ammo and no more for the current round. Even if i buy another "Extra sandbags" for 25 ammo and i get another 2 pallets, the server to forbid me to use them on the same round. In other words every player can place 2 pallets that have been bought for 25 ammo and no more for the current round. He can buy 10 "extra sandbags" if he wants, but the server to allow him to place only 2 for 1 round. Can you make it, please it's big problem ?


Here is the default plugin. I have only replaced ammo cost and pallet count for anyone else who might want to use it:

/*============================================ ====================================

-----------------------------------
-*- [ZP] Sandbags -*-
-----------------------------------

~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~

Original by SAMURAI, Upgraded to zp by LARP
[email protected] (Chile) Languaje spanish!

============================================= ===================================*/


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <zombieplague.inc>

// 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 = 2;

/* 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 stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "2 Sandbags" }
const g_item_bolsas = 25
new g_itemid_bolsas
new ZPSTUCK, g_BINDMODE, g_MSGMODE

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.1", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
g_BINDMODE = register_cvar("zp_pb_bind","0"); //Auto bind L Key!
g_MSGMODE = register_cvar("zp_pb_msg","1"); //
ZPSTUCK = register_cvar("zp_pb_stuck","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");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_pb_stuckeffects","1")
cvar[2] = register_cvar("zp_pb_stuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

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;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_bolsas)
{
g_bolsas[player]+= 2
cmd_bind(player)
set_task(0.3,"show_the_menu",player)
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(player, "Plugin By LARP^n Chile 2008")
}
}

}

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

}

Catastrophe
06-23-2013, 11:09
I have made the similar code, atleast 5 times, check my other posts, or the main sandbags plugin.... i'm n no mood to code it all over again.... :\

If you dont wanna see it, w8 sm1 else (mostly wicho) will help :D

wicho
06-23-2013, 14:32
Check this post: https://forums.alliedmods.net/showthread.php?t=216336

Catastrophe
06-24-2013, 01:29
Check this post: https://forums.alliedmods.net/showthread.php?t=216336

Love you bro ... (No homo)

FearyDust
06-24-2013, 02:21
Yes i found it 10x, but there is problem that's bothering me i hope you can fix it. I buy 2 sandbags for 25 ammo and i use them. I buy another 2 sandbags for 25 ammo, and the plugin does't let me use them (that's ok - the restriction is working ). But on the next round those sandbags dissapear they don't stack, so i am 25 ammo in loss, can you fix that ? I would like to be able to stack sandbags, like to stack 20 sandbags and use 2 sandbags per round, it would be very comfortable for the players. You think you can do it ? And 10x for the help, you are good supporter, even if you are not able to do this modification, it'll still do fine job.

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
//#include <fun>
#include <zombieplague.inc>

#define PLUGIN_NAME "Pallets with Bags"
#define PLUGIN_VERSION "0.2c"
#define PLUGIN_AUTHOR "SAMURAI"

// 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)

#define fm_get_user_noclip(%1) (pev(%1, pev_movetype) == MOVETYPE_NOCLIP)

// cvars
new pnumplugin, remove_nrnd, maxpallets, phealth;

// num of pallets with bags
new palletscout = 2;

new bool:done[33]

/* 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 stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0,

1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -

1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0,

2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -

2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0,

3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -

3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0,

4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -

4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0,

5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -

5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "2 Sandbags" }
const g_item_bolsas = 25
new g_itemid_bolsas
new ZPSTUCK

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.0", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
ZPSTUCK = register_cvar("zp_pb_stuck","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");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_autounstuckeffects","1")
cvar[2] = register_cvar("zp_autounstuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
new szMenuBody[256];
new keys;

new nLen = format( szMenuBody, 255, "\ySand Bags:^n" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. Place a Sandbags" );
//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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
new money = g_bolsas[id]
if ( money < 1 )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

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
client_print(id, print_chat, "[ZP] You have placed a Sandbags, you have %i remaining", g_bolsas[id])

return PLUGIN_HANDLED;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
for ( new id; id <= get_maxplayers(); id++)
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

done[id] = false
}

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !fm_get_user_noclip(player) && !(pev(player,pev_solid) &

SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(id, itemid)
{
if (itemid == g_itemid_bolsas)
{
if(!done[id])
{
g_bolsas[id]+= 2
client_print(id, print_chat, "[ZP] You have %i sandbags, to use type 'say / pb'", g_bolsas[id])
done[id] = true
}
}
else
{

client_print(id, print_chat, "[ZP] Some one else has bought this ")
}

}

Catastrophe
06-24-2013, 02:37
Try:-


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
//#include <fun>
#include <zombieplague.inc>

#define PLUGIN_NAME "Pallets with Bags"
#define PLUGIN_VERSION "0.2c"
#define PLUGIN_AUTHOR "SAMURAI"

// 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)

#define fm_get_user_noclip(%1) (pev(%1, pev_movetype) == MOVETYPE_NOCLIP)

// cvars
new pnumplugin, remove_nrnd, maxpallets, phealth;

// num of pallets with bags
new palletscout = 0;

new bool:done[33], set_next[33]

/* 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 stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0,

1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -

1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0,

2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -

2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0,

3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -

3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0,

4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -

4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0,

5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -

5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "15 Sandbags" }
const g_item_bolsas = 18
new g_itemid_bolsas
new ZPSTUCK

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.0", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
ZPSTUCK = register_cvar("zp_pb_stuck","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","200"); // 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");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_autounstuckeffects","1")
cvar[2] = register_cvar("zp_autounstuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
new szMenuBody[256];
new keys;

new nLen = format( szMenuBody, 255, "\ySand Bags:^n" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. Place a Sandbags" );
//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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
new money = g_bolsas[id]
if ( money < 1 )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

return PLUGIN_HANDLED;
}



public place_palletwbags(id)
{

if(set_next[id] >= 2)
return PLUGIN_HANDLED;

set_next[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
client_print(id, print_chat, "[ZP] You have placed a Sandbags, you have %i remaining", g_bolsas[id])

return PLUGIN_HANDLED;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
for ( new id; id <= get_maxplayers(); id++)
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();
set_next[id] = 0

}

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !fm_get_user_noclip(player) && !(pev(player,pev_solid) &

SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(id, itemid)
{
if (itemid == g_itemid_bolsas)
{
if(!done[id])
{
g_bolsas[id]+= 2
client_print(id, print_chat, "[ZP] You have %i sandbags, to use type 'say / pb'", g_bolsas[id])
done[id] = true
}
}
else
{

client_print(id, print_chat, "[ZP] Some one else has bought this ")
}

}

FearyDust
06-24-2013, 22:48
No it doesn't stack them for the next round i spend 75 ammo to buy 3 x 2 sandbags i used 2 sandbags and for the next round i didn't have those 4 that i should have

Catastrophe
06-25-2013, 01:23
Try this:-
Shud work....


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
//#include <fun>
#include <zombieplague.inc>

#define PLUGIN_NAME "Pallets with Bags"
#define PLUGIN_VERSION "0.2c"
#define PLUGIN_AUTHOR "SAMURAI"

// 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)

#define fm_get_user_noclip(%1) (pev(%1, pev_movetype) == MOVETYPE_NOCLIP)

// cvars
new pnumplugin, remove_nrnd, maxpallets, phealth;

// num of pallets with bags
new palletscout = 0;

new set_next[33]

/* 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 stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0,

1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -

1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0,

2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -

2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0,

3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -

3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0,

4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -

4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0,

5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -

5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "15 Sandbags" }
const g_item_bolsas = 18
new g_itemid_bolsas
new ZPSTUCK

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.0", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
ZPSTUCK = register_cvar("zp_pb_stuck","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","200"); // 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");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_autounstuckeffects","1")
cvar[2] = register_cvar("zp_autounstuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
new szMenuBody[256];
new keys;

new nLen = format( szMenuBody, 255, "\ySand Bags:^n" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. Place a Sandbags" );
//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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
new money = g_bolsas[id]
if ( money < 1 )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

return PLUGIN_HANDLED;
}



public place_palletwbags(id)
{

if(set_next[id] >= 2)
return PLUGIN_HANDLED;

set_next[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
client_print(id, print_chat, "[ZP] You have placed a Sandbags, you have %i remaining", g_bolsas[id])

return PLUGIN_HANDLED;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
for ( new id; id <= get_maxplayers(); id++)
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();
set_next[id] = 0

}

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !fm_get_user_noclip(player) && !(pev(player,pev_solid) &

SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(id, itemid)
{
if (itemid == g_itemid_bolsas)
{

g_bolsas[id]+= 2
client_print(id, print_chat, "[ZP] You have %i sandbags, to use type 'say / pb'", g_bolsas[id])

}

}

FearyDust
07-12-2013, 13:00
Sorry i was away, no it doesn't work. I buy 10 sandbags i place 2 i'm left with 8, i try to place another 3 but on all 3 attempts the server sais i have no sandbags to place - that is ok, but on the next round i should have 8 but i have 5 because of the 3 times i tried to place it. I tested this 5 times i'm sure this is what is happening. The next round i bought 10 placed 2, and tried to place 7 times and the server didn't let me, and on the next round i was left with 1 because of the 7 tryes that i have made.

And one more thing, on the original plugin, when you buy sandbags it lets you place them at the moment, now i have to type /pb in order to start placing them.

Nizolinas
01-19-2014, 00:15
thx man!

szafa323
01-19-2014, 05:22
PL:Może ktoś zrobić tak, aby można było zabierać swoje worki? Pod 2 : Zabierz worek.
EN:Can someone make so that you can take your bags? At 2: Take the bag.

KOF
08-31-2014, 15:32
https://forums.alliedmods.net/showthread.php?t=247363

if you develop it, please post at this link.

chibo
09-07-2014, 13:27
AYUDA!!!!
Hola Este plugins te daba 15 sacos de arena yo lo puse en "2" ahora el problema es que los humanos
pueden dispararle y destruir el saco de arena yo quiero que solo los zombies puedan destruirlo
Yo recuerdo que la extra laser mine también tenia ese problema pero había un plugins que evitaba que
al dispararle no se rompiera no se si sea el mismo caso de el saco tal vez me puedan ayudar.

facebook: https://www.facebook.com/Luch0djgt

zmd94
09-08-2014, 05:26
@ Chibo (https://forums.alliedmods.net/member.php?u=253223), please use English language.

pupil0888
06-13-2015, 10:15
I want that humans can pass through the sandbag. you can do that?

vikasvishwakarma
12-07-2015, 07:43
i have a sandbag sma where owner of the sandbag can pass through it but the problem is it gives 2 sb per map. can anyone fix it and re post it please i want it to be 2 sandbag per round per player.

Chihuahuax
12-07-2015, 19:25
i have a sandbag sma where owner of the sandbag can pass through it but the problem is it gives 2 sb per map. can anyone fix it and re post it please i want it to be 2 sandbag per round per player.

Cant help you much cuz im on mobile

All u nid to do is:
- add done[id] = false at event_newround

Edit:
I see 2 event_newround in that plugin. Remove the new one and replace it with the old one (remove the /* and */ signs)

vikasvishwakarma
12-08-2015, 04:26
Cant help you much cuz im on mobile

All u nid to do is:
- add done[id] = true at event_newround

Edit:
I see 2 event_newround in that plugin. Remove the new one and replace it with the old one (remove the /* and */ signs)

thanks for replying i have tried by changing it to true. but after adding the plugin in the server it says max sandbag limit reached. even i have not used any of the sandbag. looking forward for help..:) thanks

Chihuahuax
12-08-2015, 05:37
thanks for replying i have tried by changing it to true. but after adding the plugin in the server it says max sandbag limit reached. even i have not used any of the sandbag. looking forward for help..:) thanks

lol my bad sorry, it should be "false"

vikasvishwakarma
12-08-2015, 05:58
lol my bad sorry, it should be "false"

lol. anyway can you please fix it. even with false it dose not work. in first round i can plant 2 sandbag, but in second round the sandbag dose not decipher and if someone has broken the sandbag in first round it wont allow the player to place sandbag in second round it says Max sandbag limit reached!

I want it to be 2 sandbag per round per player... :)

Krtola
12-09-2015, 04:30
I want it to be 2 sandbag per round per player... :)

Try this:
/*============================================ ====================================

-----------------------------------
-*- [ZP] Sandbags -*-
-----------------------------------

~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~

Original by SAMURAI, Upgraded to zp by LARP
[email protected] (Chile) Languaje spanish!

============================================= ===================================*/


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <zombieplague.inc>

// 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 stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "15 Sandbags" }
const g_item_bolsas = 0
new g_itemid_bolsas
new ZPSTUCK, g_BINDMODE, g_MSGMODE

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.1", "LARP")

register_logevent("round_end", 2, "1=Round_End")

set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
g_BINDMODE = register_cvar("zp_pb_bind","0"); //Auto bind L Key!
g_MSGMODE = register_cvar("zp_pb_msg","1"); //
ZPSTUCK = register_cvar("zp_pb_stuck","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","200"); // 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");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_pb_stuckeffects","1")
cvar[2] = register_cvar("zp_pb_stuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

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;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public round_end()
{
palletscout = 0
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_bolsas)
{
g_bolsas[player]+= 15
cmd_bind(player)
set_task(0.3,"show_the_menu",player)
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(player, "Plugin By LARP^n Chile 2008")
}
}

}

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

}

Chihuahuax
12-09-2015, 05:20
here you go

vikasvishwakarma
12-10-2015, 16:47
thanks for the help :)

Mihai94
02-27-2018, 11:10
hello, can you make this sandbags plugin like when a smash breaks the bag to chat in on all the players who broke it?


/*============================================ ====================================

-----------------------------------
-*- [ZP] Sandbags -*-
-----------------------------------

~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~

Original by SAMURAI, Upgraded to zp by LARP
[email protected] (Chile) Languaje spanish!

============================================= ===================================*/


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <zombie_plague_special.inc>

// 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 stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "Saci Baricada X10" }
const g_item_bolsas = 35
new g_itemid_bolsas
new ZPSTUCK, g_BINDMODE, g_MSGMODE

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: Saci Baricada X10", "1.1", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
g_BINDMODE = register_cvar("zp_pb_bind","0"); //Auto bind L Key!
g_MSGMODE = register_cvar("zp_pb_msg","1"); //
ZPSTUCK = register_cvar("zp_pb_stuck","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","150"); // 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");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_pb_stuckeffects","1")
cvar[2] = register_cvar("zp_pb_stuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
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, "[Saci Nisip] Nu Trebuie Sa Plasezi Saci De Nisip!")
return PLUGIN_CONTINUE
}
g_bolsas[id]-= 1
place_palletwbags(id);
show_the_menu(id,level,cid);
return PLUGIN_CONTINUE
}
client_print(id, print_chat, "[Saci Nisip] Zombii Nu Pot Folosi Acest Item!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[Saci Nisip] Zombi Au Ca Scop Acesti Saci Cu Paleti");
}
else
client_print(id, print_chat, "[Saci Nisip] Nu Au Ca Scop O Entitate Valida !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX Saci Nisip] Ati Scos Toate Tipurile De Paleti Cu Saci !");
show_the_menu(id,level,cid);
}
*/

}

return PLUGIN_HANDLED;
}



public place_palletwbags(id)
{

if( palletscout == get_pcvar_num(maxpallets) )
{
client_print(id,print_chat,"[Saci Nisip] Ati Atins Limita Maxima De %d Saci De Nisip Pe 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,"[Saci Nisip] Nu Poti Pune Saci De Nisip Pe Cer!");
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, "[Saci Nisip] Ati Plasat Un Sac De Nisip.")
return PLUGIN_HANDLED;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_bolsas)
{
g_bolsas[player]+= 15
cmd_bind(player)
set_task(0.3,"show_the_menu",player)
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(player, "Plugin By LARP^n Chile 2008")
}
}

}

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

}



example: player Mihai destroyed Andrei's bag and received 3 ammo.

Mihai94
03-01-2018, 02:00
up?

jievylook
03-05-2019, 12:43
I urgently need someone to share the extra item of x2 sandbags, similar to the ones they have on the silentgamerz and lgz zombie plague servers.

I need that each player can only make 1 purchase of this extra item per round.

and that it changes color when the zombies are hitting the sandbags.

Krtola
04-25-2019, 07:37
With buy limit.

/*============================================ ====================================

-----------------------------------
-*- [ZP] Sandbags -*-
-----------------------------------

~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~

Original by SAMURAI, Upgraded to zp by LARP
[email protected] (Chile) Languaje spanish!

============================================= ===================================*/


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <zombieplague.inc>

// 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 stuck[33]
new g_bolsas[33];
new cvar[3]

new bool:g_just_one[33]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "15 Sandbags" }
const g_item_bolsas = 0
new g_itemid_bolsas
new ZPSTUCK, g_BINDMODE, g_MSGMODE

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.1", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
g_BINDMODE = register_cvar("zp_pb_bind","0"); //Auto bind L Key!
g_MSGMODE = register_cvar("zp_pb_msg","1"); //
ZPSTUCK = register_cvar("zp_pb_stuck","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","200"); // 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");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_pb_stuckeffects","1")
cvar[2] = register_cvar("zp_pb_stuckwait","7")

register_logevent("logevent_round_start", 2, "1=Round_Start")
register_logevent("round_end", 2, "1=Round_End")
}

public logevent_round_start()
{
static id

for(id = 1; id <= get_maxplayers() ; id++)
{
if(g_just_one[id])
{
g_just_one[id] = false
}
}
}

public round_end()
{
static id

for(id = 1; id <= get_maxplayers() ; id++)
{
if(g_just_one[id])
{
g_just_one[id] = false
}
}
}

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;
}

if ( !zp_get_user_zombie(id) )
{
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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

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;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(player, itemid)
{
if(itemid == g_itemid_bolsas)
{
if(g_just_one[player])
{
client_print(player, print_center, "Buy limit activated. Try in next round.")
return PLUGIN_HANDLED
}

g_just_one[player] = true
g_bolsas[player]+= 15
cmd_bind(player)
set_task(0.3,"show_the_menu",player)

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(player, "Plugin By LARP^n Chile 2008")
}
}
return PLUGIN_CONTINUE

}

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

}

jievylook
05-05-2019, 11:20
here you go

Can you add a glow that changes health as the health is removed from the sandbag?
and you can put 2 sandbags with a single buy? and that the purchase is limited to a single purchase for each player per round

Also when a new round starts, remove all the sandbags that were placed in the previous round.

DON KHAN 1
06-07-2019, 00:58
can anybody make it for vip?
i tried alot but got some bugs.

Noam
06-23-2019, 09:18
can anybody make it for vip?
i tried alot but got some bugs.

/*============================================ ====================================

-----------------------------------
-*- [ZP] Sandbags -*-
-----------------------------------

~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~

Original by SAMURAI, Upgraded to zp by LARP
[email protected] (Chile) Languaje spanish!

============================================= ===================================*/


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <zombieplague>
#include <zmvip>

// 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/zombie_plague/SandBag/SandBag1.mdl",
"models/zombie_plague/SandBag/SandBag.mdl"
}

new stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "2 Sandbags" }
new const g_item_name1[] = { "For Save You From Zombies" }
const g_item_bolsas = 45
new g_itemid_bolsas
new ZPSTUCK, g_BINDMODE, g_MSGMODE

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.1", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zv_register_extra_item(g_item_name, g_item_name1, g_item_bolsas, ZV_TEAM_HUMAN)
/* Register the cvars */
g_BINDMODE = register_cvar("zp_pb_bind","0"); //Auto bind L Key!
g_MSGMODE = register_cvar("zp_pb_msg","1"); //
ZPSTUCK = register_cvar("zp_pb_stuck","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","200"); // 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("\ySandBags:"), 1023, "menu_command" );
register_clcmd("say /pb","show_the_menu");
register_clcmd("say /sb","show_the_menu");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_pb_stuckeffects","1")
cvar[2] = register_cvar("zp_pb_stuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
new szMenuBody[256];
new keys;

new nLen = format( szMenuBody, 255, "\ySandBags:^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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

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;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zv_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_bolsas)
{
g_bolsas[player]+= 2
cmd_bind(player)
set_task(0.3,"show_the_menu",player)
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(player, "Plugin By LLRAP ^nChile 2008 :)")
}
}

}

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

}

DON KHAN 1
06-28-2019, 02:01
/*============================================ ====================================

-----------------------------------
-*- [ZP] Sandbags -*-
-----------------------------------

~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~

Original by SAMURAI, Upgraded to zp by LARP
[email protected] (Chile) Languaje spanish!

============================================= ===================================*/


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <zombieplague>
#include <zmvip>

// 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/zombie_plague/SandBag/SandBag1.mdl",
"models/zombie_plague/SandBag/SandBag.mdl"
}

new stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "2 Sandbags" }
new const g_item_name1[] = { "For Save You From Zombies" }
const g_item_bolsas = 45
new g_itemid_bolsas
new ZPSTUCK, g_BINDMODE, g_MSGMODE

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra: SandBags", "1.1", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zv_register_extra_item(g_item_name, g_item_name1, g_item_bolsas, ZV_TEAM_HUMAN)
/* Register the cvars */
g_BINDMODE = register_cvar("zp_pb_bind","0"); //Auto bind L Key!
g_MSGMODE = register_cvar("zp_pb_msg","1"); //
ZPSTUCK = register_cvar("zp_pb_stuck","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","200"); // 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("\ySandBags:"), 1023, "menu_command" );
register_clcmd("say /pb","show_the_menu");
register_clcmd("say /sb","show_the_menu");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_pb_stuckeffects","1")
cvar[2] = register_cvar("zp_pb_stuckwait","7")

}


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;
}

if ( !zp_get_user_zombie(id) )
{
new szMenuBody[256];
new keys;

new nLen = format( szMenuBody, 255, "\ySandBags:^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
return PLUGIN_HANDLED;
}
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:
{
if ( !zp_get_user_zombie(id) )
{
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
}
client_print(id, print_chat, "[ZP] The zombies can not use this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

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;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

}


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zv_extra_item_selected(player, itemid)
{
if (itemid == g_itemid_bolsas)
{
g_bolsas[player]+= 2
cmd_bind(player)
set_task(0.3,"show_the_menu",player)
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(player, "Plugin By LLRAP ^nChile 2008 :)")
}
}

}

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

}


Thank You For This Help

Noam
09-09-2019, 13:38
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#include <xs>
#include <fun>
#include <zombieplague>

// 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)

#define fm_get_user_noclip(%1) (pev(%1, pev_movetype) == MOVETYPE_NOCLIP)

// cvars
new pnumplugin, remove_nrnd, maxpallets, phealth;

// num of pallets with bags
new palletscout = 0;

new bool:done[33]

/* Models for pallets with bags .
Are available 2 models, will be set a random of them */
new g_models[][] =
{
"models/TheKingdom/sb1.mdl",
"models/TheKingdom/sb.mdl"
}

new stuck[33]
new g_bolsas[33];
new cvar[3]

new const Float:size[][3] = {
{0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
{0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
{0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
{0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
{0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const g_item_name[] = { "Sandbags" }
const g_item_bolsas = 30
new g_itemid_bolsas
new ZPSTUCK

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/


public plugin_init()
{
/* Register the plugin */

register_plugin("[RoD|*] Extra: SandBags", "1.1", "LARP")
set_task(0.1,"checkstuck",0,"",0,"b")
g_itemid_bolsas = zp_register_extra_item(g_item_name, g_item_bolsas, ZP_TEAM_HUMAN)
/* Register the cvars */
ZPSTUCK = register_cvar("zp_pb_stuck","1")
pnumplugin = register_cvar("zp_pb_enable","1"); // 1 = ON ; 0 = OFF
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", "RoundStart", "a", "1=0", "2=0" );

/* This is for menuz: */
register_menucmd(register_menuid("\ySand Bags:"), 1023, "menu_command" );
register_clcmd("say /sb","show_the_menu");
register_clcmd("say_team /sb","show_the_menu");

register_clcmd("say /buy_sb","gbuy");
register_clcmd("say_team /buy_sb","gbuy");

//RegisterHam(Ham_TakeDamage,"func_wall","fw_TakeDamage");
//cvar[0] = register_cvar("zp_autounstuck","1")
cvar[1] = register_cvar("zp_pb_stuckeffects","1")
cvar[2] = register_cvar("zp_pb_stuckwait","7")


RegisterHam(Ham_TakeDamage,"func_wall","fw_TakeDamage");
RegisterHam(Ham_Killed, "func_wall", "fw_PlayerKilled", 1)


}
public RoundStart(id)
{
remove_allpalletswbags();
done[id] = false;
}
//Here is what I am tryin to make just owner and zombie to be able to destroy sandbags
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
//Victim is not lasermine.
new sz_classname[32]
entity_get_string( victim , EV_SZ_classname , sz_classname, 31 )
if( !equali(sz_classname,"amxx_pallets") )
return HAM_IGNORED;

//Attacker is zombie
if( zp_get_user_zombie( attacker ) )
return HAM_IGNORED;

//Block Damage
return HAM_SUPERCEDE;
}

public fw_PlayerKilled(victim, attacker, shouldgib)
{
new sz_classname[32], Float: health
entity_get_string( victim , EV_SZ_classname , sz_classname, charsmax(sz_classname))

health = entity_get_float(victim, EV_FL_health)

if(equal(sz_classname, "amxx_pallets") && is_valid_ent(victim) && zp_get_user_zombie(attacker) && health <= 0.0)
{
zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + 6)
ColorChat(0, "^3%s^1 earned^4 6^1 Ammopacks for^4 destroying^1 a^3 sandbang^1!",szName(attacker))
return HAM_IGNORED;
}
return HAM_IGNORED;
}

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;
}

if ( !zp_get_user_zombie(id) )
{
new szMenuBody[256];
new keys;

new nLen = format( szMenuBody, 255, "\ySand Bags:^n" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. Place a Sandbags" );
//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
return PLUGIN_HANDLED;
}
ColorChat(id, "The^3 zombies^1 can't^4 use^1 this command!")
return PLUGIN_HANDLED;
}


public menu_command(id,key,level,cid)
{

switch( key )
{
// place a pallet with bags
case 0:
{
if ( !zp_get_user_zombie(id) )
{
new money = g_bolsas[id]
if ( money < 1 )
{
ColorChat(id, "You^3 don't^1 have any^4 sandbag^1 to^3 place^1 one!")
return PLUGIN_CONTINUE
}
g_bolsas[id]-= 1
place_palletwbags(id);
show_the_menu(id,level,cid);
return PLUGIN_CONTINUE
}
ColorChat(id, "The^3 zombies^1 can't^4 use^1 this!!")
return PLUGIN_CONTINUE
}

// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_bolsas[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[RoD|*] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[RoD|*] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_bolsas[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

return PLUGIN_HANDLED;
}



public place_palletwbags(id)
{

if( palletscout == get_pcvar_num(maxpallets) )
{
ColorChat(id,"For security reasons only allow^3 %d^4 Sandbags^1 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)
{
ColorChat(id,"You can't^4 put^3 sandbags^1 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);

set_pev(ent, pev_owner, id);

// num ..
palletscout++;

// confirm message
ColorChat(0, "^4%s^1 has^4 placed a ^3sandbag^1.",szName(id))

return PLUGIN_HANDLED;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}


/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======
public event_newround()
{
for ( new id; id <= get_maxplayers(); id++)
{
if( get_pcvar_num ( remove_nrnd ) == 1)
remove_allpalletswbags();

done[id] = false
g_bolsas[id] = 0
}

}
*/


/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

palletscout = 0;
}

public checkstuck() {
if ( get_pcvar_num(ZPSTUCK) == 1 )
{
static players[32], pnum, player
get_players(players, pnum)
static Float:origin[3]
static Float:mins[3], hull
static Float:vec[3]
static o,i
for(i=0; i<pnum; i++){
player = players[i]
if (is_user_connected(player) && is_user_alive(player)) {
pev(player, pev_origin, origin)
hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
if (!is_hull_vacant(origin, hull,player) && !fm_get_user_noclip(player) && !(pev(player,pev_solid) &

SOLID_NOT)) {
++stuck[player]
if(stuck[player] >= get_pcvar_num(cvar[2])) {
pev(player, pev_mins, mins)
vec[2] = origin[2]
for (o=0; o < sizeof size; ++o) {
vec[0] = origin[0] - mins[0] * size[o][0]
vec[1] = origin[1] - mins[1] * size[o][1]
vec[2] = origin[2] - mins[2] * size[o][2]
if (is_hull_vacant(vec, hull,player)) {
engfunc(EngFunc_SetOrigin, player, vec)
effects(player)
set_pev(player,pev_velocity,{0.0,0.0,0.0})
o = sizeof size
}
}
}
}
else
{
stuck[player] = 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 effects(id) {
if(get_pcvar_num(cvar[1])) {
set_hudmessage(255,150,50, -1.0, 0.65, 0, 6.0, 1.5,0.1,0.7) // HUDMESSAGE
show_hudmessage(id,"Automatic Unstuck!") // HUDMESSAGE
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0}, id )
write_short(1<<10) // fade lasts this long duration
write_short(1<<10) // fade lasts this long hold time
write_short(1<<1) // fade type (in / out)
write_byte(20) // fade red
write_byte(255) // fade green
write_byte(255) // fade blue
write_byte(255) // fade alpha
message_end()
client_cmd(id,"spk fvox/blip.wav")
}
}

public zp_extra_item_selected(id, itemid)
{
if (itemid == g_itemid_bolsas)
{
if(!done[id])
{
g_bolsas[id]+= 2
set_task(0.3,"show_the_menu",id)
ColorChat(id,"You have^3 %i^1 sandbags, to^4 use^1 type^3 '/ sb'^1.", g_bolsas[id])
done[id] = true

return PLUGIN_CONTINUE

}


else {

client_print(id, print_chat, "Max Sandbags reached !!!")
return PLUGIN_HANDLED
}

}
return PLUGIN_CONTINUE
}

public gbuy(id)
{
if ( zp_get_user_zombie(id) || !is_user_alive(id) ){
return PLUGIN_HANDLED
}

if (zp_get_user_ammo_packs(id) < g_item_bolsas) {
client_print(id, print_chat, "You don't have enough ammo pack.")
return PLUGIN_HANDLED
}

//if(!zp_core_is_zombie(id) && is_user_alive(id))
{
if(!done[id])
{
g_bolsas[id]+= 2
set_task(0.3,"show_the_menu",id)
ColorChat(id,"You have^3 %i^1 sandbags, to^4 use^1 type^3 '/ sb'^1.", g_bolsas[id])
done[id] = true
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) - g_item_bolsas)
return PLUGIN_CONTINUE
}


else {

client_print(id, print_chat, "Max Sandbags reached !!!")
return PLUGIN_HANDLED
}

}

return PLUGIN_CONTINUE

}
stock ColorChat( const index, const string[], any:... )
{
new szMsg[ 191 ], Players[ 32 ], PNum = 1;

static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "^3[TheKingdom]^1 ");

vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );

if ( index )
Players[ 0 ] = index;
else
get_players( Players, PNum, "ch" );

for ( new i; i < PNum; i++ )
{
if( is_user_connected( Players[ i ] ) )
{
message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );

write_byte( Players[ i ] );

write_string( szMsg );

message_end( );
}
}
return 1;
}

stock szName( const index )
{
static szName[ 32 ];

get_user_name( index, szName, charsmax( szName ) );

return szName;
}

Guys , you can help me ? my problem is -
when i reach limit - 2 sandbag(1 purchase) its saying me (Max Sandbag i need it)
and after its taking from me 30 ammo packs, and its write limits 2/5 3/5 4/5 5/5..
and round after i bought its saying me too (max sandbag)
and i have wrote there done[id] = false.
can you guys help me out?

Balage74
09-18-2019, 16:51
I have little modifiation (bugfixes):
Work on zp_special (just try change line 6. for other zombie mod)
and change hungarian lang:D


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <zombie_plague_special>

// 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 cvar_enabled, cvar_remround, cvar_pallethealth
new cvar_maxpallets_round,cvar_maxpallets_roundpe rsonal
new cvar_bindmode, cvar_msgmode


/* 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"
}
// num of pallets with bags
new g_palletcounter_round = 0;

new g_placedpallet[33];
new g_boughtpallet[33];


new const g_item_name[] = { "Sandbag (5x)" }
new g_itemid_bolsas

new g_maxplayers

/********************************************* ****************
************************* AMXX PLUGIN *************************
********************************************* *****************/
public plugin_precache()
{
for(new i;i < sizeof g_models;i++)
engfunc(EngFunc_PrecacheModel,g_models[i]);
}

public plugin_init()
{
/* Register the plugin */
//register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)

register_plugin("[ZP] Extra item: SandBags", "1.1", "LARP")


/* Register the cvars */
cvar_enabled = register_cvar("zp_pb_enable","1"); // 1 = ON ; 0 = OFF
cvar_bindmode = register_cvar("zp_pb_bind","0"); //Auto bind L Key!
cvar_msgmode = register_cvar("zp_pb_msg","0");
cvar_remround = register_cvar("zp_pb_remround","1");
cvar_maxpallets_round = register_cvar("zp_pb_limit","40"); // max number of pallets with bags
cvar_maxpallets_roundpersonal = register_cvar("zp_pb_personallimit","8");
cvar_pallethealth = register_cvar("zp_pb_health","200"); // 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_clcmd("say /zsak","show_the_menu");
register_clcmd("say_team /zsak","show_the_menu");
register_clcmd("say /pb","cmd_buy");
register_clcmd("say_team /pb","cmd_buy");
g_itemid_bolsas = zp_register_extra_item(g_item_name, 5, ZP_TEAM_HUMAN)
g_maxplayers = get_maxplayers()
}



public zp_extra_item_selected_pre(id, itemid)
{

if (itemid == g_itemid_bolsas)
{

if( ! get_pcvar_num( cvar_enabled ) ) return ZP_PLUGIN_SUPERCEDE
if (zp_get_human_special_class(id)) return ZP_PLUGIN_HANDLED
}

return PLUGIN_CONTINUE
}





public zp_extra_item_selected(player, itemid)
{

if (itemid == g_itemid_bolsas)
{
if( ! get_pcvar_num( cvar_enabled ) ) return ZP_PLUGIN_HANDLED
else if (zp_get_human_special_class(player)) return ZP_PLUGIN_HANDLED
else
{
g_boughtpallet[player]+= 5
if ( get_pcvar_num(cvar_bindmode) == 1 )
{
client_cmd(player,"bind l say /zsak ")

}
set_task(0.3,"show_the_menu",player)
if ( get_pcvar_num(cvar_msgmode) == 1 )
{
set_hudmessage(0, 0, 100, 0.80, 0.80, 0, 6.0, 2.0, 1.0, 1.0,-1)
show_hudmessage(player, "A plugint keszitette LARP^n Chile 2008")
}
}
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}



public cmd_buy(id)
{
new iCost = zp_get_extra_item_cost(g_itemid_bolsas)
// check if the plugin cvar is turned off
if( ! get_pcvar_num( cvar_enabled ) ){
return

}
// check if user isn't alive
if( ! is_user_alive( id ) || zp_get_user_zombie(id) || zp_get_human_special_class(id) )
{
return
}
if( zp_get_user_ammo_packs(id) < iCost )
{
return
}
g_boughtpallet[id]+= 2
if ( get_pcvar_num(cvar_bindmode) == 1 )
{
client_cmd(id,"bind l say /zsak")

}

if ( get_pcvar_num(cvar_msgmode) == 1 )
{
// set_hudmessage(0, 0, 100, 0.80, 0.80, 0, 6.0, 2.0, 1.0, 1.0,-1)
// show_hudmessage(id, "A plugint készítette LARP^n Chile 2008")

client_print_color(id, print_team_default, "^4[ZP][SB]^1 Vettél 2 db homokzsákot!");


}
show_the_menu(id)
zp_set_user_ammo_packs(id,zp_get_user_ammo_pa cks(id) - iCost)
}

public client_connect(id)
{
g_placedpallet[id] = 0
}

public client_disconnected(id)
{
g_placedpallet[id] = 0
}

/* ============================================= =======
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
============================================= =======*/
public event_newround()
{
if( get_pcvar_num ( cvar_remround ) == 1)
remove_allpalletswbags();

for ( new id = 1; id <= g_maxplayers; id++)
{
g_placedpallet[id] = 0
}


}








public show_the_menu(id)
{
// check if the plugin cvar is turned off
if( ! get_pcvar_num( cvar_enabled ) ) return
// check if user isn't alive
if( ! is_user_alive( id ) || !is_user_connected(id)|| zp_get_user_zombie(id) || zp_get_human_special_class(id) ) return



new iRemain = get_pcvar_num(cvar_maxpallets_round) - g_palletcounter_round
new MenuName[64]
format(MenuName, 63, "\yHomokzsákok: %i ",iRemain)

new menu = menu_create(MenuName, "menu_handler");


new nLen[100]
if ( g_palletcounter_round >= get_pcvar_num(cvar_maxpallets_round)||g_place dpallet[id] >= get_pcvar_num(cvar_maxpallets_roundpersonal)) format( nLen, 99, "\d Nem lehet többet lerakni (leraktál: %i/%i készlet: %i)", get_pcvar_num(cvar_maxpallets_roundpersonal), g_placedpallet[id], g_boughtpallet[id] );
else if (g_boughtpallet[id] < 1) format( nLen, 99, "\d Nincs készleten (leraktál: %i/%i készlet: %i)",g_placedpallet[id], get_pcvar_num(cvar_maxpallets_roundpersonal), g_boughtpallet[id] );
else format( nLen, 99, "\w Homokzsák elhelyezése (leraktál: %i/%i készlet: %i)",g_placedpallet[id], get_pcvar_num(cvar_maxpallets_roundpersonal), g_boughtpallet[id]);

menu_additem(menu, nLen, "", 0);
menu_additem(menu, "\w Kilépés", "", 0);
//menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu, 0);
}



public menu_handler(id,menu,key)
{
// check if the plugin cvar is turned off
if( ! get_pcvar_num( cvar_enabled ) )
{
menu_destroy(menu)
return

}
/* if ( key == MENU_EXIT )
{
menu_destroy(menu);
return ;
}*/

// check if user isn't alive
if( ! is_user_alive( id ) || !is_user_connected(id)|| zp_get_user_zombie(id) || zp_get_human_special_class(id) )
{
menu_destroy(menu)
return
}

switch( key )
{
// place a pallet with bags
case 0:
{
if( g_palletcounter_round >= get_pcvar_num(cvar_maxpallets_round)||g_place dpallet[id] >= get_pcvar_num(cvar_maxpallets_roundpersonal) )
{
if ( get_pcvar_num(cvar_msgmode) == 1 )
{
// set_hudmessage(0, 0, 100, 0.80, 0.80, 0, 6.0, 2.0, 1.0, 1.0,-1)
// show_hudmessage(id, "Nem rakhatsz több homokzsákot ebben a körben!")
client_print_color(id, print_team_default, "^4[ZP][SB]^1 Nem rakhatsz több homokzsákot ebben a körben!");

}


}

else if ( g_boughtpallet[id] < 1 )
{
if ( get_pcvar_num(cvar_msgmode) == 1 )
{
// set_hudmessage(0, 0, 100, 0.80, 0.80, 0, 6.0, 2.0, 1.0, 1.0,-1)
// show_hudmessage(id, "Nincs homokzsákod!")
client_print_color(id, print_team_default, "^4[ZP][SB]^1 Nincs homokzsákod")

}
}


else
{
place_palletwbags(id);


}

menu_destroy(menu)
show_the_menu(id);





}
case 1:
{
menu_destroy(menu)

}
// remove a pallet with bags
/*case 1:
{
if ( !zp_get_user_zombie(id) )
{
new ent, body, class[32];
get_user_aiming(id, ent, body);
if (pev_valid(ent))
{
pev(ent, pev_classname, class, 31);

if (equal(class, "amxx_pallets"))
{
g_boughtpallet[id]+= 1
fm_remove_entity(ent);
}

else
client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
}
else
client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");

show_the_menu(id,level,cid);
}
}
*/

// remove all pallets with bags
/*case 2:
{
g_boughtpallet[id]= 0
remove_allpalletswbags();
client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
show_the_menu(id,level,cid);
}
*/

}

}



public place_palletwbags(id)
{
// check if the plugin cvar is turned off
if( ! get_pcvar_num( cvar_enabled ) )
return PLUGIN_HANDLED;
// check if user isn't alive
if( ! is_user_alive( id ) || zp_get_user_zombie(id) || zp_get_human_special_class(id) )
{
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_color(id, print_team_default, "^4[ZP][SB]^1 Az égre nem tudsz elhelyezni homokzsákot!");
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(cvar_pallethealth);
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 ..
g_palletcounter_round++;
g_placedpallet[id]++
g_boughtpallet[id]-= 1
// confirm message
if ( get_pcvar_num(cvar_msgmode) == 1 )
{
set_hudmessage(0, 0, 100, 0.80, 0.80, 0, 6.0, 2.0, 1.0, 1.0,-1)
show_hudmessage(id, "Elhelyeztél egy homokzsákot^n%i Maradt", g_boughtpallet[id])
return PLUGIN_HANDLED
}
client_print_color(id, print_team_default, "^4[ZP][SB]^1 Elhelyeztél egy homokzsákot.")
return PLUGIN_HANDLED;
}

/* ============================================= =======
get_user_hitpoin stock . Was maked by P34nut, and is
like get_user_aiming but is with floats and better :o
============================================= =======*/
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;
}





/* ============================================= =======
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
============================================= =======*/
stock remove_allpalletswbags()
{
new pallets = -1;
while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets")))
fm_remove_entity(pallets);

g_palletcounter_round = 0;
}

gelsondias
04-18-2021, 10:15
how to set it up to prevent other humans or you from destroying them by shooting ?

undertaker5
04-20-2021, 13:46
how to set it up to prevent other humans or you from destroying them by shooting ?

#include <engine>
#include <hamsandwich>


public plugin_init()
{
RegisterHam(Ham_TakeDamage,"func_wall","fw_TakeDamage");
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
//Victim is not lasermine.
new sz_classname[32]
entity_get_string( victim , EV_SZ_classname , sz_classname , 31 )
if( !equali(sz_classname,"amxx_pallets") )
return HAM_IGNORED;

//Attacker is zombie
if( zp_get_user_zombie( attacker )&& is_user_alive( inflictor ) )
return HAM_IGNORED;

//Block Damage
return HAM_SUPERCEDE;
}

Aboveboat
12-13-2023, 23:59
can anyone fix is so when you purchase the sandbags theres a laser pointing to where you will place it ?