SandBags
#1
nuevamente yo por aki pero esta vez pidiendo los populares sandbags para zm

amigo me gustaria saber si me pueden ayudar con el plugins de sandbags pero editado osea que el player que los compre pueda traspasarlos sin romperlos y los zombies que den varios cuchilladas para poderlos quitar a y que no traiga tanto como el default que tiene al rededor de 200 grax
Responder
#2
Bueno, aquí te adjunto los #SandBags.
Allí usted puede editarlo a su gusto.

De necesitar algo mas solo vuelva a postear aquí.
No te hago la modificación de que los humanos transpasen
los #SandBags por que soy nuevo en el PAWN.

Usted puede modificar la vida del #SandBags,
la cantidad que se dará al comprarlo, el precio, ETC...

#AlliedModdersES.


Archivos adjuntos
.sma   Descargar AMXX / zp_sandbags.sma (Tamaño: 14.07 KB / Descargas: 39)
Responder
#3
Este codigo se supone que tiene todo lo que pedis.
Solo se puede poner una sola sandbag, y el dueño las traspasa!
Tambien los zombies al destruirla ganan ammopacks!

Probalo y Decime si te funciono o no

Código PHP:
#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

/* 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 
g_bag[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 
    
remove_nrnd register_cvar("zp_pb_remround","0"); 
    
maxpallets register_cvar("zp_pb_limit","1"); // 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 /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)

     

//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) + 5)
        
client_print(attackerprint_chat"[ZP] You earned 5 ammopacks by destroy sandbag!"
        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
    } 
    
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 
                { 
                    
client_print(idprint_chat"[ZP] You do not have to place sandbags!"
                    return 
PLUGIN_CONTINUE 
                

                
g_bolsas[id]-= 
                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, "[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) ) 
    { 
        
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); 

    
set_pev(entpev_ownerid);
     
    
// num .. 
    
palletscout++; 
     
    
// confirm message 
    
client_print(idprint_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(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(); 

    g_bolsas[id] = 0  
    g_bag[id] = 0 
  } 
         
}  
*/ 
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,
        
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(
g_bag[id] > 1
    { 
        
client_print(idprint_chat"Max Sandbags reached !!!"
        return 
ZP_PLUGIN_HANDLED
    
}
    
g_bolsas[id]+= 
    g_bag
[id]++ 
    
set_task(0.3,"show_the_menu",id
    
client_print(idprint_chat"[ZP] You have %i sandbags, to use type 'say / sb'"g_bolsas[id]) 
  }

  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(
g_bag[id] > 1
       { 
          
client_print(idprint_chat"Max Sandbags reached !!!"
           return 
ZP_PLUGIN_HANDLED
       
}
       
g_bolsas[id]+= 
       g_bag
[id]++
       
set_task(0.3,"show_the_menu",id
       
client_print(idprint_chat"[ZP] You have %i sandbags, to use type 'say / sb'"g_bolsas[id]) 
       
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) - g_item_bolsas)
       }

       return 
PLUGIN_CONTINUE   


Responder
#4
Bueno, creo que el plugin que a pasado el amigo Web Controller se
ajusta mas a sus necesidades, si desea cambiarle la cantidad de
#SandBags al comprar dicho plugin valla a este apartado:

Código PHP:
}
       
g_bolsas[id]+= 
       g_bag
[id]++
       
set_task(0.3,"show_the_menu",id
       
client_print(idprint_chat"[ZP] You have %i sandbags, to use type 'say / sb'"g_bolsas[id]) 
       
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) - g_item_bolsas)
       }

       return 
PLUGIN_CONTINUE   



Esto esta al finalizar el código del Plugin, debes modificar esta parte:
Código PHP:
g_bolsas[id]+= 
Cambia el 1 por la cantidad de sacos que desees.

Aquí puedes cambiar el Costo y Nombre de los #SandBags:
Código PHP:
new const g_item_name[] = { "Sandbags" 
const 
g_item_bolsas 30 
new g_itemid_bolsas 
new ZPSTUCK 

En:
Código PHP:
new g_item_bolsas 30 
Es el Costo de las #SandBags, puedes cambiarlo.

En:
Código PHP:
new const g_item_name[] = { "Sandbags" 
Es el Nombre que aparece en el menú cuando los vas a comprar, puedes cambiarlo.

Los mensajes también puedes cambiarlos a tu gusto, todos lo que empiece con:
Código PHP:
client_print(idprint_chat"[ZP] The zombies can not use this command!"
Esto mensajes son lo que aparecerán en el Say en ciertas ocaciones, o al ejecutar una acción del plugin.

Si te hace falta saber algo mas solo vuelve a postear.


#AlliedModdersES.
Responder
#5
como le agrego el glow a medida que le quiten la vida

600 verde
300 amarillo
150 rojo
Responder
#6
Proba esta

Código PHP:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
//#include <d7_debug>

//new g_szLogFile[] = "D7_Debug_RenderHP.log";

enum (<<= 1)
{
    
g_iEnumBitEntDefault 1,
    
g_iEnumBitEntCustom,
    
g_iEnumBitEntMdlBrush,
    
g_iEnumBitEntMdlStudio,
    
g_iEnumBitEntRendered
}

new const 
g_szEntClassNamesSpawn[][] =
{
    
"func_breakable",
    
"func_wall"/*,
    "player",
    "hostage_entity"*/
}

new const 
g_szEntClassNames[][] =
{
    
"lasermine",
    
"amxx_pallets"/*,
    "player",
    "hostage_entity",
    "func_breakable"*/
}

new 
g_bEntRegistered[sizeof g_szEntClassNames];

public 
plugin_precache()
{
    
register_forward(FM_Spawn"fwFmSpawnEntPost"1);
}

public 
plugin_init()
{
    
register_plugin("D7 Render HP""0.0.1""D i 5 7 i n c T")
    
    for (new 
isizeof g_szEntClassNamesSpawni++)
    {
//        RegisterHam(Ham_Spawn, g_szEntClassNamesSpawn[i], "fwHamSpawnEntPost", 1)
//        RegisterHam(Ham_CS_Restart, g_szEntClassNamesSpawn[i], "fwHamSpawnEntPost", 1)
        
RegisterHam(Ham_TakeDamageg_szEntClassNamesSpawn[i], "fwHamTakeDamageEntPre")
        
RegisterHam(Ham_TakeDamageg_szEntClassNamesSpawn[i], "fwHamTakeDamageEntPost"1)
    }
}

/*public client_putinserver(iID)
{
    if (!is_user_bot(iID))
        return;
    
//    ftEntGetClassName(iID)
    set_task(0.1, "ftEntGetClassName", iID)
}

public client_disconnect(iID)
{
    remove_task(iID)
}

public ftEntGetClassName(const iEntID)
{
    static szEntClassname[32];
    pev(iEntID, pev_classname, szEntClassname, charsmax(szEntClassname))
    
    RegisterHamFromEntity(Ham_Spawn, iEntID, "fwHamSpawnEntPost", 1)
    RegisterHamFromEntity(Ham_TakeDamage, iEntID, "fwHamTakeDamageEntPre")
    RegisterHamFromEntity(Ham_TakeDamage, iEntID, "fwHamTakeDamageEntPost", 1)
    
    ftD7Log(g_szLogFile, _, _, "[ftEntGetClassName] EntID: %d. Classname: ^"%s^".", iEntID, szEntClassname)
}*/

ftEntCheckCustom(const iEntID)
{
    new 
iEntFlags pev(iEntIDpev_euser4);
    
    if (!(
iEntFlags g_iEnumBitEntDefault) && !(iEntFlags g_iEnumBitEntCustom))
    {
        static 
szEntClassname[32];
        
pev(iEntIDpev_classnameszEntClassnamecharsmax(szEntClassname))
        
/*        ftD7Log(g_szLogFile, _, _, "[ftEntCheckCustom] EntID: %d. Classname: ^"%s^".", iEntID, szEntClassname)
        */
        
for (new isizeof g_szEntClassNamesi++)
            if (
equali(szEntClassnameg_szEntClassNames[i]))
            {
                
iEntFlags &= ~g_iEnumBitEntDefault;
                
iEntFlags |= g_iEnumBitEntCustom;
                
                if (!
g_bEntRegistered[i])
                {
                    
RegisterHamFromEntity(Ham_SpawniEntID"fwHamSpawnEntPost"1)
                    
RegisterHamFromEntity(Ham_CS_RestartiEntID"fwHamRestartEntPost"1)
                    
                    
g_bEntRegistered[i] = true;
                }
                
                break;
            }
            else if (
== sizeof g_szEntClassNames 1)
            {
                
iEntFlags &= ~g_iEnumBitEntCustom;
                
iEntFlags |= g_iEnumBitEntDefault;
            }
        
        
set_pev(iEntIDpev_euser4iEntFlags)
    }
    
//    ftD7Log(g_szLogFile, _, _, "[ftEntCheckCustom] EntID: %d. Flags: %d.", iEntID, iEntFlags)
    
    
if ((iEntFlags g_iEnumBitEntCustom) && !(iEntFlags g_iEnumBitEntRendered))
/*        i = pev(iEntID, pev_rendermode);
        
        if ((i == kRenderNormal || i == kRenderTransTexture) && pev(iEntID, pev_renderfx) == kRenderFxNone)
        {
        
        }
        */
        
ftSetRender(iEntID)
    
    return 
iEntFlags;
}

public 
fwHamSpawnEntPost(const iEntID)
{
    if (
ftEntCheckCustom(iEntID) & g_iEnumBitEntDefault/* || ftEntCheckMaxHP(iEntID) <= 0.0*/)
        return;
    
    static 
szEntClassname[32];
    
pev(iEntIDpev_classnameszEntClassnamecharsmax(szEntClassname))
    
//    ftD7Log(g_szLogFile, _, _, "[Ham_Spawn] EntID: %d. Classname: ^"%s^".", iEntID, szEntClassname)
    
    
set_pev(iEntIDpev_rendercolor, { 0.0255.00.0 })
}

public 
fwHamRestartEntPost(const iEntID)
{
    if (
ftEntCheckCustom(iEntID) & g_iEnumBitEntDefault/* || ftEntCheckMaxHP(iEntID) <= 0.0*/)
        return;
    
    static 
szEntClassname[32];
    
pev(iEntIDpev_classnameszEntClassnamecharsmax(szEntClassname))
    
//    ftD7Log(g_szLogFile, _, _, "[Ham_CS_Restart] EntID: %d. Classname: ^"%s^".", iEntID, szEntClassname)
    
    
set_pev(iEntIDpev_rendercolor, { 0.0255.00.0 })
}

ftSetRender(const iEntID)
{
    static 
szEntInfo[2];
    
    
pev(iEntIDpev_modelszEntInfocharsmax(szEntInfo))
    
    
szEntInfo[1] = pev(iEntIDpev_euser4);
    
    
// If the first character of the entity model is '*',
    // then it's a brush(non-studio) model
    
if (szEntInfo[0] == '*')
    {
//        ftD7Log(g_szLogFile, _, _, "[ftSetRender] EntID: %d. Initializing render for brush model.", iEntID)
//        
        
szEntInfo[1] &= ~g_iEnumBitEntMdlStudio;
        
szEntInfo[1] |= g_iEnumBitEntMdlBrush;
        
        
set_pev(iEntIDpev_rendermodekRenderTransColor);
        
set_pev(iEntIDpev_renderamt128.0)
    }
    else
    {
        
szEntInfo[1] &= ~g_iEnumBitEntMdlBrush;
        
szEntInfo[1] |= g_iEnumBitEntMdlStudio;
        
        new 
Float:fEntRenderAmt;
        
pev(iEntIDpev_renderamtfEntRenderAmt)
        
//        ftD7Log(g_szLogFile, _, _, "[ftSetRender] EntID: %d. Initializing render for studio model. Renderamt: %f.", iEntID, fEntRenderAmt)
        
        
set_pev(iEntIDpev_renderfxkRenderFxGlowShell)
        
        if (
fEntRenderAmt == 0.0)
            
set_pev(iEntIDpev_renderamt5.0)
    }
    
    
szEntInfo[1] |= g_iEnumBitEntRendered;
    
    
set_pev(iEntIDpev_euser4szEntInfo[1])
}

Float:ftEntCheckMaxHP(const iEntID)
{
    new 
Float:fHealth;
    
pev(iEntIDpev_max_healthfHealth)
    
//    ftD7Log(g_szLogFile, _, _, "[ftEntCheckMaxHP] MaxHP: %f.", fHealth)
    
    
if (fHealth != 0.0)
        return 
fHealth;
    
    
pev(iEntIDpev_healthfHealth)
    
//    ftD7Log(g_szLogFile, _, _, "[ftEntCheckMaxHP] HP: %f.", fHealth)
    
    
if (fHealth <= 0.0)
        return 
fHealth;
    
    
set_pev(iEntIDpev_max_healthfHealth)
    
    return 
fHealth;
}

public 
fwFmSpawnEntPost(const iEntID)
{
    if (!
pev_valid(iEntID))
        return;
    
//    ftD7Log(g_szLogFile, _, _, "[FM_Spawn] EntID: %d.", iEntID)
    
    
if (ftEntCheckCustom(iEntID) & g_iEnumBitEntDefault || ftEntCheckMaxHP(iEntID) <= 0.0)
        return;
    
    
set_pev(iEntIDpev_rendercolor, { 0.0255.00.0 })
}

public 
fwHamTakeDamageEntPre(const iEntID, const iInflictorID, const iAttackerID, const Float:fDamage, const iDamageType)
{
//    ftD7Log(g_szLogFile, _, _, "[Ham_TakeDamage Pre] EntID: %d.", iEntID)
    
    
if (!ftEntCheckCustom(iEntID))
        return;
    
    
ftEntCheckMaxHP(iEntID)
}

public 
fwHamTakeDamageEntPost(const iEntID, const iInflictorID, const iAttackerID, const Float:fDamage, const iDamageType)
{
/*    if (pev(iEntID, pev_takedamage) == DAMAGE_NO)
        return;
    */
//    ftD7Log(g_szLogFile, _, _, "[Ham_TakeDamage Post] EntID: %d.", iEntID)
    
    
if (!ftEntCheckCustom(iEntID))
        return;
    
    new 
Float:fHealth;
    
pev(iEntIDpev_healthfHealth)
    
//    ftD7Log(g_szLogFile, _, _, "[Ham_TakeDamage Post] HP: %f.", fHealth)
    
    
if (fHealth <= 0.0)
    {
        
set_pev(iEntIDpev_euser40)
        
        return;
    }
    
    new 
Float:fHealthMax;
    
pev(iEntIDpev_max_healthfHealthMax)
    
//    ftD7Log(g_szLogFile, _, _, "[Ham_TakeDamage Post] MaxHP: %f.", fHealthMax)
    
    // Entity didn't take damage
    
if (fHealth == fHealthMax)
        return;
    
    
ComputeColor(iEntIDfHealth 100.0 fHealthMax)
}

ComputeColor(const iEntID, const Float:fPercentage)
{
    if (
fPercentage 0.0)
        return;
    
    static 
Float:fColorAmounts[3];
    
    
fColorAmounts[1] = 255.0 fPercentage 100.0// green
    
fColorAmounts[0] = 255.0 fColorAmounts[1]; // red
    
fColorAmounts[2] = 0.0// blue
    
//    ftD7Log(g_szLogFile, _, _, "[ComputeColor] EntID: %d. Percentage: %.2f. Red: %f. Green: %f.", iEntID, fPercentage, fColorAmounts[0], fColorAmounts[1])
    
    
set_pev(iEntIDpev_rendercolorfColorAmounts)
/*    
    if (pev(iEntID, pev_euser4) & g_iEnumBitEntMdlStudio)
        set_pev(iEntID, pev_renderamt, fColorAmounts[1])*/

Responder
#7
eso se lo agrego al scritp del sandbag o como hago aki esta el sma

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

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

new const FloatConfundidoize[][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
remove_nrnd = register_cvar("zp_pb_remround","0");
maxpallets = register_cvar("zp_pb_limit","1"); // 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 /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)


}
//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) + 5)
client_print(attacker, print_chat, "[ZP] You earned 5 ammopacks by destroy sandbag!")
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;
}
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, "[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) )
{
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);

set_pev(ent, pev_owner, id);

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

g_bolsas[id] = 0
g_bag[id] = 0
}

}
*/
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 Floatpacmanec[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(g_bag[id] > 1)
{
client_print(id, print_chat, "Max Sandbags reached !!!")
return ZP_PLUGIN_HANDLED
}
g_bolsas[id]+= 1
g_bag[id]++
set_task(0.3,"show_the_menu",id)
client_print(id, print_chat, "[ZP] You have %i sandbags, to use type 'say / sb'", g_bolsas[id])
}

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(g_bag[id] > 1)
{
client_print(id, print_chat, "Max Sandbags reached !!!")
return ZP_PLUGIN_HANDLED
}
g_bolsas[id]+= 1
g_bag[id]++
set_task(0.3,"show_the_menu",id)
client_print(id, print_chat, "[ZP] You have %i sandbags, to use type 'say / sb'", g_bolsas[id])
zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) - g_item_bolsas)
}

return PLUGIN_CONTINUE

}
Responder
#8
Probalo asi como te lo pase, si funciona le agrego el semiclip apra los dueños!
Responder
#9
ya lo probe pero no funciona weon
Responder
#10
Lo hice muy por encima y con el celu. No se si esta bien probalo y si no funca decime logs etc. etc.

Código PHP:
#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) 

enum (<<= 1)
{
    
g_iEnumBitEntDefault 1,
    
g_iEnumBitEntCustom,
    
g_iEnumBitEntMdlBrush,
    
g_iEnumBitEntMdlStudio,
    
g_iEnumBitEntRendered
}

new const 
g_szEntClassNamesSpawn[][] =
{
    
"func_wall"/*,
    "player",
    "hostage_entity"*/
}

new const 
g_szEntClassNames[][] =
{
    
"amxx_pallets"/*,
    "player",
    "hostage_entity",
    "func_breakable"*/
}

// cvars 
new pnumpluginremove_nrndmaxpalletsphealth

new 
g_bEntRegistered[sizeof g_szEntClassNames];

// 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 
g_bag[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 
    
remove_nrnd register_cvar("zp_pb_remround","0"); 
    
maxpallets register_cvar("zp_pb_limit","1"); // 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 /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"
    
    for (new 
isizeof g_szEntClassNamesSpawni++)
    {
        
RegisterHam(Ham_TakeDamageg_szEntClassNamesSpawn[i], "fwHamTakeDamageEntPre")
        
RegisterHam(Ham_TakeDamageg_szEntClassNamesSpawn[i], "fwHamTakeDamageEntPost"1)
    }
    
    
RegisterHam(Ham_TakeDamage,"func_wall","fw_TakeDamage"); 
    
RegisterHam(Ham_Killed"func_wall""fw_PlayerKilled"1)

     

//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) + 5)
        
client_print(attackerprint_chat"[ZP] You earned 5 ammopacks by destroy sandbag!"
        return 
HAM_IGNORED;
    } 
    return 
HAM_IGNORED;


public 
plugin_precache() 

    
register_forward(FM_Spawn"fwFmSpawnEntPost"1);
    for(new 
i;sizeof g_models;i++) 
        
engfunc(EngFunc_PrecacheModel,g_models[i]); 
}

public 
show_the_menu(id,level,cid


    
// 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
    } 
    
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 
                { 
                    
client_print(idprint_chat"[ZP] You do not have to place sandbags!"
                    return 
PLUGIN_CONTINUE 
                

                
g_bolsas[id]-= 
                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     
        

         
             
    } 
     
    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); 
    
    
set_pev(entpev_ownerid);
         
    
// num .. 
    
palletscout++; 
         
    
// confirm message 
    
client_print(idprint_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(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(); 

    g_bolsas[id] = 0  
    g_bag[id] = 0 
  } 
         
}  
*/ 
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,
        
        
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(
g_bag[id] > 1
        { 
            
client_print(idprint_chat"Max Sandbags reached !!!"
            return 
ZP_PLUGIN_HANDLED
        
}
        
g_bolsas[id]+= 
        g_bag
[id]++ 
        
set_task(0.3,"show_the_menu",id
        
client_print(idprint_chat"[ZP] You have %i sandbags, to use type 'say / sb'"g_bolsas[id]) 
    }

    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(
g_bag[id] > 1
    { 
        
client_print(idprint_chat"Max Sandbags reached !!!"
        return 
ZP_PLUGIN_HANDLED
    
}
        
    
g_bolsas[id]+= 
    g_bag
[id]++
    
set_task(0.3,"show_the_menu",id
    
client_print(idprint_chat"[ZP] You have %i sandbags, to use type 'say / sb'"g_bolsas[id]) 
    
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) - g_item_bolsas);

    return 
PLUGIN_CONTINUE



ftEntCheckCustom(const iEntID)
{
    new 
iEntFlags pev(iEntIDpev_euser4);
    
    if (!(
iEntFlags g_iEnumBitEntDefault) && !(iEntFlags g_iEnumBitEntCustom))
    {
        static 
szEntClassname[32];
        
pev(iEntIDpev_classnameszEntClassnamecharsmax(szEntClassname))
        
/*        ftD7Log(g_szLogFile, _, _, "[ftEntCheckCustom] EntID: %d. Classname: ^"%s^".", iEntID, szEntClassname)
        */
        
for (new isizeof g_szEntClassNamesi++)
            if (
equali(szEntClassnameg_szEntClassNames[i]))
            {
                
iEntFlags &= ~g_iEnumBitEntDefault;
                
iEntFlags |= g_iEnumBitEntCustom;
                
                if (!
g_bEntRegistered[i])
                {
                    
RegisterHamFromEntity(Ham_SpawniEntID"fwHamSpawnEntPost"1)
                    
RegisterHamFromEntity(Ham_CS_RestartiEntID"fwHamRestartEntPost"1)
                    
                    
g_bEntRegistered[i] = true;
                }
                
                break;
            }
            else if (
== sizeof g_szEntClassNames 1)
            {
                
iEntFlags &= ~g_iEnumBitEntCustom;
                
iEntFlags |= g_iEnumBitEntDefault;
            }
        
        
set_pev(iEntIDpev_euser4iEntFlags)
    }
    
//    ftD7Log(g_szLogFile, _, _, "[ftEntCheckCustom] EntID: %d. Flags: %d.", iEntID, iEntFlags)
    
    
if ((iEntFlags g_iEnumBitEntCustom) && !(iEntFlags g_iEnumBitEntRendered))
/*        i = pev(iEntID, pev_rendermode);
        
        if ((i == kRenderNormal || i == kRenderTransTexture) && pev(iEntID, pev_renderfx) == kRenderFxNone)
        {
        
        }
        */
        
ftSetRender(iEntID)
    
    return 
iEntFlags;
}

public 
fwHamSpawnEntPost(const iEntID)
{
    if (
ftEntCheckCustom(iEntID) & g_iEnumBitEntDefault/* || ftEntCheckMaxHP(iEntID) <= 0.0*/)
        return;
    
    static 
szEntClassname[32];
    
pev(iEntIDpev_classnameszEntClassnamecharsmax(szEntClassname))
    
//    ftD7Log(g_szLogFile, _, _, "[Ham_Spawn] EntID: %d. Classname: ^"%s^".", iEntID, szEntClassname)
    
    
set_pev(iEntIDpev_rendercolor, { 0.0255.00.0 })
}

public 
fwHamRestartEntPost(const iEntID)
{
    if (
ftEntCheckCustom(iEntID) & g_iEnumBitEntDefault/* || ftEntCheckMaxHP(iEntID) <= 0.0*/)
        return;
    
    static 
szEntClassname[32];
    
pev(iEntIDpev_classnameszEntClassnamecharsmax(szEntClassname))
    
//    ftD7Log(g_szLogFile, _, _, "[Ham_CS_Restart] EntID: %d. Classname: ^"%s^".", iEntID, szEntClassname)
    
    
set_pev(iEntIDpev_rendercolor, { 0.0255.00.0 })
}

ftSetRender(const iEntID)
{
    static 
szEntInfo[2];
    
    
pev(iEntIDpev_modelszEntInfocharsmax(szEntInfo))
    
    
szEntInfo[1] = pev(iEntIDpev_euser4);
    
    
// If the first character of the entity model is '*',
    // then it's a brush(non-studio) model
    
if (szEntInfo[0] == '*')
    {
//        ftD7Log(g_szLogFile, _, _, "[ftSetRender] EntID: %d. Initializing render for brush model.", iEntID)
//        
        
szEntInfo[1] &= ~g_iEnumBitEntMdlStudio;
        
szEntInfo[1] |= g_iEnumBitEntMdlBrush;
        
        
set_pev(iEntIDpev_rendermodekRenderTransColor);
        
set_pev(iEntIDpev_renderamt128.0)
    }
    else
    {
        
szEntInfo[1] &= ~g_iEnumBitEntMdlBrush;
        
szEntInfo[1] |= g_iEnumBitEntMdlStudio;
        
        new 
Float:fEntRenderAmt;
        
pev(iEntIDpev_renderamtfEntRenderAmt)
        
//        ftD7Log(g_szLogFile, _, _, "[ftSetRender] EntID: %d. Initializing render for studio model. Renderamt: %f.", iEntID, fEntRenderAmt)
        
        
set_pev(iEntIDpev_renderfxkRenderFxGlowShell)
        
        if (
fEntRenderAmt == 0.0)
            
set_pev(iEntIDpev_renderamt5.0)
    }
    
    
szEntInfo[1] |= g_iEnumBitEntRendered;
    
    
set_pev(iEntIDpev_euser4szEntInfo[1])
}

Float:ftEntCheckMaxHP(const iEntID)
{
    new 
Float:fHealth;
    
pev(iEntIDpev_max_healthfHealth)
    
//    ftD7Log(g_szLogFile, _, _, "[ftEntCheckMaxHP] MaxHP: %f.", fHealth)
    
    
if (fHealth != 0.0)
        return 
fHealth;
    
    
pev(iEntIDpev_healthfHealth)
    
//    ftD7Log(g_szLogFile, _, _, "[ftEntCheckMaxHP] HP: %f.", fHealth)
    
    
if (fHealth <= 0.0)
        return 
fHealth;
    
    
set_pev(iEntIDpev_max_healthfHealth)
    
    return 
fHealth;
}

public 
fwFmSpawnEntPost(const iEntID)
{
    if (!
pev_valid(iEntID))
        return;
    
//    ftD7Log(g_szLogFile, _, _, "[FM_Spawn] EntID: %d.", iEntID)
    
    
if (ftEntCheckCustom(iEntID) & g_iEnumBitEntDefault || ftEntCheckMaxHP(iEntID) <= 0.0)
        return;
    
    
set_pev(iEntIDpev_rendercolor, { 0.0255.00.0 })
}

public 
fwHamTakeDamageEntPre(const iEntID, const iInflictorID, const iAttackerID, const Float:fDamage, const iDamageType)
{
//    ftD7Log(g_szLogFile, _, _, "[Ham_TakeDamage Pre] EntID: %d.", iEntID)
    
    
if (!ftEntCheckCustom(iEntID))
        return;
    
    
ftEntCheckMaxHP(iEntID)
}

public 
fwHamTakeDamageEntPost(const iEntID, const iInflictorID, const iAttackerID, const Float:fDamage, const iDamageType)
{
/*    if (pev(iEntID, pev_takedamage) == DAMAGE_NO)
        return;
    */
//    ftD7Log(g_szLogFile, _, _, "[Ham_TakeDamage Post] EntID: %d.", iEntID)
    
    
if (!ftEntCheckCustom(iEntID))
        return;
    
    new 
Float:fHealth;
    
pev(iEntIDpev_healthfHealth)
    
//    ftD7Log(g_szLogFile, _, _, "[Ham_TakeDamage Post] HP: %f.", fHealth)
    
    
if (fHealth <= 0.0)
    {
        
set_pev(iEntIDpev_euser40)
        
        return;
    }
    
    new 
Float:fHealthMax;
    
pev(iEntIDpev_max_healthfHealthMax)
    
//    ftD7Log(g_szLogFile, _, _, "[Ham_TakeDamage Post] MaxHP: %f.", fHealthMax)
    
    // Entity didn't take damage
    
if (fHealth == fHealthMax)
        return;
    
    
ComputeColor(iEntIDfHealth 100.0 fHealthMax)
}

ComputeColor(const iEntID, const Float:fPercentage)
{
    if (
fPercentage 0.0)
        return;
    
    static 
Float:fColorAmounts[3];
    
    
fColorAmounts[1] = 255.0 fPercentage 100.0// green
    
fColorAmounts[0] = 255.0 fColorAmounts[1]; // red
    
fColorAmounts[2] = 0.0// blue
    
//    ftD7Log(g_szLogFile, _, _, "[ComputeColor] EntID: %d. Percentage: %.2f. Red: %f. Green: %f.", iEntID, fPercentage, fColorAmounts[0], fColorAmounts[1])
    
    
set_pev(iEntIDpev_rendercolorfColorAmounts)
/*    
    if (pev(iEntID, pev_euser4) & g_iEnumBitEntMdlStudio)
        set_pev(iEntID, pev_renderamt, fColorAmounts[1])*/

Responder
#11
#patilla mix , si vas a colocar un código que sea en php Sonrisa
Responder
#12
hermano lo coloque tal cual como lo pusiste y ahora no se ven los sandbag

hermano lo coloque tal cual como lo pusiste y ahora no se ven los sandbag

hermano los sandbag ahora son invisible me imagino por que no se ven al ponerlo
Responder
#13
weon no se ven los sandbag todo funciona debe ser k que el color los puso asi nose
Responder
#14
(20/02/2016, 08:04 PM)Web Controller escribió: Lo hice muy por encima y con el celu. No se si esta bien probalo y si no funca decime logs etc. etc.

Código PHP:
#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) 

enum (<<= 1)
{
    
g_iEnumBitEntDefault 1,
    
g_iEnumBitEntCustom,
    
g_iEnumBitEntMdlBrush,
    
g_iEnumBitEntMdlStudio,
    
g_iEnumBitEntRendered
}

new const 
g_szEntClassNamesSpawn[][] =
{
    
"func_wall"/*,
    "player",
    "hostage_entity"*/
}

new const 
g_szEntClassNames[][] =
{
    
"amxx_pallets"/*,
    "player",
    "hostage_entity",
    "func_breakable"*/
}

// cvars 
new pnumpluginremove_nrndmaxpalletsphealth

new 
g_bEntRegistered[sizeof g_szEntClassNames];

// 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 
g_bag[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 
    
remove_nrnd register_cvar("zp_pb_remround","0"); 
    
maxpallets register_cvar("zp_pb_limit","1"); // 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 /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"
    
    for (new 
isizeof g_szEntClassNamesSpawni++)
    {
        
RegisterHam(Ham_TakeDamageg_szEntClassNamesSpawn[i], "fwHamTakeDamageEntPre")
        
RegisterHam(Ham_TakeDamageg_szEntClassNamesSpawn[i], "fwHamTakeDamageEntPost"1)
    }
    
    
RegisterHam(Ham_TakeDamage,"func_wall","fw_TakeDamage"); 
    
RegisterHam(Ham_Killed"func_wall""fw_PlayerKilled"1)

     

//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) + 5)
        
client_print(attackerprint_chat"[ZP] You earned 5 ammopacks by destroy sandbag!"
        return 
HAM_IGNORED;
    } 
    return 
HAM_IGNORED;


public 
plugin_precache() 

    
register_forward(FM_Spawn"fwFmSpawnEntPost"1);
    for(new 
i;sizeof g_models;i++) 
        
engfunc(EngFunc_PrecacheModel,g_models[i]); 
}

public 
show_the_menu(id,level,cid


    
// 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
    } 
    
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 
                { 
                    
client_print(idprint_chat"[ZP] You do not have to place sandbags!"
                    return 
PLUGIN_CONTINUE 
                

                
g_bolsas[id]-= 
                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     
        

         
             
    } 
     
    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); 
    
    
set_pev(entpev_ownerid);
         
    
// num .. 
    
palletscout++; 
         
    
// confirm message 
    
client_print(idprint_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(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(); 

    g_bolsas[id] = 0  
    g_bag[id] = 0 
  } 
         
}  
*/ 
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,
        
        
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(
g_bag[id] > 1
        { 
            
client_print(idprint_chat"Max Sandbags reached !!!"
            return 
ZP_PLUGIN_HANDLED
        
}
        
g_bolsas[id]+= 
        g_bag
[id]++ 
        
set_task(0.3,"show_the_menu",id
        
client_print(idprint_chat"[ZP] You have %i sandbags, to use type 'say / sb'"g_bolsas[id]) 
    }

    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(
g_bag[id] > 1
    { 
        
client_print(idprint_chat"Max Sandbags reached !!!"
        return 
ZP_PLUGIN_HANDLED
    
}
        
    
g_bolsas[id]+= 
    g_bag
[id]++
    
set_task(0.3,"show_the_menu",id
    
client_print(idprint_chat"[ZP] You have %i sandbags, to use type 'say / sb'"g_bolsas[id]) 
    
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) - g_item_bolsas);

    return 
PLUGIN_CONTINUE



ftEntCheckCustom(const iEntID)
{
    new 
iEntFlags pev(iEntIDpev_euser4);
    
    if (!(
iEntFlags g_iEnumBitEntDefault) && !(iEntFlags g_iEnumBitEntCustom))
    {
        static 
szEntClassname[32];
        
pev(iEntIDpev_classnameszEntClassnamecharsmax(szEntClassname))
        
/*        ftD7Log(g_szLogFile, _, _, "[ftEntCheckCustom] EntID: %d. Classname: ^"%s^".", iEntID, szEntClassname)
        */
        
for (new isizeof g_szEntClassNamesi++)
            if (
equali(szEntClassnameg_szEntClassNames[i]))
            {
                
iEntFlags &= ~g_iEnumBitEntDefault;
                
iEntFlags |= g_iEnumBitEntCustom;
                
                if (!
g_bEntRegistered[i])
                {
                    
RegisterHamFromEntity(Ham_SpawniEntID"fwHamSpawnEntPost"1)
                    
RegisterHamFromEntity(Ham_CS_RestartiEntID"fwHamRestartEntPost"1)
                    
                    
g_bEntRegistered[i] = true;
                }
                
                break;
            }
            else if (
== sizeof g_szEntClassNames 1)
            {
                
iEntFlags &= ~g_iEnumBitEntCustom;
                
iEntFlags |= g_iEnumBitEntDefault;
            }
        
        
set_pev(iEntIDpev_euser4iEntFlags)
    }
    
//    ftD7Log(g_szLogFile, _, _, "[ftEntCheckCustom] EntID: %d. Flags: %d.", iEntID, iEntFlags)
    
    
if ((iEntFlags g_iEnumBitEntCustom) && !(iEntFlags g_iEnumBitEntRendered))
/*        i = pev(iEntID, pev_rendermode);
        
        if ((i == kRenderNormal || i == kRenderTransTexture) && pev(iEntID, pev_renderfx) == kRenderFxNone)
        {
        
        }
        */
        
ftSetRender(iEntID)
    
    return 
iEntFlags;
}

public 
fwHamSpawnEntPost(const iEntID)
{
    if (
ftEntCheckCustom(iEntID) & g_iEnumBitEntDefault/* || ftEntCheckMaxHP(iEntID) <= 0.0*/)
        return;
    
    static 
szEntClassname[32];
    
pev(iEntIDpev_classnameszEntClassnamecharsmax(szEntClassname))
    
//    ftD7Log(g_szLogFile, _, _, "[Ham_Spawn] EntID: %d. Classname: ^"%s^".", iEntID, szEntClassname)
    
    
set_pev(iEntIDpev_rendercolor, { 0.0255.00.0 })
}

public 
fwHamRestartEntPost(const iEntID)
{
    if (
ftEntCheckCustom(iEntID) & g_iEnumBitEntDefault/* || ftEntCheckMaxHP(iEntID) <= 0.0*/)
        return;
    
    static 
szEntClassname[32];
    
pev(iEntIDpev_classnameszEntClassnamecharsmax(szEntClassname))
    
//    ftD7Log(g_szLogFile, _, _, "[Ham_CS_Restart] EntID: %d. Classname: ^"%s^".", iEntID, szEntClassname)
    
    
set_pev(iEntIDpev_rendercolor, { 0.0255.00.0 })
}

ftSetRender(const iEntID)
{
    static 
szEntInfo[2];
    
    
pev(iEntIDpev_modelszEntInfocharsmax(szEntInfo))
    
    
szEntInfo[1] = pev(iEntIDpev_euser4);
    
    
// If the first character of the entity model is '*',
    // then it's a brush(non-studio) model
    
if (szEntInfo[0] == '*')
    {
//        ftD7Log(g_szLogFile, _, _, "[ftSetRender] EntID: %d. Initializing render for brush model.", iEntID)
//        
        
szEntInfo[1] &= ~g_iEnumBitEntMdlStudio;
        
szEntInfo[1] |= g_iEnumBitEntMdlBrush;
        
        
set_pev(iEntIDpev_rendermodekRenderTransColor);
        
set_pev(iEntIDpev_renderamt128.0)
    }
    else
    {
        
szEntInfo[1] &= ~g_iEnumBitEntMdlBrush;
        
szEntInfo[1] |= g_iEnumBitEntMdlStudio;
        
        new 
Float:fEntRenderAmt;
        
pev(iEntIDpev_renderamtfEntRenderAmt)
        
//        ftD7Log(g_szLogFile, _, _, "[ftSetRender] EntID: %d. Initializing render for studio model. Renderamt: %f.", iEntID, fEntRenderAmt)
        
        
set_pev(iEntIDpev_renderfxkRenderFxGlowShell)
        
        if (
fEntRenderAmt == 0.0)
            
set_pev(iEntIDpev_renderamt5.0)
    }
    
    
szEntInfo[1] |= g_iEnumBitEntRendered;
    
    
set_pev(iEntIDpev_euser4szEntInfo[1])
}

Float:ftEntCheckMaxHP(const iEntID)
{
    new 
Float:fHealth;
    
pev(iEntIDpev_max_healthfHealth)
    
//    ftD7Log(g_szLogFile, _, _, "[ftEntCheckMaxHP] MaxHP: %f.", fHealth)
    
    
if (fHealth != 0.0)
        return 
fHealth;
    
    
pev(iEntIDpev_healthfHealth)
    
//    ftD7Log(g_szLogFile, _, _, "[ftEntCheckMaxHP] HP: %f.", fHealth)
    
    
if (fHealth <= 0.0)
        return 
fHealth;
    
    
set_pev(iEntIDpev_max_healthfHealth)
    
    return 
fHealth;
}

public 
fwFmSpawnEntPost(const iEntID)
{
    if (!
pev_valid(iEntID))
        return;
    
//    ftD7Log(g_szLogFile, _, _, "[FM_Spawn] EntID: %d.", iEntID)
    
    
if (ftEntCheckCustom(iEntID) & g_iEnumBitEntDefault || ftEntCheckMaxHP(iEntID) <= 0.0)
        return;
    
    
set_pev(iEntIDpev_rendercolor, { 0.0255.00.0 })
}

public 
fwHamTakeDamageEntPre(const iEntID, const iInflictorID, const iAttackerID, const Float:fDamage, const iDamageType)
{
//    ftD7Log(g_szLogFile, _, _, "[Ham_TakeDamage Pre] EntID: %d.", iEntID)
    
    
if (!ftEntCheckCustom(iEntID))
        return;
    
    
ftEntCheckMaxHP(iEntID)
}

public 
fwHamTakeDamageEntPost(const iEntID, const iInflictorID, const iAttackerID, const Float:fDamage, const iDamageType)
{
/*    if (pev(iEntID, pev_takedamage) == DAMAGE_NO)
        return;
    */
//    ftD7Log(g_szLogFile, _, _, "[Ham_TakeDamage Post] EntID: %d.", iEntID)
    
    
if (!ftEntCheckCustom(iEntID))
        return;
    
    new 
Float:fHealth;
    
pev(iEntIDpev_healthfHealth)
    
//    ftD7Log(g_szLogFile, _, _, "[Ham_TakeDamage Post] HP: %f.", fHealth)
    
    
if (fHealth <= 0.0)
    {
        
set_pev(iEntIDpev_euser40)
        
        return;
    }
    
    new 
Float:fHealthMax;
    
pev(iEntIDpev_max_healthfHealthMax)
    
//    ftD7Log(g_szLogFile, _, _, "[Ham_TakeDamage Post] MaxHP: %f.", fHealthMax)
    
    // Entity didn't take damage
    
if (fHealth == fHealthMax)
        return;
    
    
ComputeColor(iEntIDfHealth 100.0 fHealthMax)
}

ComputeColor(const iEntID, const Float:fPercentage)
{
    if (
fPercentage 0.0)
        return;
    
    static 
Float:fColorAmounts[3];
    
    
fColorAmounts[1] = 255.0 fPercentage 100.0// green
    
fColorAmounts[0] = 255.0 fColorAmounts[1]; // red
    
fColorAmounts[2] = 0.0// blue
    
//    ftD7Log(g_szLogFile, _, _, "[ComputeColor] EntID: %d. Percentage: %.2f. Red: %f. Green: %f.", iEntID, fPercentage, fColorAmounts[0], fColorAmounts[1])
    
    
set_pev(iEntIDpev_rendercolorfColorAmounts)
/*    
    if (pev(iEntID, pev_euser4) & g_iEnumBitEntMdlStudio)
        set_pev(iEntID, pev_renderamt, fColorAmounts[1])*/



Hola lo probe y funciona:
Le podes agregar glow a medida que le quiten la vida al sandbags?

1200 verde
600 amarillo
150 rojo
[Imagen: ban1.jpg]
Responder


Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)