ZP zclass Lusty Rose invisible play sound just once

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Заключена
Потребителски аватар

Автор на темата
truex_88
Foreigner
Foreigner
Мнения: 27
Регистриран: 18 мар 2019, 18:33
Се отблагодари: 8 пъти

ZP zclass Lusty Rose invisible play sound just once

Мнение от truex_88 » 26 мар 2019, 15:22

I would like to ask for your help in one thing.
Invisible sound just play the sound once. Currently playing continuously during invisible_time.



new const zombie_sound_invisible[] = "zombieplague/idle2.wav"

SMA:

Код: Избери всички

#include <amxmodx>
#include <engine> 
#include <fakemeta>
#include <fun>
#include <zombieplague>

#define PLUGIN "CSO Lusty Rose"
#define VERSION "1.0.1"
#define AUTHOR "ALBTeam"

new const zclass_name[] = "Light"
new const zclass_info[] = "Stealth"
new const zclass_model[] = "cosspeed1_origin"
new const zclass_clawmodel[] = "v_knife_cosspeed1.mdl"
new const zclass_clawmodel_invi[] = "models/zombie_plague/v_knife_cosspeed1_inv.mdl"
const zclass_health = 750
const zclass_speed = 295
const Float:zclass_gravity = 0.7
const Float:zclass_knockback = 6.0

new const zombie_sound_invisible[] = "zombieplague/idle2.wav"

new idclass
const Float:invisible_time = 20.0
const Float:invisible_timewait = 8.0
const invisible_dmg = 150
const Float:invisible_speed = 210.0
const Float:invisible_gravity = 1.0
const invisible_alpha = 10

new g_invisible[33], g_invisible_wait[33]

new g_msgSayText
new g_maxplayers
new g_roundend

enum (+= 100)
{
	TASK_INVISIBLE = 2000,
	TASK_WAIT_INVISIBLE,
	TASK_INVISIBLE_SOUND,
	TASK_BOT_USE_SKILL
}

#define ID_INVISIBLE (taskid - TASK_INVISIBLE)
#define ID_WAIT_INVISIBLE (taskid - TASK_WAIT_INVISIBLE)
#define ID_INVISIBLE_SOUND (taskid - TASK_INVISIBLE_SOUND)
#define ID_BOT_USE_SKILL (taskid - TASK_BOT_USE_SKILL)

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
	register_event("DeathMsg", "Death", "a")
	register_event("CurWeapon", "EventCurWeapon", "be", "1=1")
	register_logevent("logevent_round_end", 2, "1=Round_End")
	
	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
	
	register_clcmd("drop", "cmd_invisible")
	
	g_msgSayText = get_user_msgid("SayText")
	g_maxplayers = get_maxplayers()
}

public plugin_precache()
{
	precache_model(zclass_clawmodel_invi)
	precache_sound(zombie_sound_invisible)
	
	idclass = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
}

public client_putinserver(id)
{
	reset_value_player(id)
}

public client_disconnected(id)
{
	reset_value_player(id)
}

public event_round_start()
{
	g_roundend = 0
	
	for (new id=1; id<=g_maxplayers; id++)
	{
		if (!is_user_connected(id)) continue;
		
		reset_value_player(id)
	}
}

public logevent_round_end()
{
	g_roundend = 1
}

public Death()
{
	new victim = read_data(2) 
	reset_value_player(victim)
}

public EventCurWeapon(id)
{
	if(!is_user_alive(id)) return PLUGIN_CONTINUE;
	
	if(g_invisible[id]) set_user_maxspeed(id, invisible_speed);
	
	return PLUGIN_CONTINUE;
}

public zp_user_infected_post(id)
{
	reset_value_player(id)
	
	if(zp_get_user_nemesis(id)) return;
	
	if(zp_get_user_zombie_class(id) == idclass)
	{
		if(is_user_bot(id))
		{
			set_task(random_float(5.0,15.0), "bot_use_skill", id+TASK_BOT_USE_SKILL)
			return
		}
		
		zp_colored_print(id, "^x04[ZP]^x01 Your skill is^x04 Stealth^x01. Cooldown^x04 %.1f ^x01seconds.", invisible_timewait)
	}
}

public zp_user_humanized_post(id)
{
	reset_value_player(id)
}

public zp_user_unfrozen(id)
{
	if(g_invisible[id])
	{
		set_user_rendering(id,kRenderFxGlowShell,20,20,20,kRenderTransAlpha, invisible_alpha)
		set_user_maxspeed(id, invisible_speed)
		set_user_gravity(id, invisible_gravity)
	}
}

public fw_PlayerPreThink(id) 
{ 
	new button = get_user_button(id) 
	new oldbutton = get_user_oldbutton(id) 
	
	if (zp_get_user_zombie(id) && (zp_get_user_zombie_class(id) == idclass)) 
	{ 
		if (!(oldbutton & IN_USE) && (button & IN_USE)) 
		{ 
			cmd_invisible(id) 
		} 
	} 
} 

public cmd_invisible(id)
{
	if (g_roundend) return PLUGIN_CONTINUE
	
	if (!is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id)) return PLUGIN_CONTINUE

	new health = get_user_health(id) - invisible_dmg
	if (zp_get_user_zombie_class(id) == idclass && health>0 && !g_invisible[id] && !g_invisible_wait[id])
	{
		g_invisible[id] = 1
		
		set_wpnmodel(id)
		set_user_health(id, health)
		set_user_rendering(id,kRenderFxGlowShell,20,20,20,kRenderTransAlpha, invisible_alpha)
		set_user_footsteps(id, 1)
		set_user_maxspeed(id, invisible_speed)
		set_user_gravity(id, invisible_gravity)
		PlayEmitSound(id, zombie_sound_invisible)
		
		set_task(invisible_time, "RemoveInvisible", id+TASK_INVISIBLE)
		set_task(2.0, "InvisibleSound", id+TASK_INVISIBLE_SOUND, _, _, "b")

		zp_colored_print(id, "^x04[ZP]^x01 You will^x04 Stealth^x01 for^x04 %.1f ^x01seconds.", invisible_time)
		
		return PLUGIN_HANDLED
	}
	
	return PLUGIN_CONTINUE
}

public bot_use_skill(taskid)
{
	new id = ID_BOT_USE_SKILL
	
	if (!is_user_alive(id)) return;

	cmd_invisible(id)
	
	set_task(random_float(5.0,15.0), "bot_use_skill", id+TASK_BOT_USE_SKILL)
}

public InvisibleSound(taskid)
{
	new id = ID_INVISIBLE_SOUND
	
	if (g_invisible[id]) PlayEmitSound(id, zombie_sound_invisible)
	else remove_task(taskid)
}

public RemoveInvisible(taskid)
{
	new id = ID_INVISIBLE
	
	g_invisible[id] = 0
	
	set_wpnmodel(id)
	set_user_rendering(id)
	set_user_footsteps(id, 0)
	set_user_maxspeed(id, float(zclass_speed))
	set_user_gravity(id, zclass_gravity)
	zp_colored_print(id, "^x04[ZP]^x01 Your^x04 Stealth^x01 skill is over.")
	
	g_invisible_wait[id] = 1
	
	set_task(invisible_timewait, "RemoveWaitInvisible", id+TASK_WAIT_INVISIBLE)
}

public RemoveWaitInvisible(taskid)
{
	new id = ID_WAIT_INVISIBLE
	
	g_invisible_wait[id] = 0
	
	zp_colored_print(id, "^x04[ZP]^x01 Your skill^x04 Stealth^x01 is ready.")
}

set_wpnmodel(id)
{
	if (!is_user_alive(id)) return;
	
	if (get_user_weapon(id) == CSW_KNIFE)
	{
		if (g_invisible[id])
		{
			set_pev(id, pev_viewmodel2, zclass_clawmodel_invi)
		}
		else
		{
			static temp[100]
			format(temp, charsmax(temp), "models/zombie_plague/%s", zclass_clawmodel)
			set_pev(id, pev_viewmodel2, temp)
		}
	}	
}

PlayEmitSound(id, const sound[])
{
	emit_sound(id, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
}

reset_value_player(id)
{
	g_invisible[id] = 0
	g_invisible_wait[id] = 0
	
	remove_task(id+TASK_INVISIBLE)
	remove_task(id+TASK_WAIT_INVISIBLE)
	remove_task(id+TASK_BOT_USE_SKILL)
}

zp_colored_print(target, const message[], any:...)
{
	static buffer[512], i, argscount
	argscount = numargs()
	
	if (!target)
	{
		static player
		for (player = 1; player <= g_maxplayers; player++)
		{
			if (!is_user_connected(player))
				continue;
			
			static changed[5], changedcount
			changedcount = 0
			
			for (i = 2; i < argscount; i++)
			{
				if (getarg(i) == LANG_PLAYER)
				{
					setarg(i, 0, player)
					changed[changedcount] = i
					changedcount++
				}
			}
			
			vformat(buffer, charsmax(buffer), message, 3)
			
			message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player)
			write_byte(player)
			write_string(buffer)
			message_end()
			
			for (i = 0; i < changedcount; i++)
				setarg(changed[i], 0, LANG_PLAYER)
		}
	}
	else
	{
		vformat(buffer, charsmax(buffer), message, 3)
		
		message_begin(MSG_ONE, g_msgSayText, _, target)
		write_byte(target)
		write_string(buffer)
		message_end()
	}
}

Потребителски аватар

<VeCo>
AMXX Скриптър
AMXX Скриптър
Мнения: 98
Регистриран: 28 яну 2019, 19:01
Се отблагодари: 3 пъти
Получена благодарност: 34 пъти

ZP zclass Lusty Rose

Мнение от <VeCo> » 26 мар 2019, 19:46

Код: Избери всички

#include <amxmodx>
#include <engine> 
#include <fakemeta>
#include <fun>
#include <zombieplague>

#define PLUGIN "CSO Lusty Rose"
#define VERSION "1.0.1"
#define AUTHOR "ALBTeam"

new const zclass_name[] = "Light"
new const zclass_info[] = "Stealth"
new const zclass_model[] = "cosspeed1_origin"
new const zclass_clawmodel[] = "v_knife_cosspeed1.mdl"
new const zclass_clawmodel_invi[] = "models/zombie_plague/v_knife_cosspeed1_inv.mdl"
const zclass_health = 750
const zclass_speed = 295
const Float:zclass_gravity = 0.7
const Float:zclass_knockback = 6.0

new const zombie_sound_invisible[] = "zombieplague/idle2.wav"

new idclass
const Float:invisible_time = 20.0
const Float:invisible_timewait = 8.0
const invisible_dmg = 150
const Float:invisible_speed = 210.0
const Float:invisible_gravity = 1.0
const invisible_alpha = 10

new g_invisible[33], g_invisible_wait[33]

new g_msgSayText
new g_maxplayers
new g_roundend

enum (+= 100)
{
	TASK_INVISIBLE = 2000,
	TASK_WAIT_INVISIBLE,
	TASK_INVISIBLE_SOUND,
	TASK_BOT_USE_SKILL
}

#define ID_INVISIBLE (taskid - TASK_INVISIBLE)
#define ID_WAIT_INVISIBLE (taskid - TASK_WAIT_INVISIBLE)
#define ID_INVISIBLE_SOUND (taskid - TASK_INVISIBLE_SOUND)
#define ID_BOT_USE_SKILL (taskid - TASK_BOT_USE_SKILL)

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
	register_event("DeathMsg", "Death", "a")
	register_event("CurWeapon", "EventCurWeapon", "be", "1=1")
	register_logevent("logevent_round_end", 2, "1=Round_End")
	
	register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
	
	register_clcmd("drop", "cmd_invisible")
	
	g_msgSayText = get_user_msgid("SayText")
	g_maxplayers = get_maxplayers()
}

public plugin_precache()
{
	precache_model(zclass_clawmodel_invi)
	precache_sound(zombie_sound_invisible)
	
	idclass = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
}

public client_putinserver(id)
{
	reset_value_player(id)
}

public client_disconnected(id)
{
	reset_value_player(id)
}

public event_round_start()
{
	g_roundend = 0
	
	for (new id=1; id<=g_maxplayers; id++)
	{
		if (!is_user_connected(id)) continue;
		
		reset_value_player(id)
	}
}

public logevent_round_end()
{
	g_roundend = 1
}

public Death()
{
	new victim = read_data(2) 
	reset_value_player(victim)
}

public EventCurWeapon(id)
{
	if(!is_user_alive(id)) return PLUGIN_CONTINUE;
	
	if(g_invisible[id]) set_user_maxspeed(id, invisible_speed);
	
	return PLUGIN_CONTINUE;
}

public zp_user_infected_post(id)
{
	reset_value_player(id)
	
	if(zp_get_user_nemesis(id)) return;
	
	if(zp_get_user_zombie_class(id) == idclass)
	{
		if(is_user_bot(id))
		{
			set_task(random_float(5.0,15.0), "bot_use_skill", id+TASK_BOT_USE_SKILL)
			return
		}
		
		zp_colored_print(id, "^x04[ZP]^x01 Your skill is^x04 Stealth^x01. Cooldown^x04 %.1f ^x01seconds.", invisible_timewait)
	}
}

public zp_user_humanized_post(id)
{
	reset_value_player(id)
}

public zp_user_unfrozen(id)
{
	if(g_invisible[id])
	{
		set_user_rendering(id,kRenderFxGlowShell,20,20,20,kRenderTransAlpha, invisible_alpha)
		set_user_maxspeed(id, invisible_speed)
		set_user_gravity(id, invisible_gravity)
	}
}

public fw_PlayerPreThink(id) 
{ 
	new button = get_user_button(id) 
	new oldbutton = get_user_oldbutton(id) 
	
	if (zp_get_user_zombie(id) && (zp_get_user_zombie_class(id) == idclass)) 
	{ 
		if (!(oldbutton & IN_USE) && (button & IN_USE)) 
		{ 
			cmd_invisible(id) 
		} 
	} 
} 

public cmd_invisible(id)
{
	if (g_roundend) return PLUGIN_CONTINUE
	
	if (!is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id)) return PLUGIN_CONTINUE

	new health = get_user_health(id) - invisible_dmg
	if (zp_get_user_zombie_class(id) == idclass && health>0 && !g_invisible[id] && !g_invisible_wait[id])
	{
		g_invisible[id] = 1
		
		set_wpnmodel(id)
		set_user_health(id, health)
		set_user_rendering(id,kRenderFxGlowShell,20,20,20,kRenderTransAlpha, invisible_alpha)
		set_user_footsteps(id, 1)
		set_user_maxspeed(id, invisible_speed)
		set_user_gravity(id, invisible_gravity)
		PlayEmitSound(id, zombie_sound_invisible)
		
		set_task(invisible_time, "RemoveInvisible", id+TASK_INVISIBLE)

		zp_colored_print(id, "^x04[ZP]^x01 You will^x04 Stealth^x01 for^x04 %.1f ^x01seconds.", invisible_time)
		
		return PLUGIN_HANDLED
	}
	
	return PLUGIN_CONTINUE
}

public bot_use_skill(taskid)
{
	new id = ID_BOT_USE_SKILL
	
	if (!is_user_alive(id)) return;

	cmd_invisible(id)
	
	set_task(random_float(5.0,15.0), "bot_use_skill", id+TASK_BOT_USE_SKILL)
}

public RemoveInvisible(taskid)
{
	new id = ID_INVISIBLE
	
	g_invisible[id] = 0
	
	set_wpnmodel(id)
	set_user_rendering(id)
	set_user_footsteps(id, 0)
	set_user_maxspeed(id, float(zclass_speed))
	set_user_gravity(id, zclass_gravity)
	zp_colored_print(id, "^x04[ZP]^x01 Your^x04 Stealth^x01 skill is over.")
	
	g_invisible_wait[id] = 1
	
	set_task(invisible_timewait, "RemoveWaitInvisible", id+TASK_WAIT_INVISIBLE)
}

public RemoveWaitInvisible(taskid)
{
	new id = ID_WAIT_INVISIBLE
	
	g_invisible_wait[id] = 0
	
	zp_colored_print(id, "^x04[ZP]^x01 Your skill^x04 Stealth^x01 is ready.")
}

set_wpnmodel(id)
{
	if (!is_user_alive(id)) return;
	
	if (get_user_weapon(id) == CSW_KNIFE)
	{
		if (g_invisible[id])
		{
			set_pev(id, pev_viewmodel2, zclass_clawmodel_invi)
		}
		else
		{
			static temp[100]
			format(temp, charsmax(temp), "models/zombie_plague/%s", zclass_clawmodel)
			set_pev(id, pev_viewmodel2, temp)
		}
	}	
}

PlayEmitSound(id, const sound[])
{
	emit_sound(id, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
}

reset_value_player(id)
{
	g_invisible[id] = 0
	g_invisible_wait[id] = 0
	
	remove_task(id+TASK_INVISIBLE)
	remove_task(id+TASK_WAIT_INVISIBLE)
	remove_task(id+TASK_BOT_USE_SKILL)
}

zp_colored_print(target, const message[], any:...)
{
	static buffer[512], i, argscount
	argscount = numargs()
	
	if (!target)
	{
		static player
		for (player = 1; player <= g_maxplayers; player++)
		{
			if (!is_user_connected(player))
				continue;
			
			static changed[5], changedcount
			changedcount = 0
			
			for (i = 2; i < argscount; i++)
			{
				if (getarg(i) == LANG_PLAYER)
				{
					setarg(i, 0, player)
					changed[changedcount] = i
					changedcount++
				}
			}
			
			vformat(buffer, charsmax(buffer), message, 3)
			
			message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player)
			write_byte(player)
			write_string(buffer)
			message_end()
			
			for (i = 0; i < changedcount; i++)
				setarg(changed[i], 0, LANG_PLAYER)
		}
	}
	else
	{
		vformat(buffer, charsmax(buffer), message, 3)
		
		message_begin(MSG_ONE, g_msgSayText, _, target)
		write_byte(target)
		write_string(buffer)
		message_end()
	}
}
:pepo_think3:

Потребителски аватар

Автор на темата
truex_88
Foreigner
Foreigner
Мнения: 27
Регистриран: 18 мар 2019, 18:33
Се отблагодари: 8 пъти

ZP zclass Lusty Rose

Мнение от truex_88 » 26 мар 2019, 20:13

it works! thank you!

Потребителски аватар

OciXCrom TM
Администратор
Администратор
Мнения: 5110
Регистриран: 06 окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 59 пъти
Получена благодарност: 491 пъти
Години: 21
Контакти:

ZP zclass Lusty Rose invisible sound plays just once

Мнение от OciXCrom TM » 27 мар 2019, 14:40

Please use more descriptive titles in the future. Make sure to provide a short description of the problem (not only the plugin) in the title itself. I fixed it for you - use it as an example.

Заключена

Върни се в “Заявки за плъгини”

Кой е на линия

Потребители, разглеждащи този форум: Няма регистрирани потребители и 1 гост