Raised This Month: $59 Target: $400
 14% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Noam
Member
Join Date: Jun 2019
Old 06-23-2019 , 09:18   Re: [ZP] Extra Item: Sand Bags BETA!
Reply With Quote #111

Quote:
Originally Posted by DON KHAN 1 View Post
can anybody make it for vip?
i tried alot but got some bugs.
PHP Code:
/*================================================================================
    
    -----------------------------------
    -*- [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 pnumpluginremove_nrndmaxpalletsphealth;

// 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.00.01.0}, {0.00.0, -1.0}, {0.01.00.0}, {0.0, -1.00.0}, {1.00.00.0}, {-1.00.00.0}, {-1.01.01.0}, {1.01.01.0}, {1.0, -1.01.0}, {1.01.0, -1.0}, {-1.0, -1.01.0}, {1.0, -1.0, -1.0}, {-1.01.0, -1.0}, {-1.0, -1.0, -1.0},
    {
0.00.02.0}, {0.00.0, -2.0}, {0.02.00.0}, {0.0, -2.00.0}, {2.00.00.0}, {-2.00.00.0}, {-2.02.02.0}, {2.02.02.0}, {2.0, -2.02.0}, {2.02.0, -2.0}, {-2.0, -2.02.0}, {2.0, -2.0, -2.0}, {-2.02.0, -2.0}, {-2.0, -2.0, -2.0},
    {
0.00.03.0}, {0.00.0, -3.0}, {0.03.00.0}, {0.0, -3.00.0}, {3.00.00.0}, {-3.00.00.0}, {-3.03.03.0}, {3.03.03.0}, {3.0, -3.03.0}, {3.03.0, -3.0}, {-3.0, -3.03.0}, {3.0, -3.0, -3.0}, {-3.03.0, -3.0}, {-3.0, -3.0, -3.0},
    {
0.00.04.0}, {0.00.0, -4.0}, {0.04.00.0}, {0.0, -4.00.0}, {4.00.00.0}, {-4.00.00.0}, {-4.04.04.0}, {4.04.04.0}, {4.0, -4.04.0}, {4.04.0, -4.0}, {-4.0, -4.04.0}, {4.0, -4.0, -4.0}, {-4.04.0, -4.0}, {-4.0, -4.0, -4.0},
    {
0.00.05.0}, {0.00.0, -5.0}, {0.05.00.0}, {0.0, -5.00.0}, {5.00.00.0}, {-5.00.00.0}, {-5.05.05.0}, {5.05.05.0}, {5.0, -5.05.0}, {5.05.0, -5.0}, {-5.0, -5.05.0}, {5.0, -5.0, -5.0}, {-5.05.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 ZPSTUCKg_BINDMODEg_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_nameg_item_name1g_item_bolsasZV_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;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_numpnumplugin ) )
        return 
PLUGIN_HANDLED;
        
        
    
// check if user isn't alive
    
if( ! is_user_aliveid ) )
    {
        
client_printidprint_chat"" ); //msg muerto
        
return PLUGIN_HANDLED;
    }
            
    if ( !
zp_get_user_zombie(id) )
    {        
        new 
szMenuBody[256];
        new 
keys;
        
        new 
nLen formatszMenuBody255"\ySandBags:^n" );
        
nLen += formatszMenuBody[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 += formatszMenuBody[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_menuidkeysszMenuBody, -);

        
// depends what you want, if is continue will appear on chat what the admin sayd
        
return PLUGIN_HANDLED;
    }
    
client_print(idprint_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 )
                {
                    if ( 
get_pcvar_num(g_MSGMODE) == )
                        {
                            
set_hudmessage(001000.800.8006.02.01.01.0)
                            
show_hudmessage(id"You do not have to^nplace sandbags")
                            return 
PLUGIN_CONTINUE
                        
}
                    
client_print(idprint_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(idprint_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_CreateNamedEntityengfunc(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_SetSizeentp_minsp_maxs);
    
set_pev(entpev_minsp_mins);
    
set_pev(entpev_maxsp_maxs );
    
set_pev(entpev_absminp_mins);
    
set_pev(entpev_absmaxp_maxs );

    
    
// set the rock of origin where is user placed
    
engfunc(EngFunc_SetOriginentxorigin);
    
    
    
// 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) == )
    {
        
set_hudmessage(001000.800.8006.02.01.01.0)
        
show_hudmessage(id"You placed a SandBag^n%i Remaining"g_bolsas[id])
        return 
PLUGIN_HANDLED
    
}
    
client_print(idprint_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(idFloat:hOrigin[3]) 
{
    if ( ! 
is_user_aliveid ))
        return 
0;
    
    new 
Float:fOrigin[3], Float:fvAngle[3], Float:fvOffset[3], Float:fvOrigin[3], Float:feOrigin[3];
    new 
Float:fTemp[3];
    
    
pev(idpev_originfOrigin);
    
pev(idpev_v_anglefvAngle);
    
pev(idpev_view_ofsfvOffset);
    
    
xs_vec_add(fOriginfvOffsetfvOrigin);
    
    
engfunc(EngFunc_AngleVectorsfvAnglefeOriginfTempfTemp);
    
    
xs_vec_mul_scalar(feOrigin9999.9feOrigin);
    
xs_vec_add(fvOriginfeOriginfeOrigin);
    
    
engfunc(EngFunc_TraceLinefvOriginfeOrigin0id);
    
global_get(glb_trace_endposhOrigin);
    
    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) == )
    {
        static 
players[32], pnumplayer
        get_players
(playerspnum)
        static 
Float:origin[3]
        static 
Float:mins[3], hull
        
static Float:vec[3]
        static 
o,i
        
for(i=0i<pnumi++){
            
player players[i]
            if (
is_user_connected(player) && is_user_alive(player)) {
                
pev(playerpev_originorigin)
                
hull pev(playerpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMAN
                
if (!is_hull_vacant(originhull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
                    ++
stuck[player]
                    if(
stuck[player] >= get_pcvar_num(cvar[2])) {
                        
pev(playerpev_minsmins)
                        
vec[2] = origin[2]
                        for (
o=0sizeof 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(vechull,player)) {
                                
engfunc(EngFunc_SetOriginplayervec)
                                
effects(player)
                                
set_pev(player,pev_velocity,{0.0,0.0,0.0})
                                
sizeof size
                            
}
                        }
                    }
                }
                else
                {
                    
stuck[player] = 0
                
}
            }
        }
    
    }
    
}

stock bool:is_hull_vacant(const Float:origin[3], hull,id) {
    static 
tr
    engfunc
(EngFunc_TraceHulloriginorigin0hullidtr)
    if (!
get_tr2(trTR_StartSolid) || !get_tr2(trTR_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.00.6506.01.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(playeritemid)
{
    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) == )
        {
            
set_hudmessage(001000.800.8006.02.01.01.0)
            
show_hudmessage(player"Plugin By LLRAP ^nChile 2008 :)")
        }
    }

}

public 
cmd_bind(id)
{
    if ( 
get_pcvar_num(g_BINDMODE) == )
    {
        
client_print(idprint_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(idprint_chat"[ZP] You have %i sandbags, to use type 'say /pb'"g_bolsas[id])
    return 
PLUGIN_HANDLED



Last edited by Noam; 06-23-2019 at 09:19.
Noam is online now
DON KHAN 1
Senior Member
Join Date: Mar 2019
Location: Pakistan
Old 06-28-2019 , 02:01   Re: [ZP] Extra Item: Sand Bags BETA!
Reply With Quote #112

Quote:
Originally Posted by Noam View Post
PHP Code:
/*================================================================================
    
    -----------------------------------
    -*- [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 pnumpluginremove_nrndmaxpalletsphealth;

// 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.00.01.0}, {0.00.0, -1.0}, {0.01.00.0}, {0.0, -1.00.0}, {1.00.00.0}, {-1.00.00.0}, {-1.01.01.0}, {1.01.01.0}, {1.0, -1.01.0}, {1.01.0, -1.0}, {-1.0, -1.01.0}, {1.0, -1.0, -1.0}, {-1.01.0, -1.0}, {-1.0, -1.0, -1.0},
    {
0.00.02.0}, {0.00.0, -2.0}, {0.02.00.0}, {0.0, -2.00.0}, {2.00.00.0}, {-2.00.00.0}, {-2.02.02.0}, {2.02.02.0}, {2.0, -2.02.0}, {2.02.0, -2.0}, {-2.0, -2.02.0}, {2.0, -2.0, -2.0}, {-2.02.0, -2.0}, {-2.0, -2.0, -2.0},
    {
0.00.03.0}, {0.00.0, -3.0}, {0.03.00.0}, {0.0, -3.00.0}, {3.00.00.0}, {-3.00.00.0}, {-3.03.03.0}, {3.03.03.0}, {3.0, -3.03.0}, {3.03.0, -3.0}, {-3.0, -3.03.0}, {3.0, -3.0, -3.0}, {-3.03.0, -3.0}, {-3.0, -3.0, -3.0},
    {
0.00.04.0}, {0.00.0, -4.0}, {0.04.00.0}, {0.0, -4.00.0}, {4.00.00.0}, {-4.00.00.0}, {-4.04.04.0}, {4.04.04.0}, {4.0, -4.04.0}, {4.04.0, -4.0}, {-4.0, -4.04.0}, {4.0, -4.0, -4.0}, {-4.04.0, -4.0}, {-4.0, -4.0, -4.0},
    {
0.00.05.0}, {0.00.0, -5.0}, {0.05.00.0}, {0.0, -5.00.0}, {5.00.00.0}, {-5.00.00.0}, {-5.05.05.0}, {5.05.05.0}, {5.0, -5.05.0}, {5.05.0, -5.0}, {-5.0, -5.05.0}, {5.0, -5.0, -5.0}, {-5.05.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 ZPSTUCKg_BINDMODEg_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_nameg_item_name1g_item_bolsasZV_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;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_numpnumplugin ) )
        return 
PLUGIN_HANDLED;
        
        
    
// check if user isn't alive
    
if( ! is_user_aliveid ) )
    {
        
client_printidprint_chat"" ); //msg muerto
        
return PLUGIN_HANDLED;
    }
            
    if ( !
zp_get_user_zombie(id) )
    {        
        new 
szMenuBody[256];
        new 
keys;
        
        new 
nLen formatszMenuBody255"\ySandBags:^n" );
        
nLen += formatszMenuBody[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 += formatszMenuBody[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_menuidkeysszMenuBody, -);

        
// depends what you want, if is continue will appear on chat what the admin sayd
        
return PLUGIN_HANDLED;
    }
    
client_print(idprint_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 )
                {
                    if ( 
get_pcvar_num(g_MSGMODE) == )
                        {
                            
set_hudmessage(001000.800.8006.02.01.01.0)
                            
show_hudmessage(id"You do not have to^nplace sandbags")
                            return 
PLUGIN_CONTINUE
                        
}
                    
client_print(idprint_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(idprint_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_CreateNamedEntityengfunc(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_SetSizeentp_minsp_maxs);
    
set_pev(entpev_minsp_mins);
    
set_pev(entpev_maxsp_maxs );
    
set_pev(entpev_absminp_mins);
    
set_pev(entpev_absmaxp_maxs );

    
    
// set the rock of origin where is user placed
    
engfunc(EngFunc_SetOriginentxorigin);
    
    
    
// 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) == )
    {
        
set_hudmessage(001000.800.8006.02.01.01.0)
        
show_hudmessage(id"You placed a SandBag^n%i Remaining"g_bolsas[id])
        return 
PLUGIN_HANDLED
    
}
    
client_print(idprint_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(idFloat:hOrigin[3]) 
{
    if ( ! 
is_user_aliveid ))
        return 
0;
    
    new 
Float:fOrigin[3], Float:fvAngle[3], Float:fvOffset[3], Float:fvOrigin[3], Float:feOrigin[3];
    new 
Float:fTemp[3];
    
    
pev(idpev_originfOrigin);
    
pev(idpev_v_anglefvAngle);
    
pev(idpev_view_ofsfvOffset);
    
    
xs_vec_add(fOriginfvOffsetfvOrigin);
    
    
engfunc(EngFunc_AngleVectorsfvAnglefeOriginfTempfTemp);
    
    
xs_vec_mul_scalar(feOrigin9999.9feOrigin);
    
xs_vec_add(fvOriginfeOriginfeOrigin);
    
    
engfunc(EngFunc_TraceLinefvOriginfeOrigin0id);
    
global_get(glb_trace_endposhOrigin);
    
    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) == )
    {
        static 
players[32], pnumplayer
        get_players
(playerspnum)
        static 
Float:origin[3]
        static 
Float:mins[3], hull
        
static Float:vec[3]
        static 
o,i
        
for(i=0i<pnumi++){
            
player players[i]
            if (
is_user_connected(player) && is_user_alive(player)) {
                
pev(playerpev_originorigin)
                
hull pev(playerpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMAN
                
if (!is_hull_vacant(originhull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
                    ++
stuck[player]
                    if(
stuck[player] >= get_pcvar_num(cvar[2])) {
                        
pev(playerpev_minsmins)
                        
vec[2] = origin[2]
                        for (
o=0sizeof 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(vechull,player)) {
                                
engfunc(EngFunc_SetOriginplayervec)
                                
effects(player)
                                
set_pev(player,pev_velocity,{0.0,0.0,0.0})
                                
sizeof size
                            
}
                        }
                    }
                }
                else
                {
                    
stuck[player] = 0
                
}
            }
        }
    
    }
    
}

stock bool:is_hull_vacant(const Float:origin[3], hull,id) {
    static 
tr
    engfunc
(EngFunc_TraceHulloriginorigin0hullidtr)
    if (!
get_tr2(trTR_StartSolid) || !get_tr2(trTR_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.00.6506.01.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(playeritemid)
{
    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) == )
        {
            
set_hudmessage(001000.800.8006.02.01.01.0)
            
show_hudmessage(player"Plugin By LLRAP ^nChile 2008 :)")
        }
    }

}

public 
cmd_bind(id)
{
    if ( 
get_pcvar_num(g_BINDMODE) == )
    {
        
client_print(idprint_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(idprint_chat"[ZP] You have %i sandbags, to use type 'say /pb'"g_bolsas[id])
    return 
PLUGIN_HANDLED


Thank You For This Help
__________________
Hosting Servers: Angel Of Games

Facebook
My YouTube
Join My Forum
Ro{Y}aL WarLanD CommuniTy
Angel Of Games - Forum
Currently Working On: ADVANCED VIP + API : 70%
DON KHAN 1 is offline
Noam
Member
Join Date: Jun 2019
Old 09-09-2019 , 13:38   Re: [ZP] Extra Item: Sand Bags BETA!
Reply With Quote #113

PHP Code:
#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 pnumpluginremove_nrndmaxpalletsphealth

// 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.00.01.0}, {0.00.0, -1.0}, {0.01.00.0}, {0.0, -1.00.0}, {1.00.00.0}, {-1.00.00.0}, {-1.01.01.0}, {1.01.01.0}, {1.0, -1.01.0}, {1.01.0, -1.0}, {-1.0, -1.01.0}, {1.0, -1.0, -1.0}, {-1.01.0, -1.0}, {-1.0, -1.0, -1.0}, 
    {
0.00.02.0}, {0.00.0, -2.0}, {0.02.00.0}, {0.0, -2.00.0}, {2.00.00.0}, {-2.00.00.0}, {-2.02.02.0}, {2.02.02.0}, {2.0, -2.02.0}, {2.02.0, -2.0}, {-2.0, -2.02.0}, {2.0, -2.0, -2.0}, {-2.02.0, -2.0}, {-2.0, -2.0, -2.0}, 
    {
0.00.03.0}, {0.00.0, -3.0}, {0.03.00.0}, {0.0, -3.00.0}, {3.00.00.0}, {-3.00.00.0}, {-3.03.03.0}, {3.03.03.0}, {3.0, -3.03.0}, {3.03.0, -3.0}, {-3.0, -3.03.0}, {3.0, -3.0, -3.0}, {-3.03.0, -3.0}, {-3.0, -3.0, -3.0}, 
    {
0.00.04.0}, {0.00.0, -4.0}, {0.04.00.0}, {0.0, -4.00.0}, {4.00.00.0}, {-4.00.00.0}, {-4.04.04.0}, {4.04.04.0}, {4.0, -4.04.0}, {4.04.0, -4.0}, {-4.0, -4.04.0}, {4.0, -4.0, -4.0}, {-4.04.0, -4.0}, {-4.0, -4.0, -4.0}, 
    {
0.00.05.0}, {0.00.0, -5.0}, {0.05.00.0}, {0.0, -5.00.0}, {5.00.00.0}, {-5.00.00.0}, {-5.05.05.0}, {5.05.05.0}, {5.0, -5.05.0}, {5.05.0, -5.0}, {-5.0, -5.05.0}, {5.0, -5.0, -5.0}, {-5.05.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_nameg_item_bolsasZP_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(victiminflictorattackerFloat:damagedamage_type

    
//Victim is not lasermine. 
    
new sz_classname[32
    
entity_get_stringvictim EV_SZ_classname sz_classname31 
    if( !
equali(sz_classname,"amxx_pallets") ) 
        return 
HAM_IGNORED
     
    
//Attacker is zombie 
    
if( zp_get_user_zombieattacker ) )  
        return 
HAM_IGNORED
     
    
//Block Damage 
    
return HAM_SUPERCEDE


public 
fw_PlayerKilled(victimattackershouldgib)
{     
    new 
sz_classname[32], Floathealth 
    entity_get_string
victim EV_SZ_classname sz_classnamecharsmax(sz_classname))

    
health entity_get_float(victimEV_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(attackerzp_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;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_numpnumplugin ) ) 
        return 
PLUGIN_HANDLED
         
         
    
// check if user isn't alive 
    
if( ! is_user_aliveid ) ) 
    { 
        
client_printidprint_chat"" ); //msg muerto 
        
return PLUGIN_HANDLED
    } 
             
    if ( !
zp_get_user_zombie(id) ) 
    {         
        new 
szMenuBody[256]; 
        new 
keys
         
        new 
nLen formatszMenuBody255"\ySand Bags:^n" ); 
        
nLen += formatszMenuBody[nLen], 255-nLen"^n\w1. Place a Sandbags" ); 
        
//nLen += format( szMenuBody[nLen], 255-nLen, "^n\w2. Remove a pallet with bags" ); 
        
nLen += formatszMenuBody[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_menuidkeysszMenuBody, -); 

        
// 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 
                { 
                    
ColorChat(id"You^3 don't^1 have any^4 sandbag^1 to^3 place^1 one!"
                    return 
PLUGIN_CONTINUE 
                

                
g_bolsas[id]-= 
                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_CreateNamedEntityengfunc(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_SetSizeentp_minsp_maxs); 
    
set_pev(entpev_minsp_mins); 
    
set_pev(entpev_maxsp_maxs ); 
    
set_pev(entpev_absminp_mins); 
    
set_pev(entpev_absmaxp_maxs ); 

     
    
// set the rock of origin where is user placed 
    
engfunc(EngFunc_SetOriginentxorigin); 
     
     
    
// 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(entpev_ownerid);
     
    
// 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(idFloat:hOrigin[3])  

    if ( ! 
is_user_aliveid )) 
        return 
0
     
    new 
Float:fOrigin[3], Float:fvAngle[3], Float:fvOffset[3], Float:fvOrigin[3], Float:feOrigin[3]; 
    new 
Float:fTemp[3]; 
     
    
pev(idpev_originfOrigin); 
    
pev(idpev_v_anglefvAngle); 
    
pev(idpev_view_ofsfvOffset); 
     
    
xs_vec_add(fOriginfvOffsetfvOrigin); 
     
    
engfunc(EngFunc_AngleVectorsfvAnglefeOriginfTempfTemp); 
     
    
xs_vec_mul_scalar(feOrigin9999.9feOrigin); 
    
xs_vec_add(fvOriginfeOriginfeOrigin); 
     
    
engfunc(EngFunc_TraceLinefvOriginfeOrigin0id); 
    
global_get(glb_trace_endposhOrigin); 
     
    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) == 
    { 
        static 
players[32], pnumplayer 
        get_players
(playerspnum
        static 
Float:origin[3
        static 
Float:mins[3], hull 
        
static Float:vec[3
        static 
o,
        
for(i=0i<pnumi++){ 
            
player players[i
            if (
is_user_connected(player) && is_user_alive(player)) { 
                
pev(playerpev_originorigin
                
hull pev(playerpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMAN 
                
if (!is_hull_vacant(originhull,player) && !fm_get_user_noclip(player) && !(pev(player,pev_solid) &  

SOLID_NOT)) { 
                    ++
stuck[player
                    if(
stuck[player] >= get_pcvar_num(cvar[2])) { 
                        
pev(playerpev_minsmins
                        
vec[2] = origin[2
                        for (
o=0sizeof 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(vechull,player)) { 
                                
engfunc(EngFunc_SetOriginplayervec
                                
effects(player
                                
set_pev(player,pev_velocity,{0.0,0.0,0.0}) 
                                
sizeof size 
                            

                        } 
                    } 
                } 
                else 
                { 
                    
stuck[player] = 
                

            } 
        } 
     
    } 
     


stock bool:is_hull_vacant(const Float:origin[3], hull,id) { 
    static 
tr 
    engfunc
(EngFunc_TraceHulloriginorigin0hullidtr
    if (!
get_tr2(trTR_StartSolid) || !get_tr2(trTR_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.00.6506.01.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(iditemid

  if (
itemid == g_itemid_bolsas
  {  
    if(!
done[id]) 
    { 
    
g_bolsas[id]+= 
    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(idprint_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(idprint_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]+= 
       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
(idzp_get_user_ammo_packs(id) - g_item_bolsas)
       return 
PLUGIN_CONTINUE
       
}

    
       else { 
     
       
client_print(idprint_chat"Max Sandbags reached !!!"
       return 
PLUGIN_HANDLED
       

 
       }

       return 
PLUGIN_CONTINUE   

}  
stock ColorChat( const index, const string[], any:... )
{
new 
szMsg191 ], Players32 ], PNum 1;

static 
iLeniLen formatexszMsgcharsmaxszMsg ), "^3[TheKingdom]^1 ");

vformatszMsgiLen ], charsmaxszMsg ) - iLenstring);

if ( 
index )
    
Players] = index;
    else
        
get_playersPlayersPNum"ch" );
        
        for ( new 
iPNumi++ )
        {
            if( 
is_user_connectedPlayers] ) )
            {
                
message_beginMSG_ONE_UNRELIABLEget_user_msgid"SayText" ), _Players] );
                
                
write_bytePlayers] );
                
                
write_stringszMsg );
                
                
message_end( );
            }
        }
        return 
1;
    }
    
    
stock szName( const index )
    {
        static 
szName32 ];
        
        
get_user_nameindexszNamecharsmaxszName ) );
        
        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?

Last edited by Noam; 09-09-2019 at 13:39.
Noam is online now
Balage74
Member
Join Date: Dec 2006
Old 09-18-2019 , 16:51   Re: [ZP] Extra Item: Sand Bags BETA!
Reply With Quote #114

I have little modifiation (bugfixes):
Work on zp_special (just try change line 6. for other zombie mod)
and change hungarian lang

Quote:
#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 Floatorigin[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
============================================= =======*/
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;
}




__________________
Balage74 is offline
Send a message via MSN to Balage74 Send a message via Skype™ to Balage74
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:42.


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