(ReAPI) Weapons Icon + Dead Effect (solved)

Coding Help/Re-API Supported
Post Reply
User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

(ReAPI) Weapons Icon + Dead Effect (solved)

#1

Post by ArminC » 6 years ago

Can someone optimize it into ReAPI? It's very old tough.. Plus from what I did understand the "Gernade sprites are scewing up - flashbang is showing part of HE, Smoke is HE gernade, sigh..."

Code: Select all

#include <amxmodx>

#define PLUGIN "Weapon Icon"
#define VERSION "1.0"
#define AUTHOR "Zenix (m$ubn)"

new iconstatus;
new user_icons[32][192];
new icon_origin[3] = {0,0,0}
new pcv_show;
new pcv_iloc;

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_event ("CurWeapon", "update_icon", "ab")
	register_event("DeathMsg", "event_death", "a")
	pcv_show = register_cvar("amx_show_weapon_icon", "1");
	pcv_iloc = register_cvar("amx_show_weapon_icon_location", "1");
	register_concmd("amx_weapon_icon", "weapon_icon_toggle", ADMIN_CVAR, "Toggle display of the weapon icon on/off (default on)")
	
	check_icon_loc();
}

public update_icon(id) {
	check_icon_loc();
	if(!get_pcvar_num(pcv_show) || get_pcvar_num(pcv_iloc) == 0)
		return PLUGIN_CONTINUE;
	
	if(is_user_alive(id))
	{
		new iwpn, wclip, wammo, sprite[192], icon_color[3] = {0, 160, 0}
		
		remove_weapon_icon(id)
		
		iwpn = get_user_weapon(id, wclip, wammo)
		switch(iwpn) {
			case CSW_P228: sprite = "d_p228"
				case CSW_SCOUT: sprite = "d_scout"
				case CSW_HEGRENADE: sprite = "d_grenade"
				case CSW_XM1014: sprite = "d_xm1014"
				case CSW_C4: sprite = "d_c4"
				case CSW_MAC10: sprite = "d_mac10"
				case CSW_AUG: sprite = "d_aug"
				case CSW_SMOKEGRENADE: sprite = "d_grenade"
				case CSW_ELITE: sprite = "d_elite"
				case CSW_FIVESEVEN: sprite = "d_fiveseven"
				case CSW_UMP45: sprite = "d_ump45"
				case CSW_SG550: sprite = "d_sg550"
				case CSW_GALIL: sprite = "d_galil"
				case CSW_FAMAS: sprite = "d_famas"
				case CSW_USP: sprite = "d_usp"
				case CSW_MP5NAVY: sprite = "d_mp5navy"
				case CSW_M249: sprite = "d_m249"
				case CSW_M3: sprite = "d_m3"
				case CSW_M4A1: sprite = "d_m4a1"
				case CSW_TMP: sprite = "d_tmp"
				case CSW_G3SG1: sprite = "d_g3sg1"
				case CSW_FLASHBANG: sprite = "d_flashbang"
				case CSW_DEAGLE: sprite = "d_deagle"
				case CSW_SG552: sprite = "d_sg552"
				case CSW_AK47: sprite = "d_ak47"
				case CSW_KNIFE: sprite = "d_knife"
				case CSW_P90: sprite = "d_p90"
				case CSW_VEST: sprite = "suit_full"
				case CSW_VESTHELM: sprite = "suithelmet_full"
				case CSW_GLOCK18: sprite = "d_glock18"
				case CSW_AWP: sprite = "d_awp"
				case 0: sprite = ""
				default: sprite = ""
		}
		if (is_user_ok(id)) {
			if (equali(sprite, "") || !is_user_ok(id)) {
				remove_weapon_icon(id)
				} else {
				// draw the sprite itself (only on a human user's screen)
				// marker ////////////////////////////////////////////////////////////////////////////////
				message_begin(MSG_ONE,iconstatus,icon_origin,id);
				write_byte(1); // status (0=hide, 1=show, 2=flash)
				write_string(sprite); // sprite name
				
				/*
				4 stages - Normal, 1 Clip, No Clip + Some ammo, Completely Out
				
				*/
				
				// ammo check, this is for the color of the icon
				get_user_ammo(id, iwpn, wammo, wclip) // update vars correctly
				if (wclip == 0 && wammo == 0) icon_color = {0, 0, 255} // outta ammo!
				if (wclip == wammo || wclip > wammo) icon_color = {255, 150, 150} // last clip!
				if (wammo > 0 && wclip == 0) icon_color = {255, 100, 100} // almost out!
				// attempt at percentage max clip & % red/green color
				// 1: Get max ammo for weapon
				//maxammo = maxclip(iwpn);
				
				
				write_byte(icon_color[0]); // red
				write_byte(icon_color[1]); // green
				write_byte(icon_color[2]); // blue
				message_end();
			}
			user_icons[id] = sprite;
		}
	}
	return PLUGIN_CONTINUE
} 

public weapon_icon_toggle(id) {
	new toggle[32], players[32], num, player, status[32] = "enabled"
	read_argv(1, toggle, 1)
	
	if (equali(toggle, "1")) {
		status = "enabled"
		} else if (equali(toggle, "0")) {
		status = "disabled"
		} else if (equali(toggle, "")) {
		console_print(id, "Usage: amx_weapon_icon <1/0> - Toggles wether or not showing the user's current weapon as an icon")
		console_print(id, "Weapon Icon is currently %s", status)
		return PLUGIN_HANDLED
	}
	
	set_cvar_string("amx_show_weapon_icon", toggle)
	client_print(0, print_chat, "Weapon Icon is now %s", status)
	get_players(players, num)
	for (new i=0; i<num; i++) {
		player = players[i]
		if (!equali(user_icons[player], "") && !equali(players[i], "") && is_user_ok(id)) {
			remove_weapon_icon(i)
		}
	}
	return PLUGIN_CONTINUE
}

public remove_weapon_icon(id) {
	if (is_user_ok(id)) {
		message_begin(MSG_ONE,iconstatus,icon_origin,id);
		write_byte(0);
		write_string(user_icons[id]);
		message_end();
	}
}

public is_user_ok(id) {
	// check if the user is "ok": they are connected, not a bot, and alive
	if (is_user_connected(id) && !is_user_bot(id) && is_user_alive(id))
		return true
	return false
}

public event_death() {
	new player = read_data(2) // the dead player's ID (1-32)
	if (is_user_connected(player) && !is_user_bot(player)) { // remove icon
		message_begin(MSG_ONE,iconstatus,icon_origin,player);
		write_byte(0);
		write_string(user_icons[player]);
		message_end();
	}
}

public check_icon_loc() {
	if(!get_pcvar_num(pcv_iloc))
		return PLUGIN_CONTINUE;
	new value = get_pcvar_num(pcv_iloc);
	if (value == 0)
		iconstatus = 0;
	if (value == 1)
		iconstatus = get_user_msgid("StatusIcon");
	if (value == 2)
		iconstatus = get_user_msgid("Scenario");
	return PLUGIN_CONTINUE;
}
2. For this to optimize trough ReAPI too

Code: Select all

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

//Define fade type
#define FFADE_OUT 0x0001
#define SPECMODE_ALIVE 0

//CVAR
new cvar_death, cvar_red, cvar_green, cvar_blue, cvar_damage

//MSG
new g_MsgScreenFade, g_MsgScreenShake

public plugin_init()
{
	// Register plugin call
	register_plugin("Damage & Death Effect", "1.3.3", "YKH =]")

	//CVAR
	cvar_death = register_cvar("amx_killed_effect_on", "1")
    	cvar_red  = register_cvar("death_color_r","0")
    	cvar_green  =  register_cvar("death_color_g","0")
    	cvar_blue =  register_cvar("death_color_b","0") 
    	cvar_damage =  register_cvar("damage_num","60")

	//Forward
	RegisterHam(Ham_Killed, "player", "fw_Killed")
	RegisterHam(Ham_Killed, "player", "Ham_Killed_player_Post", 1);
	RegisterHam(Ham_TakeDamage, "player", "fw_Damage")

	// Message IDs
	g_MsgScreenFade = get_user_msgid("ScreenFade")
	g_MsgScreenShake = get_user_msgid("ScreenShake")
}

public fw_Killed(victim)
{
	if(get_pcvar_num(cvar_death))
	{
		message_begin(MSG_ONE_UNRELIABLE, g_MsgScreenFade, _, victim)
		write_short(12288)	// Duration
		write_short(12288)	// Hold time
		write_short(FFADE_OUT)	// Fade type
		write_byte (get_pcvar_num(cvar_red))		// Red
		write_byte (get_pcvar_num(cvar_green))		// Green
		write_byte (get_pcvar_num(cvar_blue))		// Blue
		write_byte (255)	// Alpha
		message_end()
	}
}
public Ham_Killed_player_Post(victim, attacker)
{
	set_pev(victim, pev_iuser1, SPECMODE_ALIVE);
		
	return HAM_IGNORED;
}

public fw_Damage(victim, inflictor, attacker, Float:damage, damage_type)
{
	if ((victim != attacker) && (damage > get_pcvar_num(cvar_damage)))
	{
		message_begin(MSG_ONE_UNRELIABLE, g_MsgScreenShake, _, victim)
		write_short( 1<<14 )
		write_short( 1<<14 )
		write_short( 1<<14 )
		message_end();

		message_begin(MSG_ONE_UNRELIABLE, g_MsgScreenFade, _, victim)
		write_short( 1<<10 )
		write_short( 1<<10 )
		write_short( 1<<12 )
		write_byte( 250 )
		write_byte( 0 )
		write_byte( 0 )
		write_byte( 125 )
		message_end()
	}
}
+ Can you make this for Normal/ZM/ZP? (in most cases the problem is the door I think)

Code: Select all

    #include <zombie_escape>
     
    new const szEntities[][] =
    {
        "func_train",
        "func_vehicle",
        "func_tracktrain",
        "func_door"
    }
     
    public plugin_init()
    {
        register_plugin("No Block", "1.0", "Raheem")
     
        for (new i = 0; i < charsmax(szEntities); i++)
        {
            RegisterHam(Ham_Blocked, szEntities[i], "Fw_Blocked_Post", 1)
        }
    }
     
    public Fw_Blocked_Post(iEnt, id)
    {
        if (is_user_alive(id) && pev_valid(iEnt))
        {
            new Float:flVelocity[3]
     
            velocity_by_aim(id, 550, flVelocity)
     
            flVelocity[0] += 20.0
            flVelocity[1] += 20.0
            flVelocity[2] += 20.0
     
            set_entvar(id, var_velocity, flVelocity)
        }
    }

+

Code: Select all

#include <zombie_escape>

new cvars_message_type

public plugin_init()
{
	
    register_plugin("[ZE] Break Message","1.2","Raheem")
    
	// Ham
    RegisterHam(Ham_TakeDamage, "func_breakable", "Fw_HamBreakableKilled_Post", 1)
	
	// Cvars
    cvars_message_type = register_cvar("ze_message_type", "1")
}

public Fw_HamBreakableKilled_Post(iEnt, iWeapon, iKiller)
{
    if(get_entvar(iEnt, var_health) < 0)
    {
		static szName[32]
		get_user_name(iKiller, szName, charsmax(szName))
		
		if(iKiller == 0)
			return HAM_IGNORED
		
		if (get_pcvar_num(cvars_message_type) == 1)
		{
			ze_colored_print(0,"!gPlayer !t%s !ghas broken Something!y!", szName)
		}
		else if (get_pcvar_num(cvars_message_type) == 2)
		{
			set_hudmessage(random(256), random(256), random(256), -1.0, 0.21, 0, 4.0, 4.0)
			show_hudmessage(0, "Player %s has broken Something!", szName)
		}
		else if (get_pcvar_num(cvars_message_type) == 3)
		{
			client_print(0, print_console, "Player %s has broken Something!", szName)
		}
    }
    return HAM_IGNORED
}
+

Code: Select all

#include <zombie_escape>

// Defines
#define AIMTASK 500

// Cvars
new cvar_message_type

public plugin_init()
{
	register_plugin("[ZE] Breakable Hint", "1.1", "Raheem")
	
	// Cvars
	cvar_message_type = register_cvar("ze_break_hint_type", "1")
	
	// Tasks
	set_task(0.5, "Check_AimTask", AIMTASK, _, _, "b")
}

public Check_AimTask()
{
	if (get_pcvar_num(cvar_message_type) == 0)
	{
		remove_task(AIMTASK, 0)
		return
	}
	
	for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
	{
		if (!is_user_alive(id))
			continue
		
		new iEntIndex, iBody
		get_user_aiming(id, iEntIndex, iBody)
		
		if(is_valid_ent(iEntIndex) && !is_user_connected(iEntIndex))
		{
			new szClassName[32]
			
			get_entvar(iEntIndex, var_classname, szClassName, charsmax(szClassName))
			
			if(equal(szClassName, "func_breakable"))
			{
				if (get_pcvar_num(cvar_message_type) == 1)
				{
					set_hudmessage(random(256), random(256), random(256), 0.1, -0.3, 2, 2.0, 2.0)
					show_hudmessage(id, "[Hint] You can break this Entity!")
				}
				else if (get_pcvar_num(cvar_message_type) == 2)
				{
					client_print(id, print_center, "[Hint] You can break this Entity!")
				}
			}
		}
	}
}
+ (For ZM/ZP)

Code: Select all

#include <zombie_escape>
 
new Thunder
 
public plugin_precache()
{
    Thunder = precache_model("sprites/lgtning.spr")
    precache_sound("ambience/thunder_clap.wav")
}
 
public plugin_init()
{
    register_plugin("[ZE] Thunder On Infect", "1.0", "LegendofWarior")
}
 
public ze_user_infected(iVictim, iAttacker)
{ 
    new vorigin[3], srco[3]
    get_user_origin(iVictim, vorigin)
 
    vorigin[2] -= 26
    srco[0] = vorigin[0] + 150
    srco[1] = vorigin[1] + 150
    srco[2] = vorigin[2] + 800
 
    ThunderCarabine(srco, vorigin)
    ThunderCarabine(srco, vorigin)
    ThunderCarabine(srco, vorigin)
 
    emit_sound(0 ,CHAN_ITEM, "ambience/thunder_clap.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}
 
ThunderCarabine(vec1[3], vec2[3])
{
    message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    write_byte(0)
    write_coord(vec1[0])
    write_coord(vec1[1])
    write_coord(vec1[2])
    write_coord(vec2[0])
    write_coord(vec2[1])
    write_coord(vec2[2])
    write_short(Thunder)
    write_byte(1)
    write_byte(5)
    write_byte(2)
    write_byte(20)
    write_byte(30)
    write_byte(200)
    write_byte(200)
    write_byte(200)
    write_byte(200)
    write_byte(200)
    message_end()
   
    message_begin(MSG_PVS, SVC_TEMPENTITY, vec2)
    write_byte(9)
    write_coord(vec2[0])
    write_coord(vec2[1])
    write_coord(vec2[2])
    message_end()
}
Wow everything is for ZE :(
Last edited by ArminC 6 years ago, edited 1 time in total.

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 6 years ago

Sad to tell you that here we only support Zombie Escape Mod. Personally i stopped supporting ZP long time ago. If needed i advice you to ask for ZP help in http://zppv.boards.net/ They only for ZP and we here for ZE.

One more thing i see you ask for optimizing using ReAPI so you know about code? So i can tell you what to change to optimize and you do, this is simpler for me so i don't waste much time.
He who fails to plan is planning to fail

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

#3

Post by ArminC » 6 years ago

Oh, I dont't actually know to code.. Just to edit some strings but nothing special.

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#4

Post by Night Fury » 6 years ago

ArminC wrote: 6 years ago Oh, I dont't actually know to code.. Just to edit some strings but nothing special.
Keep editing as you do & we will help you as long as you want. Request if you've any problem. That's how you will learn how to code.
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

#5

Post by ArminC » 6 years ago

Got it at STOP Blocking -

Code: Select all

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <reapi>

new const szEntities[][] =
{
    "func_train",
    "func_vehicle",
    "func_tracktrain",
    "func_door"
}
 
new Float:g_flLastBlock[33]
 
// Cvars
new g_pCvarBlockTime
 
public plugin_init()
{
    register_plugin("No Block", "1.0", "Raheem")
   
    // Cvars
    g_pCvarBlockTime = register_cvar("block_time", "1.5") // At how many seconds to take damage?
 
    for (new i = 0; i <= charsmax(szEntities); i++)
    {
        RegisterHam(Ham_Blocked, szEntities[i], "Fw_Blocked_Post", 1)
    }
}
 
public Fw_Blocked_Post(iEnt, id)
{
    new Float:flRefTime = get_gametime()
   
    if (is_user_alive(id) && pev_valid(iEnt))
    {
        if(g_flLastBlock[id] > flRefTime)
            return
       
        g_flLastBlock[id] = flRefTime + get_pcvar_float(g_pCvarBlockTime)
           
        ExecuteHamB(Ham_TakeDamage, id, iEnt, iEnt, 10.0, DMG_GENERIC) // How much damage(hp) to take?
 
        client_print(id, print_center, "STOP BLOCKING!")
    }
}
Got it at BREAK MESSAGE -

Code: Select all

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <reapi>

new cvars_message_type

public plugin_init()
{
	
    register_plugin("Break Message","1.2","Raheem")
    
	// Ham
    RegisterHam(Ham_TakeDamage, "func_breakable", "Fw_HamBreakableKilled_Post", 1)
	
	// Cvars
    cvars_message_type = register_cvar("message_type", "1")
}

public Fw_HamBreakableKilled_Post(iEnt, iWeapon, iKiller)
{
    if(get_entvar(iEnt, var_health) < 0)
    {
		static szName[32]
		get_user_name(iKiller, szName, charsmax(szName))
		
		if(iKiller == 0)
			return HAM_IGNORED
		
		if (get_pcvar_num(cvars_message_type) == 1)
		{
			client_print_color(0, print_team_default,"^1[^4ZPNM^1] ^3Player ^4%s ^3broke something^1.", szName)
		}
		else if (get_pcvar_num(cvars_message_type) == 2)
		{
			set_hudmessage(random(256), random(256), random(256), -1.0, 0.21, 0, 4.0, 4.0)
			show_hudmessage(0, "Player %s broke something!", szName)
		}
		else if (get_pcvar_num(cvars_message_type) == 3)
		{
			client_print(0, print_console, "Player %s broke something!", szName)
		}
    }
    return HAM_IGNORED
}
Got it at BREAKABLE HINT

Code: Select all

#include <amxmodx>
#include <engine>
#include <reapi>

// Defines
#define AIMTASK 500

// Cvars
new cvar_message_type

public plugin_init()
{
	register_plugin("Breakable Hint", "1.1", "Raheem")
	
	// Cvars
	cvar_message_type = register_cvar("break_hint_type", "1")
	
	// Tasks
	set_task(0.5, "Check_AimTask", AIMTASK, _, _, "b")
}

public Check_AimTask()
{
	if (get_pcvar_num(cvar_message_type) == 0)
	{
		remove_task(AIMTASK, 0)
		return
	}
	
	for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
	{
		if (!is_user_alive(id))
			continue
		
		new iEntIndex, iBody
		get_user_aiming(id, iEntIndex, iBody)
		
		if(is_valid_ent(iEntIndex) && !is_user_connected(iEntIndex))
		{
			new szClassName[32]
			
			get_entvar(iEntIndex, var_classname, szClassName, charsmax(szClassName))
			
			if(equal(szClassName, "func_breakable"))
			{
				if (get_pcvar_num(cvar_message_type) == 1)
				{
					set_hudmessage(random(256), random(256), random(256), 0.1, -0.3, 2, 2.0, 2.0)
					show_hudmessage(id, "You can break this entity!")
				}
				else if (get_pcvar_num(cvar_message_type) == 2)
				{
					client_print(id, print_center, "You can break this entity!")
				}
			}
		}
	}
}

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#6

Post by Night Fury » 6 years ago

You forgot to add your problem.
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

User avatar
ArminC
Senior Member
Senior Member
Romania
Posts: 137
Joined: 6 years ago
Location: Bucharest
Contact:

#7

Post by ArminC » 6 years ago

No I don't forgot it. The problem is in the topic. I did want you to convert me to Normal from ZE you said that you support ZE + sometimes normal but this to contact anyone of you trough a chat platform.. or to ask ZPPV... here as usual no one want to help me.. and I decied to try by myself and it work'd :D And I did post Normal version of that plugins for whoever want it..

PS: I ask every problem of mine here because on other forums I don't get 20% of help (in a month) that I get here in a day, *lol* :lol:

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#8

Post by Raheem » 6 years ago

ArminC wrote: 6 years ago No I don't forgot it. The problem is in the topic. I did want you to convert me to Normal from ZE you said that you support ZE + sometimes normal but this to contact anyone of you trough a chat platform.. or to ask ZPPV... here as usual no one want to help me.. and I decide to try by myself and it work'd :D And I did post Normal version of that plugins for whoever want it..
OK, Thanks you convert them to normal Mods, Will be great if you post this code as comment in every plugin thread so if someone search there he find it simply.
ArminC wrote: 6 years ago PS: I ask every problem of mine here because on other forums I don't get 20% of help (in a month) that I get here in a day, *lol* :lol:
Maybe because i have free time these days? :lol: By anyway my studies will back in 2/2 at this time expect low help because of low time free.
He who fails to plan is planning to fail

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 0 guests