Hi! I don't know how to add colors to my sandbags. For example when it has 600-300 health to be blue , 300-150 green and 150-0 red. Can somebody help me please.
Not tested, but try this #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)
// 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 g_item_name[] = { "SandBags X2" } const g_item_bolsas = 30 new g_itemid_bolsas new ZPSTUCK
/************************************************************* ************************* AMXX PLUGIN ************************* **************************************************************/ new r, g, b
public plugin_init() { /* Register the plugin */
register_plugin("[RoD|*] Extra: SandBags X2", "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","200"); // max number of pallets with bags phealth = register_cvar("zp_pb_health","600"); // set the health to a pallet with bags
/* Game Events */ register_event("HLTV","event_newround", "a","1=0", "2=0"); // it's called every on new round
/* This is for menuz: */ register_menucmd(register_menuid("\ySand Bags:"), 1023, "menu_command" ); register_clcmd("say /sb","show_the_menu"); register_clcmd("say_team /sb","show_the_menu");
// Render Cvars r =register_cvar("s_red", "128") g = register_cvar("s_green", "0") b = register_cvar("s_blue", "128")
} //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))
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, "[CEDEGE] 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, "[CEDEGE] You do not have to place sandbags!") return PLUGIN_CONTINUE } g_bolsas[id]-= 1 place_palletwbags(id); static red, green, blue red = get_pcvar_num(r) green = get_pcvar_num(g) blue = get_pcvar_num(b) fm_set_rendering(id, kRenderFxGlowShell, red, green, blue, kRenderNormal, 20) show_the_menu(id,level,cid); return PLUGIN_CONTINUE } client_print(id, print_chat, "[CEDEGE] 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, "[CEDEGE] You are not aiming at a pallet with bags"); } else client_print(id, print_chat, "[CEDEGE] 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,"[CEDEGE] 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,"[CEDEGE] You can not put sandbags in the sky!"); return PLUGIN_HANDLED; }
// 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); }
// confirm message client_print(id, print_chat, "[CEDEGE] 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];
/* ==================================================== 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();
/* ==================================================== This is a stock to help for remove all pallets with bags placed . Is called on new round if the cvar "pallets_wbags_nroundrem" is set 1. ====================================================*/ stock remove_allpalletswbags() { new pallets = -1; while((pallets = fm_find_ent_by_class(pallets, "amxx_pallets"))) fm_remove_entity(pallets);
palletscout = 0; }
public checkstuck() { if ( get_pcvar_num(ZPSTUCK) == 1 ) { static players[32], pnum, player get_players(players, pnum) static Float:origin[3] static Float:mins[3], hull static Float:vec[3] static o,i for(i=0; i<pnum; i++){ player = players[i] if (is_user_connected(player) && is_user_alive(player)) { pev(player, pev_origin, origin) hull = pev(player, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN if (!is_hull_vacant(origin, hull,player) && !fm_get_user_noclip(player) && !(pev(player,pev_solid) &