Resolved Coding Help For Bazooka

Coding Help/Re-API Supported
Post Reply
johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

Coding Help For Bazooka

#1

Post by johnnysins2000 » 2 Years Ago

I have tried Many Times to convert this bazooka into ze extra item

But still no luck :/ And now I am Getting confused

Original Zp Code

Code: Select all

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>

static const plugin[] = "[ZP] Extra Item: Bazooka";

static const mrocket[] = "models/zm_bazooka_missile.mdl";
static const mrpg_w[] = "models/w_zm_bazooka.mdl";
static const mrpg_v[] = "models/v_zm_bazooka.mdl";
static const mrpg_p[] = "models/p_zm_bazooka.mdl";
static const sfire[] = "weapons/rocketfire1.wav";
static const sfly[] = "weapons/nuke_fly.wav";
static const shit[] = "weapons/mortarhit.wav";
static const spickup[] = "items/gunpickup2.wav";

static const g_item_name[] = "Базука";
const g_item_cost = 10;
new g_itemid;

new gmsg_screenshake, gmsg_death, gmsg_damage, pcvar_delay, pcvar_maxdmg, pcvar_radius, pcvar_map;
new rocketsmoke, explosion, bazsmoke, white; 
new bool:has_baz[33], bool:CanShoot[33];
new dmgcount[33], pcvar_dmgforpacks, pcvar_award;

public plugin_init()
{
	register_plugin(plugin, "0.6", "Random1");
	
	pcvar_delay = register_cvar("zp_baz_delay", "10.0");
	pcvar_maxdmg = register_cvar("zp_baz_dmg", "500");
	pcvar_radius = register_cvar("zp_baz_radius", "750");
	pcvar_map = register_cvar("zp_baz_map", "0");
	pcvar_dmgforpacks = get_cvar_pointer("zp_human_damage_reward");
	pcvar_award = register_cvar("zp_baz_awardpacks", "1");
	
	if ( pcvar_dmgforpacks == 0 ) {
		set_pcvar_num(pcvar_award, 0);	//if we couldn't read the dmg cvar from zp then set a stop state on dmg reward
		log_amx("[%s] error reading zp_human_damage_reward cvar from zombie plague, turning award for damage off", plugin);
	}
	
	g_itemid = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN);
	
	register_concmd("zp_bazooka", "give_bazooka", ADMIN_KICK, "<name/@all> gives a bazooka to the spcified target");
	register_event("CurWeapon","switch_to_knife","be","1=1","2=29");
	register_event("HLTV", "event_HLTV", "a", "1=0", "2=0")	// New Round
	register_clcmd("drop", "drop_call");
	
	//supports 2 methods of firing, attacking while holding knife and a bind
	register_clcmd("baz_fire", "fire_call");
	register_forward(FM_PlayerPreThink, "fw_prethink");
	
	register_forward(FM_Touch, "fw_touch");
		
	gmsg_screenshake = get_user_msgid("ScreenShake");
	gmsg_death = get_user_msgid("DeathMsg");
	gmsg_damage = get_user_msgid("Damage");
}
public event_HLTV()
{
	//remove entities regardless of cvar
	new rpg_temp = engfunc(EngFunc_FindEntityByString, -1, "classname", "rpg_temp");
	while( rpg_temp > 0) {
		engfunc(EngFunc_RemoveEntity, rpg_temp);
		rpg_temp = engfunc(EngFunc_FindEntityByString, -1, "classname", "rpg_temp");
	}
	
	if ( get_pcvar_num(pcvar_map) ) return;
	
	for( new id = 1; id <= 32; id++ )
		has_baz[id] = false;
}

public zp_extra_item_selected(player, itemid)
{
	if (itemid == g_itemid)
	{
		if ( has_baz[player] )
		{
			zp_set_user_ammo_packs( player, zp_get_user_ammo_packs(player) + g_item_cost );
			client_print(player, print_chat, "Вы приобрели базуку, достанте нож и нажмите на правую кнопку мыши.");
		}
		else {
			has_baz[player] = true;
			CanShoot[player] = true;
			client_print(player, print_chat, "[ZP BAZ] You now have a bazooka, attack while holding knife(will take %2.1f seconds to reload", get_pcvar_float(pcvar_delay));
		}
	}
}
public give_bazooka(id,level,cid)
{
	if (!cmd_access(id,level,cid,1)) {
		console_print(id,"You have no access to that command");
		return;
	}
	if (read_argc() > 2) {
		console_print(id,"Too many arguments supplied.");
		return;
	}
	new arg1[32];
	read_argv(1, arg1, sizeof(arg1) - 1);
	new player = cmd_target(id, arg1, 10);
	if ( !player ) {
		if ( arg1[0] == '@' ) {
			for ( new i = 1; i <= 32; i++ ) {
				if ( is_user_connected(i) && !has_baz[i] && !zp_get_user_zombie(i) ) {
					has_baz[i] = true;
					CanShoot[i] = true;
					client_print(i, print_chat, "[ZP BAZ] You now have a bazooka, attack while holding knife(will take %2.1f seconds to reload", get_pcvar_float(pcvar_delay));
				}
			}
		} else {
			client_print(id, print_chat, "No Such Player/Team");
			return;
		}
	} else if ( !has_baz[player] && !zp_get_user_zombie(player) ) {
		has_baz[player] = true;
		CanShoot[player] = true;
		client_print(player, print_chat, "[ZP BAZ] You now have a bazooka, attack while holding knife(will take %2.1f seconds to reload", get_pcvar_float(pcvar_delay));
	}
}

public zp_user_infected_post(id, infector)
	if ( has_baz[id] )
		drop_rpg_temp(id);

public plugin_precache()
{
	precache_model(mrocket);	

	precache_model(mrpg_w);
	precache_model(mrpg_v);
	precache_model(mrpg_p);

	precache_sound(sfire);
	precache_sound(sfly);
	precache_sound(shit);
	precache_sound(spickup);
	
	rocketsmoke = precache_model("sprites/smoke.spr");
	explosion = precache_model("sprites/fexplo.spr");
	bazsmoke  = precache_model("sprites/steam1.spr");
	white = precache_model("sprites/white.spr");
}

public switch_to_knife(id)
{
	if ( !is_user_alive(id) ) return;
	
	if ( has_baz[id] && CanShoot[id] )
	{
		set_pev(id, pev_viewmodel2, mrpg_v);
		set_pev(id, pev_weaponmodel2, mrpg_p);
	}
}

public fw_prethink(id)
{
	static button;
	button = pev(id, pev_button);
	if ( button & IN_ATTACK )
		fire_call(id);
}
public fire_call(id)
{
	if ( !is_user_alive(id) || !has_baz[id] || !CanShoot[id] ) return;
	
	new weapon = get_user_weapon(id);
	if ( weapon == CSW_KNIFE ) fire_rocket(id);	
}

fire_rocket(id) {
	if ( !CanShoot[id] ) return;
	
	CanShoot[id] = false;
	set_task(get_pcvar_float(pcvar_delay), "rpg_reload", id);
	engclient_cmd(id, "weapon_knife");	//attempt to force model to reset

	new Float:StartOrigin[3], Float:Angle[3];
	pev(id, pev_origin, StartOrigin);
	pev(id, pev_angles, Angle);

	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
	set_pev(ent, pev_classname, "rpgrocket");
	engfunc(EngFunc_SetModel, ent, mrocket);
	set_pev(ent, pev_mins, {-1.0, -1.0, -1.0});
	set_pev(ent, pev_maxs, {1.0, 1.0, 1.0});
	engfunc(EngFunc_SetOrigin, ent, StartOrigin);
	set_pev(ent, pev_angles, Angle);


	set_pev(ent, pev_solid, 2);
	set_pev(ent, pev_movetype, 5);
	set_pev(ent, pev_owner, id);

	new Float:nVelocity[3];
	velocity_by_aim(id, 1500, nVelocity);
	set_pev(ent, pev_velocity, nVelocity);

	emit_sound(ent, CHAN_WEAPON, sfire, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
	emit_sound(ent, CHAN_VOICE, sfly, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);

	message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
	write_byte(22);
	write_short(ent);
	write_short(rocketsmoke);
	write_byte(30);
	write_byte(3);
	write_byte(255);
	write_byte(255);
	write_byte(255);
	write_byte(255);
	message_end();
}
//---------------------------------------------------------------------------------------
public rpg_reload(id)
{
	CanShoot[id] = true;
	if ( get_user_weapon(id) == CSW_KNIFE ) switch_to_knife(id);	//sets our model
}

//---------------------------------------------------------------------------------------
public fw_touch(ent, touched)
{
	if ( !pev_valid(ent) ) return FMRES_IGNORED;
	static entclass[32];
	pev(ent, pev_classname, entclass, 31);
	if ( equali(entclass, "rpg_temp") )
	{
		static touchclass[32];
		pev(touched, pev_classname, touchclass, 31);
		if ( !equali(touchclass, "player") ) return FMRES_IGNORED;
		
		if( !is_user_alive(touched) || zp_get_user_zombie(touched) ) return FMRES_IGNORED;
			
		emit_sound(touched, CHAN_VOICE, spickup, 1.0, ATTN_NORM, 0, PITCH_NORM);
		has_baz[touched] = true;
		
		engfunc(EngFunc_RemoveEntity, ent);
	
		return FMRES_HANDLED;
	}
	else if ( equali(entclass, "rpgrocket") )
	{
		new Float:EndOrigin[3];
		pev(ent, pev_origin, EndOrigin);
		new NonFloatEndOrigin[3];
		NonFloatEndOrigin[0] = floatround(EndOrigin[0]);
		NonFloatEndOrigin[1] = floatround(EndOrigin[1]);
		NonFloatEndOrigin[2] = floatround(EndOrigin[2]);
	
		emit_sound(ent, CHAN_WEAPON, shit, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
		emit_sound(ent, CHAN_VOICE, shit, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
	
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(17);
		write_coord(NonFloatEndOrigin[0]);
		write_coord(NonFloatEndOrigin[1]);
		write_coord(NonFloatEndOrigin[2] + 128);
		write_short(explosion);
		write_byte(60);
		write_byte(255);
		message_end();
	
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(5);
		write_coord(NonFloatEndOrigin[0]);
		write_coord(NonFloatEndOrigin[1]);
		write_coord(NonFloatEndOrigin[2] + 256);
		write_short(bazsmoke);
		write_byte(125);
		write_byte(5);
		message_end();
	
		new maxdamage = get_pcvar_num(pcvar_maxdmg);
		new damageradius = get_pcvar_num(pcvar_radius);
	
		new PlayerPos[3], distance, damage;
		for (new i = 1; i <= 32; i++) {
			if ( is_user_alive(i)) 
				{	
					new id = pev(ent, pev_owner)
					 if  ((zp_get_user_zombie(id)) || (zp_get_user_nemesis(id))) 
						if ((zp_get_user_zombie(i)) || (zp_get_user_nemesis(i))) continue;
						
					if  ((!zp_get_user_zombie(id)) && (!zp_get_user_nemesis(id))) 
						if ((!zp_get_user_zombie(i)) && (!zp_get_user_nemesis(i))) continue;
						
					get_user_origin(i, PlayerPos);
		
					distance = get_distance(PlayerPos, NonFloatEndOrigin);
					if (distance <= damageradius) {	
					message_begin(MSG_ONE, gmsg_screenshake, {0,0,0}, i);
					write_short(1<<14);
					write_short(1<<14);
					write_short(1<<14);
					message_end();
		
					damage = maxdamage - floatround(floatmul(float(maxdamage), floatdiv(float(distance), float(damageradius))));
					new attacker = pev(ent, pev_owner);
		
					baz_damage(i, attacker, damage, "bazooka");
				}
			}
		}
	
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(21);
		write_coord(NonFloatEndOrigin[0]);
		write_coord(NonFloatEndOrigin[1]);
		write_coord(NonFloatEndOrigin[2]);
		write_coord(NonFloatEndOrigin[0]);
		write_coord(NonFloatEndOrigin[1]);
		write_coord(NonFloatEndOrigin[2] + 320);
		write_short(white);
		write_byte(0);
		write_byte(0);
		write_byte(16);
		write_byte(128);
		write_byte(0);
		write_byte(255);
		write_byte(255);
		write_byte(192);
		write_byte(128);
		write_byte(0);
		message_end();
	
		engfunc(EngFunc_RemoveEntity, ent);
		
		return FMRES_HANDLED;
	}
	return FMRES_IGNORED;
}
//---------------------------------------------------------------------------------------
public drop_call(id)
{
	if ( has_baz[id] && get_user_weapon(id) == CSW_KNIFE )
	{
		drop_rpg_temp(id);
		return PLUGIN_HANDLED;	//attempt to block can't drop knife message
	}
	return PLUGIN_CONTINUE;
}

drop_rpg_temp(id) {
	new Float:fAim[3] , Float:fOrigin[3];
	velocity_by_aim(id , 64 , fAim);
	pev(id , pev_origin , fOrigin);

	fOrigin[0] += fAim[0];
	fOrigin[1] += fAim[1];

	new rpg = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));

	set_pev(rpg, pev_classname, "rpg_temp");
	engfunc(EngFunc_SetModel, rpg, mrpg_w);

	set_pev(rpg, pev_mins, { -16.0, -16.0, -16.0 } );
	set_pev(rpg, pev_maxs, { 16.0, 16.0, 16.0 } );

	set_pev(rpg , pev_solid , 1);
	set_pev(rpg , pev_movetype , 6);

	engfunc(EngFunc_SetOrigin, rpg, fOrigin);

	has_baz[id] = false;
}
//---------------------------------------------------------------------------------------
baz_damage(id, attacker, damage, weaponDescription[])
{
	if ( pev(id, pev_takedamage) == DAMAGE_NO ) return;
	if ( damage <= 0 ) return;

	new userHealth = get_user_health(id);
	if (userHealth - damage <= 0 ) {
		dmgcount[attacker] += userHealth - damage;
		set_msg_block(gmsg_death, BLOCK_SET);
		ExecuteHamB(Ham_Killed, id, attacker, 2);
		set_msg_block(gmsg_death, BLOCK_NOT);
	
		
		message_begin(MSG_BROADCAST, gmsg_death);
		write_byte(attacker);
		write_byte(id);
		write_byte(0);
		write_string(weaponDescription);
		message_end();
		
		set_pev(attacker, pev_frags, float(get_user_frags(attacker) + 1));
			
		new kname[32], vname[32], kauthid[32], vauthid[32], kteam[10], vteam[10];
	
		get_user_name(attacker, kname, 31);
		get_user_team(attacker, kteam, 9);
		get_user_authid(attacker, kauthid, 31);
	 
		get_user_name(id, vname, 31);
		get_user_team(id, vteam, 9);
		get_user_authid(id, vauthid, 31);
			
		log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^"", 
		kname, get_user_userid(attacker), kauthid, kteam, 
	 	vname, get_user_userid(id), vauthid, vteam, weaponDescription);
	}
	else {
		dmgcount[attacker] += damage;
		new origin[3];
		get_user_origin(id, origin);
		
		message_begin(MSG_ONE,gmsg_damage,{0,0,0},id);
		write_byte(21);
		write_byte(20);
		write_long(DMG_BLAST);
		write_coord(origin[0]);
		write_coord(origin[1]);
		write_coord(origin[2]);
		message_end();
		
		set_pev(id, pev_health, pev(id, pev_health) - float(damage));
	}
	if ( !get_pcvar_num(pcvar_award) ) return;
	
	new breaker = get_pcvar_num(pcvar_dmgforpacks);
	if ( dmgcount[attacker] > breaker )
	{
		new temp = dmgcount[attacker] / breaker
		if ( temp * breaker > dmgcount[attacker] ) return; //should never be possible
		dmgcount[attacker] -= temp * breaker;
		zp_set_user_ammo_packs( attacker, zp_get_user_ammo_packs(attacker) + temp );
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/


And What i have done


Code: Select all

#include <zombie_escape> 

static const plugin[] = "[ZE] Extra Item: Bazooka";

static const mrocket[] = "models/zm_bazooka_missile.mdl";
static const mrpg_w[] = "models/w_zm_bazooka.mdl";
static const mrpg_v[] = "models/v_zm_bazooka.mdl";
static const mrpg_p[] = "models/p_zm_bazooka.mdl";
static const sfire[] = "weapons/rocketfire1.wav";
static const sfly[] = "weapons/nuke_fly.wav";
static const shit[] = "weapons/mortarhit.wav";
static const spickup[] = "items/gunpickup2.wav";

const g_item_cost = 10;
new g_iItemID

new gmsg_screenshake, gmsg_death, gmsg_damage, pcvar_delay, pcvar_maxdmg, pcvar_radius, pcvar_map;
new rocketsmoke, explosion, bazsmoke, white; 
new bool:has_baz[33], bool:CanShoot[33];
new dmgcount[33] 

public plugin_init()
{
	register_plugin(plugin, "0.6", "Random1");
	
	pcvar_delay = register_cvar("ze_baz_delay", "10.0");
	pcvar_maxdmg = register_cvar("ze_baz_dmg", "500");
	pcvar_radius = register_cvar("ze_baz_radius", "750");
	pcvar_map = register_cvar("ze_baz_map", "0");

	g_iItemID = ze_register_item("Bazooka", 65) 
	
	register_concmd("zp_bazooka", "give_bazooka", ADMIN_KICK, "<name/@all> gives a bazooka to the spcified target");
	register_event("CurWeapon","switch_to_knife","be","1=1","2=29");
	register_event("HLTV", "event_HLTV", "a", "1=0", "2=0")	// New Round
	register_clcmd("drop", "drop_call");
	
	//supports 2 methods of firing, attacking while holding knife and a bind
	register_clcmd("baz_fire", "fire_call");
	register_forward(FM_PlayerPreThink, "fw_prethink");
	
	register_forward(FM_Touch, "fw_touch");
		
	gmsg_screenshake = get_user_msgid("ScreenShake");
	gmsg_death = get_user_msgid("DeathMsg");
	gmsg_damage = get_user_msgid("Damage");
}
public event_HLTV()
{
	//remove entities regardless of cvar
	new rpg_temp = engfunc(EngFunc_FindEntityByString, -1, "classname", "rpg_temp");
	while( rpg_temp > 0) {
		engfunc(EngFunc_RemoveEntity, rpg_temp);
		rpg_temp = engfunc(EngFunc_FindEntityByString, -1, "classname", "rpg_temp");
	}
	
	if ( get_pcvar_num(pcvar_map) ) return;
	
	for( new id = 1; id <= 32; id++ )
		has_baz[id] = false;
}

public ze_select_item_pre(id, itemid)
{
    // This not our item?
    if (itemid != g_iItemID)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    // Finally return that it's available
    return ZE_ITEM_AVAILABLE
}  

public ze_select_item_post(id, itemid)
{
    // This is not our item, Block it here and don't execute the blew code
    if (itemid != g_iItemID)
        return
   
    give_bazooka(id)
}

public give_bazooka(id,level,cid)
{
	if (!cmd_access(id,level,cid,1)) {
		console_print(id,"You have no access to that command");
		return;
	}
	if (read_argc() > 2) {
		console_print(id,"Too many arguments supplied.");
		return;
	}
	new arg1[32];
	read_argv(1, arg1, sizeof(arg1) - 1);
	new player = cmd_target(id, arg1, 10);
	if ( !player ) {
		if ( arg1[0] == '@' ) {
			for ( new i = 1; i <= 32; i++ ) {
				if ( is_user_connected(i) && !has_baz[i] && !zp_get_user_zombie(i) ) {
					has_baz[i] = true;
					CanShoot[i] = true;
					client_print(i, print_chat, "[ZE BAZ] You now have a bazooka, attack while holding knife(will take %2.1f seconds to reload", get_pcvar_float(pcvar_delay));
				}
			}
		} else {
			client_print(id, print_chat, "No Such Player/Team");
			return;
		}
	} else if ( !has_baz[player] && !zp_get_user_zombie(player) ) {
		has_baz[player] = true;
		CanShoot[player] = true;
		client_print(player, print_chat, "[ZE BAZ] You now have a bazooka, attack while holding knife(will take %2.1f seconds to reload", get_pcvar_float(pcvar_delay));
	}
}

public ze_user_infected(id, infector)
	if ( has_baz[id] )
		drop_rpg_temp(id);

public plugin_precache()
{
	precache_model(mrocket);	

	precache_model(mrpg_w);
	precache_model(mrpg_v);
	precache_model(mrpg_p);

	precache_sound(sfire);
	precache_sound(sfly);
	precache_sound(shit);
	precache_sound(spickup);
	
	rocketsmoke = precache_model("sprites/smoke.spr");
	explosion = precache_model("sprites/fexplo.spr");
	bazsmoke  = precache_model("sprites/steam1.spr");
	white = precache_model("sprites/white.spr");
}

public switch_to_knife(id)
{
	if ( !is_user_alive(id) ) return;
	
	if ( has_baz[id] && CanShoot[id] )
	{
		set_pev(id, pev_viewmodel2, mrpg_v);
		set_pev(id, pev_weaponmodel2, mrpg_p);
	}
}

public fw_prethink(id)
{
	static button;
	button = pev(id, pev_button);
	if ( button & IN_ATTACK )
		fire_call(id);
}
public fire_call(id)
{
	if ( !is_user_alive(id) || !has_baz[id] || !CanShoot[id] ) return;
	
	new weapon = get_user_weapon(id);
	if ( weapon == CSW_KNIFE ) fire_rocket(id);	
}

fire_rocket(id) {
	if ( !CanShoot[id] ) return;
	
	CanShoot[id] = false;
	set_task(get_pcvar_float(pcvar_delay), "rpg_reload", id);
	engclient_cmd(id, "weapon_knife");	//attempt to force model to reset

	new Float:StartOrigin[3], Float:Angle[3];
	pev(id, pev_origin, StartOrigin);
	pev(id, pev_angles, Angle);

	new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
	set_pev(ent, pev_classname, "rpgrocket");
	engfunc(EngFunc_SetModel, ent, mrocket);
	set_pev(ent, pev_mins, {-1.0, -1.0, -1.0});
	set_pev(ent, pev_maxs, {1.0, 1.0, 1.0});
	engfunc(EngFunc_SetOrigin, ent, StartOrigin);
	set_pev(ent, pev_angles, Angle);


	set_pev(ent, pev_solid, 2);
	set_pev(ent, pev_movetype, 5);
	set_pev(ent, pev_owner, id);

	new Float:nVelocity[3];
	velocity_by_aim(id, 1500, nVelocity);
	set_pev(ent, pev_velocity, nVelocity);

	emit_sound(ent, CHAN_WEAPON, sfire, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
	emit_sound(ent, CHAN_VOICE, sfly, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);

	message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
	write_byte(22);
	write_short(ent);
	write_short(rocketsmoke);
	write_byte(30);
	write_byte(3);
	write_byte(255);
	write_byte(255);
	write_byte(255);
	write_byte(255);
	message_end();
}
//---------------------------------------------------------------------------------------
public rpg_reload(id)
{
	CanShoot[id] = true;
	if ( get_user_weapon(id) == CSW_KNIFE ) switch_to_knife(id);	//sets our model
}

//---------------------------------------------------------------------------------------
public fw_touch(ent, touched)
{
	if ( !pev_valid(ent) ) return FMRES_IGNORED;
	static entclass[32];
	pev(ent, pev_classname, entclass, 31);
	if ( equali(entclass, "rpg_temp") )
	{
		static touchclass[32];
		pev(touched, pev_classname, touchclass, 31);
		if ( !equali(touchclass, "player") ) return FMRES_IGNORED;
		
		if( !is_user_alive(touched) || zp_get_user_zombie(touched) ) return FMRES_IGNORED;
			
		emit_sound(touched, CHAN_VOICE, spickup, 1.0, ATTN_NORM, 0, PITCH_NORM);
		has_baz[touched] = true;
		
		engfunc(EngFunc_RemoveEntity, ent);
	
		return FMRES_HANDLED;
	}
	else if ( equali(entclass, "rpgrocket") )
	{
		new Float:EndOrigin[3];
		pev(ent, pev_origin, EndOrigin);
		new NonFloatEndOrigin[3];
		NonFloatEndOrigin[0] = floatround(EndOrigin[0]);
		NonFloatEndOrigin[1] = floatround(EndOrigin[1]);
		NonFloatEndOrigin[2] = floatround(EndOrigin[2]);
	
		emit_sound(ent, CHAN_WEAPON, shit, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
		emit_sound(ent, CHAN_VOICE, shit, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
	
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(17);
		write_coord(NonFloatEndOrigin[0]);
		write_coord(NonFloatEndOrigin[1]);
		write_coord(NonFloatEndOrigin[2] + 128);
		write_short(explosion);
		write_byte(60);
		write_byte(255);
		message_end();
	
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(5);
		write_coord(NonFloatEndOrigin[0]);
		write_coord(NonFloatEndOrigin[1]);
		write_coord(NonFloatEndOrigin[2] + 256);
		write_short(bazsmoke);
		write_byte(125);
		write_byte(5);
		message_end();
	
		new maxdamage = get_pcvar_num(pcvar_maxdmg);
		new damageradius = get_pcvar_num(pcvar_radius);
	
		new PlayerPos[3], distance, damage;
		for (new i = 1; i <= 32; i++) {
			if ( is_user_alive(i)) 
				{	
					new id = pev(ent, pev_owner)
					 if  ((zp_get_user_zombie(id)) || (zp_get_user_nemesis(id))) 
						if ((zp_get_user_zombie(i)) || (zp_get_user_nemesis(i))) continue;
						
					if  ((!zp_get_user_zombie(id)) && (!zp_get_user_nemesis(id))) 
						if ((!zp_get_user_zombie(i)) && (!zp_get_user_nemesis(i))) continue;
						
					get_user_origin(i, PlayerPos);
		
					distance = get_distance(PlayerPos, NonFloatEndOrigin);
					if (distance <= damageradius) {	
					message_begin(MSG_ONE, gmsg_screenshake, {0,0,0}, i);
					write_short(1<<14);
					write_short(1<<14);
					write_short(1<<14);
					message_end();
		
					damage = maxdamage - floatround(floatmul(float(maxdamage), floatdiv(float(distance), float(damageradius))));
					new attacker = pev(ent, pev_owner);
		
					baz_damage(i, attacker, damage, "bazooka");
				}
			}
		}
	
		message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
		write_byte(21);
		write_coord(NonFloatEndOrigin[0]);
		write_coord(NonFloatEndOrigin[1]);
		write_coord(NonFloatEndOrigin[2]);
		write_coord(NonFloatEndOrigin[0]);
		write_coord(NonFloatEndOrigin[1]);
		write_coord(NonFloatEndOrigin[2] + 320);
		write_short(white);
		write_byte(0);
		write_byte(0);
		write_byte(16);
		write_byte(128);
		write_byte(0);
		write_byte(255);
		write_byte(255);
		write_byte(192);
		write_byte(128);
		write_byte(0);
		message_end();
	
		engfunc(EngFunc_RemoveEntity, ent);
		
		return FMRES_HANDLED;
	}
	return FMRES_IGNORED;
}
//---------------------------------------------------------------------------------------
public drop_call(id)
{
	if ( has_baz[id] && get_user_weapon(id) == CSW_KNIFE )
	{
		drop_rpg_temp(id);
		return PLUGIN_HANDLED;	//attempt to block can't drop knife message
	}
	return PLUGIN_CONTINUE;
}

drop_rpg_temp(id) {
	new Float:fAim[3] , Float:fOrigin[3];
	velocity_by_aim(id , 64 , fAim);
	pev(id , pev_origin , fOrigin);

	fOrigin[0] += fAim[0];
	fOrigin[1] += fAim[1];

	new rpg = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));

	set_pev(rpg, pev_classname, "rpg_temp");
	engfunc(EngFunc_SetModel, rpg, mrpg_w);

	set_pev(rpg, pev_mins, { -16.0, -16.0, -16.0 } );
	set_pev(rpg, pev_maxs, { 16.0, 16.0, 16.0 } );

	set_pev(rpg , pev_solid , 1);
	set_pev(rpg , pev_movetype , 6);

	engfunc(EngFunc_SetOrigin, rpg, fOrigin);

	has_baz[id] = false;
}
//---------------------------------------------------------------------------------------
baz_damage(id, attacker, damage, weaponDescription[])
{
	if ( pev(id, pev_takedamage) == DAMAGE_NO ) return;
	if ( damage <= 0 ) return;

	new userHealth = get_user_health(id);
	if (userHealth - damage <= 0 ) {
		dmgcount[attacker] += userHealth - damage;
		set_msg_block(gmsg_death, BLOCK_SET);
		ExecuteHamB(Ham_Killed, id, attacker, 2);
		set_msg_block(gmsg_death, BLOCK_NOT);
	
		
		message_begin(MSG_BROADCAST, gmsg_death);
		write_byte(attacker);
		write_byte(id);
		write_byte(0);
		write_string(weaponDescription);
		message_end();
		
		set_pev(attacker, pev_frags, float(get_user_frags(attacker) + 1));
			
		new kname[32], vname[32], kauthid[32], vauthid[32], kteam[10], vteam[10];
	
		get_user_name(attacker, kname, 31);
		get_user_team(attacker, kteam, 9);
		get_user_authid(attacker, kauthid, 31);
	 
		get_user_name(id, vname, 31);
		get_user_team(id, vteam, 9);
		get_user_authid(id, vauthid, 31);
			
		log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^"", 
		kname, get_user_userid(attacker), kauthid, kteam, 
	 	vname, get_user_userid(id), vauthid, vteam, weaponDescription);
	}
	else {
		dmgcount[attacker] += damage;
		new origin[3];
		get_user_origin(id, origin);
		
		message_begin(MSG_ONE,gmsg_damage,{0,0,0},id);
		write_byte(21);
		write_byte(20);
		write_long(DMG_BLAST);
		write_coord(origin[0]);
		write_coord(origin[1]);
		write_coord(origin[2]);
		message_end();
		
		set_pev(id, pev_health, pev(id, pev_health) - float(damage));
	}
	if ( !get_pcvar_num(pcvar_award) ) return;
	
	if ( dmgcount[attacker] > breaker )
	{
		new temp = dmgcount[attacker] / breaker
		if ( temp * breaker > dmgcount[attacker] ) return; //should never be possible
		dmgcount[attacker] -= temp * breaker;
	}
}
Nobody Is That Busy If They Make Time :roll:

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#2

Post by Raheem » 2 Years Ago

-Try and See what i do:

  1. #include <zombie_escape>
  2. #include <amxmisc>
  3.  
  4. static const plugin[] = "[ZP] Extra Item: Bazooka";
  5.  
  6. static const mrocket[] = "models/zm_bazooka_missile.mdl";
  7. static const mrpg_w[] = "models/w_zm_bazooka.mdl";
  8. static const mrpg_v[] = "models/v_zm_bazooka.mdl";
  9. static const mrpg_p[] = "models/p_zm_bazooka.mdl";
  10. static const sfire[] = "weapons/rocketfire1.wav";
  11. static const sfly[] = "weapons/nuke_fly.wav";
  12. static const shit[] = "weapons/mortarhit.wav";
  13. static const spickup[] = "items/gunpickup2.wav";
  14.  
  15. new g_itemid;
  16.  
  17. new gmsg_screenshake, gmsg_death, gmsg_damage, pcvar_delay, pcvar_maxdmg, pcvar_radius, pcvar_map;
  18. new rocketsmoke, explosion, bazsmoke, white;
  19. new bool:has_baz[33], bool:CanShoot[33];
  20. new dmgcount[33], pcvar_dmgforpacks, pcvar_award;
  21.  
  22. public plugin_init()
  23. {
  24.     register_plugin(plugin, "0.6", "Random1");
  25.    
  26.     pcvar_delay = register_cvar("zp_baz_delay", "10.0");
  27.     pcvar_maxdmg = register_cvar("zp_baz_dmg", "500");
  28.     pcvar_radius = register_cvar("zp_baz_radius", "750");
  29.     pcvar_map = register_cvar("zp_baz_map", "0");
  30.     pcvar_dmgforpacks = get_cvar_pointer("zp_human_damage_reward");
  31.     pcvar_award = register_cvar("zp_baz_awardpacks", "1");
  32.    
  33.     if ( pcvar_dmgforpacks == 0 ) {
  34.         set_pcvar_num(pcvar_award, 0);  //if we couldn't read the dmg cvar from zp then set a stop state on dmg reward
  35.         log_amx("[%s] error reading zp_human_damage_reward cvar from zombie plague, turning award for damage off", plugin);
  36.     }
  37.    
  38.     g_itemid = ze_register_item("Bazooka", 65);
  39.    
  40.     register_concmd("zp_bazooka", "give_bazooka", ADMIN_KICK, "<name/@all> gives a bazooka to the spcified target");
  41.     register_event("CurWeapon","switch_to_knife","be","1=1","2=29");
  42.     register_event("HLTV", "event_HLTV", "a", "1=0", "2=0") // New Round
  43.     register_clcmd("drop", "drop_call");
  44.    
  45.     //supports 2 methods of firing, attacking while holding knife and a bind
  46.     register_clcmd("baz_fire", "fire_call");
  47.     register_forward(FM_PlayerPreThink, "fw_prethink");
  48.    
  49.     register_forward(FM_Touch, "fw_touch");
  50.        
  51.     gmsg_screenshake = get_user_msgid("ScreenShake");
  52.     gmsg_death = get_user_msgid("DeathMsg");
  53.     gmsg_damage = get_user_msgid("Damage");
  54. }
  55. public event_HLTV()
  56. {
  57.     //remove entities regardless of cvar
  58.     new rpg_temp = engfunc(EngFunc_FindEntityByString, -1, "classname", "rpg_temp");
  59.     while( rpg_temp > 0) {
  60.         engfunc(EngFunc_RemoveEntity, rpg_temp);
  61.         rpg_temp = engfunc(EngFunc_FindEntityByString, -1, "classname", "rpg_temp");
  62.     }
  63.    
  64.     if ( get_pcvar_num(pcvar_map) ) return;
  65.    
  66.     for( new id = 1; id <= 32; id++ )
  67.         has_baz[id] = false;
  68. }
  69.  
  70. public ze_select_item_pre(id, itemid)
  71. {
  72.     // This not our item?
  73.     if (itemid != g_itemid)
  74.         return ZE_ITEM_AVAILABLE
  75.    
  76.     // Available for Humans only, So don't show it for zombies
  77.     if (ze_is_user_zombie(id))
  78.         return ZE_ITEM_DONT_SHOW
  79.    
  80.     // Finally return that it's available
  81.     return ZE_ITEM_AVAILABLE
  82. }  
  83.  
  84. public ze_select_item_post(id, itemid)
  85. {
  86.     // This is not our item, Block it here and don't execute the blew code
  87.     if (itemid != g_itemid)
  88.         return
  89.  
  90.     has_baz[id] = true;
  91.     CanShoot[id] = true;
  92. }
  93.  
  94. public give_bazooka(id,level,cid)
  95. {
  96.     if (!cmd_access(id,level,cid,1)) {
  97.         console_print(id,"You have no access to that command");
  98.         return;
  99.     }
  100.     if (read_argc() > 2) {
  101.         console_print(id,"Too many arguments supplied.");
  102.         return;
  103.     }
  104.     new arg1[32];
  105.     read_argv(1, arg1, sizeof(arg1) - 1);
  106.     new player = cmd_target(id, arg1, 10);
  107.     if ( !player ) {
  108.         if ( arg1[0] == '@' ) {
  109.             for ( new i = 1; i <= 32; i++ ) {
  110.                 if ( is_user_connected(i) && !has_baz[i] && !ze_is_user_zombie(i) ) {
  111.                     has_baz[i] = true;
  112.                     CanShoot[i] = true;
  113.                     client_print(i, print_chat, "[ZP BAZ] You now have a bazooka, attack while holding knife(will take %2.1f seconds to reload", get_pcvar_float(pcvar_delay));
  114.                 }
  115.             }
  116.         } else {
  117.             client_print(id, print_chat, "No Such Player/Team");
  118.             return;
  119.         }
  120.     } else if ( !has_baz[player] && !ze_is_user_zombie(player) ) {
  121.         has_baz[player] = true;
  122.         CanShoot[player] = true;
  123.         client_print(player, print_chat, "[ZP BAZ] You now have a bazooka, attack while holding knife(will take %2.1f seconds to reload", get_pcvar_float(pcvar_delay));
  124.     }
  125. }
  126.  
  127. public ze_user_infected(id, infector)
  128.     if ( has_baz[id] )
  129.         drop_rpg_temp(id);
  130.  
  131. public plugin_precache()
  132. {
  133.     precache_model(mrocket);   
  134.  
  135.     precache_model(mrpg_w);
  136.     precache_model(mrpg_v);
  137.     precache_model(mrpg_p);
  138.  
  139.     precache_sound(sfire);
  140.     precache_sound(sfly);
  141.     precache_sound(shit);
  142.     precache_sound(spickup);
  143.    
  144.     rocketsmoke = precache_model("sprites/smoke.spr");
  145.     explosion = precache_model("sprites/fexplo.spr");
  146.     bazsmoke  = precache_model("sprites/steam1.spr");
  147.     white = precache_model("sprites/white.spr");
  148. }
  149.  
  150. public switch_to_knife(id)
  151. {
  152.     if ( !is_user_alive(id) ) return;
  153.    
  154.     if ( has_baz[id] && CanShoot[id] )
  155.     {
  156.         set_pev(id, pev_viewmodel2, mrpg_v);
  157.         set_pev(id, pev_weaponmodel2, mrpg_p);
  158.     }
  159. }
  160.  
  161. public fw_prethink(id)
  162. {
  163.     static button;
  164.     button = pev(id, pev_button);
  165.     if ( button & IN_ATTACK )
  166.         fire_call(id);
  167. }
  168. public fire_call(id)
  169. {
  170.     if ( !is_user_alive(id) || !has_baz[id] || !CanShoot[id] ) return;
  171.    
  172.     new weapon = get_user_weapon(id);
  173.     if ( weapon == CSW_KNIFE ) fire_rocket(id);
  174. }
  175.  
  176. fire_rocket(id) {
  177.     if ( !CanShoot[id] ) return;
  178.    
  179.     CanShoot[id] = false;
  180.     set_task(get_pcvar_float(pcvar_delay), "rpg_reload", id);
  181.     engclient_cmd(id, "weapon_knife");  //attempt to force model to reset
  182.  
  183.     new Float:StartOrigin[3], Float:Angle[3];
  184.     pev(id, pev_origin, StartOrigin);
  185.     pev(id, pev_angles, Angle);
  186.  
  187.     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
  188.     set_pev(ent, pev_classname, "rpgrocket");
  189.     engfunc(EngFunc_SetModel, ent, mrocket);
  190.     set_pev(ent, pev_mins, {-1.0, -1.0, -1.0});
  191.     set_pev(ent, pev_maxs, {1.0, 1.0, 1.0});
  192.     engfunc(EngFunc_SetOrigin, ent, StartOrigin);
  193.     set_pev(ent, pev_angles, Angle);
  194.  
  195.  
  196.     set_pev(ent, pev_solid, 2);
  197.     set_pev(ent, pev_movetype, 5);
  198.     set_pev(ent, pev_owner, id);
  199.  
  200.     new Float:nVelocity[3];
  201.     velocity_by_aim(id, 1500, nVelocity);
  202.     set_pev(ent, pev_velocity, nVelocity);
  203.  
  204.     emit_sound(ent, CHAN_WEAPON, sfire, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  205.     emit_sound(ent, CHAN_VOICE, sfly, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  206.  
  207.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  208.     write_byte(22);
  209.     write_short(ent);
  210.     write_short(rocketsmoke);
  211.     write_byte(30);
  212.     write_byte(3);
  213.     write_byte(255);
  214.     write_byte(255);
  215.     write_byte(255);
  216.     write_byte(255);
  217.     message_end();
  218. }
  219. //---------------------------------------------------------------------------------------
  220. public rpg_reload(id)
  221. {
  222.     CanShoot[id] = true;
  223.     if ( get_user_weapon(id) == CSW_KNIFE ) switch_to_knife(id);    //sets our model
  224. }
  225.  
  226. //---------------------------------------------------------------------------------------
  227. public fw_touch(ent, touched)
  228. {
  229.     if ( !pev_valid(ent) ) return FMRES_IGNORED;
  230.     static entclass[32];
  231.     pev(ent, pev_classname, entclass, 31);
  232.     if ( equali(entclass, "rpg_temp") )
  233.     {
  234.         static touchclass[32];
  235.         pev(touched, pev_classname, touchclass, 31);
  236.         if ( !equali(touchclass, "player") ) return FMRES_IGNORED;
  237.        
  238.         if( !is_user_alive(touched) || ze_is_user_zombie(touched) ) return FMRES_IGNORED;
  239.            
  240.         emit_sound(touched, CHAN_VOICE, spickup, 1.0, ATTN_NORM, 0, PITCH_NORM);
  241.         has_baz[touched] = true;
  242.        
  243.         engfunc(EngFunc_RemoveEntity, ent);
  244.    
  245.         return FMRES_HANDLED;
  246.     }
  247.     else if ( equali(entclass, "rpgrocket") )
  248.     {
  249.         new Float:EndOrigin[3];
  250.         pev(ent, pev_origin, EndOrigin);
  251.         new NonFloatEndOrigin[3];
  252.         NonFloatEndOrigin[0] = floatround(EndOrigin[0]);
  253.         NonFloatEndOrigin[1] = floatround(EndOrigin[1]);
  254.         NonFloatEndOrigin[2] = floatround(EndOrigin[2]);
  255.    
  256.         emit_sound(ent, CHAN_WEAPON, shit, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  257.         emit_sound(ent, CHAN_VOICE, shit, VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
  258.    
  259.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  260.         write_byte(17);
  261.         write_coord(NonFloatEndOrigin[0]);
  262.         write_coord(NonFloatEndOrigin[1]);
  263.         write_coord(NonFloatEndOrigin[2] + 128);
  264.         write_short(explosion);
  265.         write_byte(60);
  266.         write_byte(255);
  267.         message_end();
  268.    
  269.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  270.         write_byte(5);
  271.         write_coord(NonFloatEndOrigin[0]);
  272.         write_coord(NonFloatEndOrigin[1]);
  273.         write_coord(NonFloatEndOrigin[2] + 256);
  274.         write_short(bazsmoke);
  275.         write_byte(125);
  276.         write_byte(5);
  277.         message_end();
  278.    
  279.         new maxdamage = get_pcvar_num(pcvar_maxdmg);
  280.         new damageradius = get_pcvar_num(pcvar_radius);
  281.    
  282.         new PlayerPos[3], distance, damage;
  283.         for (new i = 1; i <= 32; i++) {
  284.             if ( is_user_alive(i))
  285.                 {  
  286.                     new id = pev(ent, pev_owner)
  287.                     if ((ze_is_user_zombie(id)))
  288.                         continue;
  289.                        
  290.                     get_user_origin(i, PlayerPos);
  291.        
  292.                     distance = get_distance(PlayerPos, NonFloatEndOrigin);
  293.                     if (distance <= damageradius) {
  294.                     message_begin(MSG_ONE, gmsg_screenshake, {0,0,0}, i);
  295.                     write_short(1<<14);
  296.                     write_short(1<<14);
  297.                     write_short(1<<14);
  298.                     message_end();
  299.        
  300.                     damage = maxdamage - floatround(floatmul(float(maxdamage), floatdiv(float(distance), float(damageradius))));
  301.                     new attacker = pev(ent, pev_owner);
  302.        
  303.                     baz_damage(i, attacker, damage, "bazooka");
  304.                 }
  305.             }
  306.         }
  307.    
  308.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
  309.         write_byte(21);
  310.         write_coord(NonFloatEndOrigin[0]);
  311.         write_coord(NonFloatEndOrigin[1]);
  312.         write_coord(NonFloatEndOrigin[2]);
  313.         write_coord(NonFloatEndOrigin[0]);
  314.         write_coord(NonFloatEndOrigin[1]);
  315.         write_coord(NonFloatEndOrigin[2] + 320);
  316.         write_short(white);
  317.         write_byte(0);
  318.         write_byte(0);
  319.         write_byte(16);
  320.         write_byte(128);
  321.         write_byte(0);
  322.         write_byte(255);
  323.         write_byte(255);
  324.         write_byte(192);
  325.         write_byte(128);
  326.         write_byte(0);
  327.         message_end();
  328.    
  329.         engfunc(EngFunc_RemoveEntity, ent);
  330.        
  331.         return FMRES_HANDLED;
  332.     }
  333.     return FMRES_IGNORED;
  334. }
  335. //---------------------------------------------------------------------------------------
  336. public drop_call(id)
  337. {
  338.     if ( has_baz[id] && get_user_weapon(id) == CSW_KNIFE )
  339.     {
  340.         drop_rpg_temp(id);
  341.         return PLUGIN_HANDLED;  //attempt to block can't drop knife message
  342.     }
  343.     return PLUGIN_CONTINUE;
  344. }
  345.  
  346. drop_rpg_temp(id) {
  347.     new Float:fAim[3] , Float:fOrigin[3];
  348.     velocity_by_aim(id , 64 , fAim);
  349.     pev(id , pev_origin , fOrigin);
  350.  
  351.     fOrigin[0] += fAim[0];
  352.     fOrigin[1] += fAim[1];
  353.  
  354.     new rpg = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
  355.  
  356.     set_pev(rpg, pev_classname, "rpg_temp");
  357.     engfunc(EngFunc_SetModel, rpg, mrpg_w);
  358.  
  359.     set_pev(rpg, pev_mins, { -16.0, -16.0, -16.0 } );
  360.     set_pev(rpg, pev_maxs, { 16.0, 16.0, 16.0 } );
  361.  
  362.     set_pev(rpg , pev_solid , 1);
  363.     set_pev(rpg , pev_movetype , 6);
  364.  
  365.     engfunc(EngFunc_SetOrigin, rpg, fOrigin);
  366.  
  367.     has_baz[id] = false;
  368. }
  369. //---------------------------------------------------------------------------------------
  370. baz_damage(id, attacker, damage, weaponDescription[])
  371. {
  372.     if ( pev(id, pev_takedamage) == DAMAGE_NO ) return;
  373.     if ( damage <= 0 ) return;
  374.  
  375.     new userHealth = get_user_health(id);
  376.     if (userHealth - damage <= 0 ) {
  377.         dmgcount[attacker] += userHealth - damage;
  378.         set_msg_block(gmsg_death, BLOCK_SET);
  379.         ExecuteHamB(Ham_Killed, id, attacker, 2);
  380.         set_msg_block(gmsg_death, BLOCK_NOT);
  381.    
  382.        
  383.         message_begin(MSG_BROADCAST, gmsg_death);
  384.         write_byte(attacker);
  385.         write_byte(id);
  386.         write_byte(0);
  387.         write_string(weaponDescription);
  388.         message_end();
  389.        
  390.         set_pev(attacker, pev_frags, float(get_user_frags(attacker) + 1));
  391.            
  392.         new kname[32], vname[32], kauthid[32], vauthid[32], kteam[10], vteam[10];
  393.    
  394.         get_user_name(attacker, kname, 31);
  395.         get_user_team(attacker, kteam, 9);
  396.         get_user_authid(attacker, kauthid, 31);
  397.      
  398.         get_user_name(id, vname, 31);
  399.         get_user_team(id, vteam, 9);
  400.         get_user_authid(id, vauthid, 31);
  401.            
  402.         log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^"",
  403.         kname, get_user_userid(attacker), kauthid, kteam,
  404.         vname, get_user_userid(id), vauthid, vteam, weaponDescription);
  405.     }
  406.     else {
  407.         dmgcount[attacker] += damage;
  408.         new origin[3];
  409.         get_user_origin(id, origin);
  410.        
  411.         message_begin(MSG_ONE,gmsg_damage,{0,0,0},id);
  412.         write_byte(21);
  413.         write_byte(20);
  414.         write_long(DMG_BLAST);
  415.         write_coord(origin[0]);
  416.         write_coord(origin[1]);
  417.         write_coord(origin[2]);
  418.         message_end();
  419.        
  420.         set_pev(id, pev_health, pev(id, pev_health) - float(damage));
  421.     }
  422.     if ( !get_pcvar_num(pcvar_award) ) return;
  423.    
  424.     new breaker = get_pcvar_num(pcvar_dmgforpacks);
  425.     if ( dmgcount[attacker] > breaker )
  426.     {
  427.         new temp = dmgcount[attacker] / breaker
  428.         if ( temp * breaker > dmgcount[attacker] ) return; //should never be possible
  429.         dmgcount[attacker] -= temp * breaker;
  430.         ze_set_escape_coins( attacker, ze_get_escape_coins(attacker) + temp );
  431.     }
  432. }

-Before you compile go to include folder and open amxmisc.inc then delete these lines:

  1. stock register_menu(const title[],keys,const function[],outside=0)
  2. {
  3.     register_menucmd(register_menuid(title,outside),keys,function);
  4. }
You don't know? Learn and you will know.

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#3

Post by johnnysins2000 » 2 Years Ago

I see instead of this

Code: Select all

public ze_select_item_post(id, itemid)
{
    // This is not our item, Block it here and don't execute the blew code
    if (itemid != g_iItemID)
        return
   
    give_bazooka(id)
}
U Changed give_bazooka(id)

and wrote this instead

Code: Select all

  has_baz[id] = true;
    CanShoot[id] = true;

You Also Included amxmisc here


and also in the last line of the code which is this

Code: Select all

zp_set_user_ammo_packs( attacker, zp_get_user_ammo_packs(attacker) + temp );

U used ze_set_escape_coins( attacker, ze_get_escape_coins(attacker) + temp );


Well this thing u used in the last line is new to me and I don't know when to use this native But thanks Anyway

I wanted To Ask You A Question Bro ?

Why we use this native ?

public ze_select_item_post(id, itemid)
Nobody Is That Busy If They Make Time :roll:

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#4

Post by Raheem » 2 Years Ago

ِAbout natives and forwards, I worte a topic about it and explained it in details so you need to just read them so you know when to use them and when not. Forwards/Natives.

About ze_select_item_post() We on it write the code that will give the player the item in it. And in Pre we write all conditions we need like this item for humans only or for zombies and so on. First the all codes in the Pre Select will be executed and then if you return in the Pre Select that item available it will now start execute the select post function. Also read Forwards/Natives Thread to understand more.
You don't know? Learn and you will know.

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#5

Post by johnnysins2000 » 2 Years Ago

One More Question Bro


// Available for Humans only, So don't show it for zombies
if (ze_is_user_zombie(id))
return ZE_ITEM_DONT_SHOW


We Use this because we want the extra items for this only but what if i wanted to set it for zombie only ?

Then which native we should use ?
Nobody Is That Busy If They Make Time :roll:

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#6

Post by Raheem » 2 Years Ago

It will be:

  1. // Available for Zombies only, So don't show it for Humans
  2. if (!ze_is_user_zombie(id))
  3.     return ZE_ITEM_DONT_SHOW

! - Operator means Not. So now it's like: If the Player not Zombie >> Don't Show him the Menu.
The player which not Zombie is Human as there is only 2 teams so if he not Zombie so he is now Human. Hope you get this.
You don't know? Learn and you will know.

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#7

Post by johnnysins2000 » 2 Years Ago

I got it bro
Nobody Is That Busy If They Make Time :roll:

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#8

Post by Raheem » 2 Years Ago

Nice i'am happy to know that :).
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests