I create nemesis plugin but not work [Help]

Coding Help/Re-API Supported
karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#41

Post by karan » 4 years ago

Mohamed Alaa wrote: 4 years ago Updated:
1- Added ambience.
2- Bug fixes.
3- Added countdown.
4- Added "ze_nemesis" command to set a specific player a nemesis.

Code:

Code: Select all

#include <zombie_escape>

// Uncomment to use custom model for nemesis
// Note: This includes player model & claws
//#define USE_NEMESIS_MODEL

// Uncomment to use leap for nemesis
// Leap Code: https://escapers-zone.net/viewtopic.php?p=10582#p10582
//#define USE_NEMESIS_LEAP

#define TASK_MAKE_NEMESIS 4949849
#define TASK_AMBIENCESOUND 2020
#define TASK_REAMBIENCESOUND 5050

// Access to start nemesis round
#define STARTNEMESIS_ACCESS ADMIN_LEVEL_H

// Settings file
new const ZE_SETTING_FILE[] = "zombie_escape.ini"

#if defined USE_NEMESIS_MODEL
// Default models
new const g_szModels_Nemesis_Player[][] = { "ze_nemesis_host" }
new const g_szModels_Nemesis_Claws[][] = { "models/zombie_escape/v_knife_nemesis.mdl" }

new Array:g_aModels_Nemesis_Player,
	Array:g_aModels_Nemesis_Claws
#endif

#if defined USE_NEMESIS_LEAP
native ze_get_longjump(id)
native ze_remove_longjump(id)
#endif

enum _:Colors
{
	Red = 0,
	Green,
	Blue
}

new g_iAmbianceSoundDuration = 160	// Set ambience duration = highest sound duration
new const szAmbianceSound[][] = 
{
	"zombie_escape/ze_ambiance1.mp3"
}

new bool:g_bIsNemesis[33],
	bool:g_bIsNextRoundNemesis = false,
	g_iCountDown,
	Array:g_szAmbianceSound

new g_pCvarNemesisHP,
	g_pCvarNemesisGravity,
	g_pCvarNemesisSpeed,
	g_pCvarNemesisGlow,
	g_pCvarNemesisGlowColor[Colors],
	g_pCvarNemesisKB,
	g_pCvarNemesisDmg,
	g_pCvarNemesisFreeze,
	g_pCvarNemesisFire

public plugin_natives()
{
	register_native("ze_is_user_nemesis", "native_ze_is_user_nemesis", 1)
	register_native("ze_set_user_nemesis", "native_ze_set_user_nemesis", 1)
}

public plugin_precache()
{
	g_szAmbianceSound = ArrayCreate(64, 1)
	amx_load_setting_string_arr(ZE_SETTING_FILE, "Sounds", "Nemesis Round Ambiance", g_szAmbianceSound)

	new iIndex, szSound[64]
	if (ArraySize(g_szAmbianceSound) == 0)
	{
		for (iIndex = 0; iIndex < sizeof szAmbianceSound; iIndex++)
			ArrayPushString(g_szAmbianceSound, szAmbianceSound[iIndex])
		
		// Save to external file
		amx_save_setting_string_arr(ZE_SETTING_FILE, "Sounds", "Nemesis Round Ambiance", g_szAmbianceSound)
	}

	for (iIndex = 0; iIndex < ArraySize(g_szAmbianceSound); iIndex++)
	{
		ArrayGetString(g_szAmbianceSound, iIndex, szSound, charsmax(szSound))
		
		if (equal(szSound[strlen(szSound)-4], ".mp3"))
		{
			format(szSound, charsmax(szSound), "sound/%s", szSound)
			precache_generic(szSound)
		}
		else
		{
			precache_sound(szSound)
		}
	}

	#if defined USE_NEMESIS_MODEL
		// Initialize arrays
		g_aModels_Nemesis_Player = ArrayCreate(32, 1)
		g_aModels_Nemesis_Claws = ArrayCreate(64, 1)
		
		// Load from external file
		amx_load_setting_string_arr(ZE_SETTING_FILE, "Player Models", "NEMESIS MODEL", g_aModels_Nemesis_Player)
		amx_load_setting_string_arr(ZE_SETTING_FILE, "Weapon Models", "V_KNIFE NEMESIS", g_aModels_Nemesis_Claws)
		
		// If we couldn't load from file, use and save default ones
		if (ArraySize(g_aModels_Nemesis_Player) == 0)
		{
			for (iIndex = 0; iIndex < sizeof g_szModels_Nemesis_Player; iIndex++)
				ArrayPushString(g_aModels_Nemesis_Player, g_szModels_Nemesis_Player[iIndex])
			
			// Save to external file
			amx_save_setting_string_arr(ZE_SETTING_FILE, "Player Models", "NEMESIS", g_aModels_Nemesis_Player)
		}

		if (ArraySize(g_aModels_Nemesis_Claws) == 0)
		{
			for (iIndex = 0; iIndex < sizeof g_szModels_Nemesis_Claws; iIndex++)
				ArrayPushString(g_aModels_Nemesis_Claws, g_szModels_Nemesis_Claws[iIndex])
			
			// Save to external file
			amx_save_setting_string_arr(ZE_SETTING_FILE, "Weapon Models", "V_KNIFE NEMESIS", g_aModels_Nemesis_Claws)
		}
		
		// Precache models
		new player_model[32], model[64], model_path[128]

		for (iIndex = 0; iIndex < ArraySize(g_aModels_Nemesis_Player); iIndex++)
		{
			ArrayGetString(g_aModels_Nemesis_Player, iIndex, player_model, charsmax(player_model))
			formatex(model_path, charsmax(model_path), "models/player/%s/%s.mdl", player_model, player_model)
			precache_model(model_path)
			// Support modelT.mdl files
			formatex(model_path, charsmax(model_path), "models/player/%s/%sT.mdl", player_model, player_model)
			if (file_exists(model_path)) precache_model(model_path)
		}

		for (iIndex = 0; iIndex < ArraySize(g_aModels_Nemesis_Claws); iIndex++)
		{
			ArrayGetString(g_aModels_Nemesis_Claws, iIndex, model, charsmax(model))
			precache_model(model)
		}
	#endif
}

public plugin_init()
{
	register_plugin("[ZE] Addons: Nemesis", "2.0", "Jack")

	RegisterHam(Ham_TakeDamage, "player", "Fw_TakeDamage")

	register_clcmd("ze_start_nemesis_next", "cmd_start_nemesis", STARTNEMESIS_ACCESS)
	register_concmd("ze_nemesis", "cmd_nemsis", STARTNEMESIS_ACCESS)

	g_pCvarNemesisHP = register_cvar("ze_nemesis_hp", "20000")	// Nemesis health - Set 0 to use zombie HP
	g_pCvarNemesisGravity = register_cvar("ze_nemesis_gravity", "600")	// Nemesis gravity - Set 0 to use zombie gravity
	g_pCvarNemesisSpeed = register_cvar("ze_nemesis_speed", "300")	// Nemesis speed - Set 0 to use zombie speed
	g_pCvarNemesisGlow = register_cvar("ze_nemesis_glow", "1")	// Nemesis glow - 1 = enable | 0 = disable
	g_pCvarNemesisGlowColor[Red] = register_cvar("ze_nemesis_glow_r", "255")	// Nemesis glow color RED
	g_pCvarNemesisGlowColor[Green] = register_cvar("ze_nemesis_glow_g", "255")	// Nemesis glow color GREEN
	g_pCvarNemesisGlowColor[Blue] = register_cvar("ze_nemesis_glow_b", "255")	// Nemesis glow color BLUE
	g_pCvarNemesisKB = register_cvar("ze_nemesis_kb", "200.0")	// Nemesis knockback - Set 0 to use zombie knockback
	g_pCvarNemesisDmg = register_cvar("ze_nemesis_dmg", "200.0")	// Nemesis damage
	g_pCvarNemesisFreeze = register_cvar("ze_nemesis_freeze", "0")	// Nemesis get frozen? - 1 = doesn't get frozen | 0 = gets frozen
	g_pCvarNemesisFire = register_cvar("ze_nemesis_fire", "1")	// Nemesis set on fire? - 1 = doesn't set on fire | 0 = set on fire
}

public client_disconnected(id)
{
	if (g_bIsNemesis[id])
	{
		new szPlayerName[2][32], iNewNemId
		get_user_name(id, szPlayerName[0], charsmax(szPlayerName))
		iNewNemId = GetRandomNemesis()
		get_user_name(iNewNemId, szPlayerName[1], charsmax(szPlayerName))
		g_bIsNemesis[id] = false
		Set_Nemesis(iNewNemId)
		ze_colored_print(0, "!g%s !thas left !n& !g%s !thas become nemesis!n.", szPlayerName[0], szPlayerName[1])
	}
}

public client_putinserver(id)
{
	if (g_bIsNemesis[id])
		g_bIsNemesis[id] = false
}

public ze_user_infected_pre(iVictim, iAttacker)
{
	if (g_bIsNemesis[iAttacker] && !ze_is_user_zombie(iVictim))
	{
		SendDeathMsg(iAttacker, iVictim)
		return 1
	}

	return 0
}

public Fw_TakeDamage(iVictim, iInfector, iAttacker, Float:iDamage)
{
	if (iVictim == iAttacker || !is_user_alive(iAttacker))
		return HAM_IGNORED

	if (g_bIsNemesis[iAttacker] && !ze_is_user_zombie(iVictim) && iInfector == iAttacker)
	{
		SetHamParamFloat(4, iDamage * get_pcvar_float(g_pCvarNemesisDmg))
		return HAM_HANDLED
	}

	return HAM_IGNORED
}

public ze_fire_pre(id)
{
	if (g_bIsNemesis[id] && get_pcvar_num(g_pCvarNemesisFire))
		return PLUGIN_HANDLED
	return PLUGIN_CONTINUE
}

public ze_frost_pre(id)
{
	if (g_bIsNemesis[id] && get_pcvar_num(g_pCvarNemesisFreeze))
		return PLUGIN_HANDLED
	return PLUGIN_CONTINUE
}

public ze_user_humanized(id)
{
	UnSet_Nemesis(id)
}

public ze_roundend()
{
	remove_task(TASK_AMBIENCESOUND)
	remove_task(TASK_REAMBIENCESOUND)
	remove_task(TASK_MAKE_NEMESIS)
	
	for (new id = 0; id <= get_member_game(m_nMaxPlayers); id++)
	{
		if (is_user_alive(id) && g_bIsNemesis[id])
			UnSet_Nemesis(id)
	}
}

public ze_game_started_pre()
{
	if (get_playersnum())
	{
		if (g_bIsNextRoundNemesis)
		{
			g_bIsNextRoundNemesis = false
			g_iCountDown = 5
			set_task(1.0, "StartNemesis", TASK_MAKE_NEMESIS, _, _, "b")
			set_task(3.0, "AmbianceSound", TASK_AMBIENCESOUND)
			return PLUGIN_HANDLED
		}
	}
	else
	{
		g_bIsNextRoundNemesis = false
		ze_colored_print(0, "!gThe server doesn't have enough players to start nemesis round !n(!tat least 1!n)!n.")
	}

	return PLUGIN_CONTINUE
}

public AmbianceSound()
{
	// Stop All Sounds
	StopSound()
	
	// Play The Ambiance Sound For All Players
	new szSound[64]
	ArrayGetString(g_szAmbianceSound, random_num(0, ArraySize(g_szAmbianceSound) - 1), szSound, charsmax(szSound))
	
	for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
	{
		if (!is_user_connected(id))
			continue

		PlaySound(id, szSound)
	}

	// We should Set Task back again to replay (Repeated 5 times MAX)
	set_task(float(g_iAmbianceSoundDuration), "AmbianceSound", TASK_REAMBIENCESOUND, _, _, "a", 5)
}

public StartNemesis(taskid)
{
	if (!g_iCountDown)
	{
		Set_Nemesis(GetRandomNemesis())
		remove_task(taskid)
		return
	}

	set_hudmessage(random(256), random(256), random(256), -1.0, 0.21, 0, 0.8, 0.8)
	show_hudmessage(0, "Nemesis starts in %d second(s).", g_iCountDown--)
}

public cmd_start_nemesis(id, level, cid)
{
	if (!cmd_access(id, STARTNEMESIS_ACCESS, cid, 0))
	{
		client_print(id, print_console, "You have not access.")
		return PLUGIN_HANDLED
	}
	
	g_bIsNextRoundNemesis = true
	client_print(id, print_console, "Nemesis round will start next round.")
	return PLUGIN_HANDLED
}

public cmd_nemsis(id, level, cid)
{
	if (!cmd_access(id, STARTNEMESIS_ACCESS, cid, 0))
	{
		client_print(id, print_console, "You have not access.")
		return PLUGIN_HANDLED
	}
	
	// Retrieve arguments
	new arg[32], player
	read_argv(1, arg, charsmax(arg))
	player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
	
	// Invalid target
	if (!player || !is_user_alive(player))
	{
		ze_colored_print(id, "Invalid player.")
		return PLUGIN_HANDLED
	}
	
	// Target not allowed to be nemesis
	if (g_bIsNemesis[player])
	{
		new player_name[32]
		get_user_name(player, player_name, charsmax(player_name))
		client_print(id, print_console, "[ZE] %s is already nemesis.", player_name)
		return PLUGIN_HANDLED
	}
	
	Set_Nemesis(player)
	return PLUGIN_HANDLED
}

public Set_Nemesis(id)
{
	g_bIsNemesis[id] = true

	if (!ze_is_user_zombie(id))
		ze_set_user_zombie(id)

	#if defined USE_NEMESIS_LEAP
		ze_get_longjump(id)
	#endif

	#if defined USE_NEMESIS_MODEL
		new szPlayerModel[32], szModel[64]
		ArrayGetString(g_aModels_Nemesis_Player, random_num(0, ArraySize(g_aModels_Nemesis_Player) - 1), szPlayerModel, charsmax(szPlayerModel))
		cs_set_user_model(id, szPlayerModel)

		ArrayGetString(g_aModels_Nemesis_Claws, random_num(0, ArraySize(g_aModels_Nemesis_Claws) - 1), szModel, charsmax(szModel))
		cs_set_player_view_model(id, CSW_KNIFE, szModel)
	#endif
	
	if (get_pcvar_num(g_pCvarNemesisHP))
	{
		set_entvar(id, var_health, get_pcvar_float(g_pCvarNemesisHP))
	}

	if (get_pcvar_num(g_pCvarNemesisSpeed))
	{
		ze_set_zombie_speed(id, get_pcvar_num(g_pCvarNemesisSpeed))
	}

	if (get_pcvar_num(g_pCvarNemesisGravity))
	{
		ze_set_user_gravity(id, get_pcvar_num(g_pCvarNemesisGravity))
	}

	if (get_pcvar_num(g_pCvarNemesisKB))
	{
		ze_set_user_knockback(id, get_pcvar_float(g_pCvarNemesisKB))
	}

	if (get_pcvar_num(g_pCvarNemesisGlow))
	{
		Set_Rendering(id, kRenderFxNone, 255, 0, 0, kRenderNormal, 15)
	}

	new szName[32]
	get_user_name(id, szName, charsmax(szName))
	set_hudmessage(255, 0, 0, -1.0, 0.21, 0, 0.0, 5.0, 0.1, 1.5)
	show_hudmessage(id, "%s became Nemesis", szName)
	ze_colored_print(0, "!g%s !tbecame !gNemesis!n.", szName)
	ze_colored_print(id, "!gYou !tbecame !gNemesis!n.")
}

public UnSet_Nemesis(id)
{
	if (!g_bIsNemesis[id] || !is_user_alive(id))
		return

	g_bIsNemesis[id] = false

	#if defined USE_NEMESIS_LEAP
		ze_remove_longjump(id)
	#endif

	if (get_pcvar_num(g_pCvarNemesisSpeed))
	{
		ze_reset_zombie_speed(id)
	}

	if (get_pcvar_num(g_pCvarNemesisGravity))
	{
		ze_reset_user_gravity(id)
	}

	if (get_pcvar_num(g_pCvarNemesisKB))
	{
		ze_reset_user_knockback(id)
	}

	if (get_pcvar_num(g_pCvarNemesisGlow))
	{
		Set_Rendering(id)
	}
}

public GetRandomNemesis()
{
	if (get_playersnum())
	{
		new iPlayers[32], iSelected[33], iCount = 0, iTotalPlayers, id
		get_players(iPlayers, iTotalPlayers)

		for (new i = 0; i < iTotalPlayers; i++)
		{
			id = iPlayers[i]

			if (is_user_alive(id) && !g_bIsNemesis[id])
			{
				iSelected[iCount++] = id
			}
		}

		return iSelected[random(--iCount)]
	}

	return 0
}

public native_ze_is_user_nemesis(id)
{
	if (!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return -1
	}

	return g_bIsNemesis[id]
}

public native_ze_set_user_nemesis(id, bool:set)
{
	if (!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false
	}

	if (set)
	{
		if (!g_bIsNemesis[id])
			Set_Nemesis(id)
	}
	else
	{
		if (g_bIsNemesis[id])
			UnSet_Nemesis(id)
	}

	return true
}
btw ty jack for the fixes :D will let u know if any kind of bug found
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#42

Post by karan » 4 years ago

BandiT wrote: 4 years ago This plugin have some resources for sound sprites ?
just models and in update a round ambience
Image

BandiT
Member
Member
Romania
Posts: 59
Joined: 4 years ago
Contact:

#43

Post by BandiT » 4 years ago

I complied the code of nemesis i put on my sv but is no working, is showing me bad load.

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#44

Post by karan » 4 years ago

BandiT wrote: 4 years ago I complied the code of nemesis i put on my sv but is no working, is showing me bad load.
cause u r using older version of ze have to upgrade to 1.5
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#45

Post by karan » 4 years ago

jack only 1 thing frost nade is not working on nemesis can u fix it plz?
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#46

Post by czirimbolo » 4 years ago

When you use knive menu and choose one of them, you can walk in freeztime while nemesis counting is ON. Can you fix this?
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#47

Post by karan » 4 years ago

czirimbolo wrote: 4 years ago When you use knive menu and choose one of them, you can walk in freeztime while nemesis counting is ON. Can you fix this?
which ze version u are using?
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#48

Post by czirimbolo » 4 years ago

karan wrote: 4 years ago
czirimbolo wrote: 4 years ago When you use knive menu and choose one of them, you can walk in freeztime while nemesis counting is ON. Can you fix this?
which ze version u are using?
1,5v
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#49

Post by karan » 4 years ago

czirimbolo wrote: 4 years ago
karan wrote: 4 years ago
czirimbolo wrote: 4 years ago When you use knive menu and choose one of them, you can walk in freeztime while nemesis counting is ON. Can you fix this?
which ze version u are using?
1,5v
nd nemesis plugin not working?
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#50

Post by karan » 4 years ago

czirimbolo wrote: 4 years ago When you use knive menu and choose one of them, you can walk in freeztime while nemesis counting is ON. Can you fix this?
as u said it only bugged in knife menu?
i mean if u use knife menu it bugger or it always behave like this?
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#51

Post by czirimbolo » 4 years ago

nemesis is working but when I choose one of the knives, I can walk in freezetime when NEMESIS round is ON. I am not gonna turn off my knives. Nemesis plugin is causing that problem. I've never had any problems with knive menu till now
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#52

Post by karan » 4 years ago

karan wrote: 4 years ago and also if u facing model bug add this

Code: Select all

    #if defined USE_NEMESIS_MODEL
        new szPlayerModel[32], szModel[64]
        ArrayGetString(g_aModels_Nemesis_Player, random_num(0, ArraySize(g_aModels_Nemesis_Player) - 1), szPlayerModel, charsmax(szPlayerModel))
        cs_reset_user_model(id)
    #endif
at public UnSet_Nemesis(id)

and done
dont forget to include cstrike after ze include
#include <cstrike>
Image


karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#54

Post by karan » 2 years ago

VicKy wrote: 2 years ago Karan its working?
for me yes it is did some changes to work with version 1.6
Image

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#55

Post by VicKy » 2 years ago

Can you give me Fixed Your Nemesis Mod i am using v1.6
Image

User avatar
VicKy
Mod Tester
Mod Tester
Pakistan
Posts: 87
Joined: 3 years ago
Contact:

#56

Post by VicKy » 2 years ago

i used this plugin
bugged
1. When Make nemesis its not block sv to respawn zm
2. skin bugged normal zm skin showing
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#57

Post by karan » 2 years ago

  1. #include <cstrike>
  2. #include <zombie_escape>
  3.  
  4. // Uncomment to use custom model for nemesis
  5. // Note: This includes player model & claws
  6. #define USE_NEMESIS_MODEL
  7.  
  8. // Uncomment to use leap for nemesis
  9. // Leap Code: https://escapers-zone.net/viewtopic.php?p=10582#p10582
  10. #define USE_NEMESIS_LEAP
  11.  
  12. #define TASK_MAKE_NEMESIS 4949849
  13. #define TASK_AMBIENCESOUND 2020
  14. #define TASK_REAMBIENCESOUND 5050
  15.  
  16. // Access to start nemesis round
  17. #define STARTNEMESIS_ACCESS ADMIN_KICK
  18.  
  19. // Settings file
  20. new const ZE_SETTING_FILE[] = "zombie_escape.ini"
  21.  
  22. #if defined USE_NEMESIS_MODEL
  23. // Default models
  24. new const g_szModels_Nemesis_Player[][] = { "nemesis_v2" }
  25. new const g_szModels_Nemesis_Claws[][] = { "models/zombie_escape/v_nemesis_knife_v2.mdl" }
  26.  
  27. new Array:g_aModels_Nemesis_Player,
  28.     Array:g_aModels_Nemesis_Claws
  29. #endif
  30.  
  31. #if defined USE_NEMESIS_LEAP
  32. native ze_get_longjump(id)
  33. native ze_remove_longjump(id)
  34. #endif
  35.  
  36. enum _:Colors
  37. {
  38.     Red = 0,
  39.     Green,
  40.     Blue
  41. }
  42.  
  43. new g_iAmbianceSoundDuration = 160  // Set ambience duration = highest sound duration
  44. new const szAmbianceSound[][] =
  45. {
  46.     "zombie_escape/ze_ambiance1.mp3"
  47. }
  48.  
  49. new bool:g_bIsNemesis[33],
  50.     bool:g_bIsNextRoundNemesis = false,
  51.     g_iCountDown,
  52.     Array:g_szAmbianceSound,
  53.         g_iNemesisNum = 0
  54.  
  55. new g_pCvarNemesisHP,
  56.     g_pCvarNemesisGravity,
  57.     g_pCvarNemesisSpeed,
  58.     //g_pCvarNemesisGlow,
  59.     //g_pCvarNemesisGlowColor[Colors],
  60.     g_pCvarNemesisKB,
  61.     g_pCvarNemesisDmg,
  62.     g_pCvarNemesisFreeze,
  63.     g_pCvarNemesisFire
  64.  
  65. public plugin_natives()
  66. {
  67.     register_native("ze_is_user_nemesis", "native_ze_is_user_nemesis", 1)
  68.     register_native("ze_set_user_nemesis", "native_ze_set_user_nemesis", 1)
  69. }
  70.  
  71. public plugin_precache()
  72. {
  73.     g_szAmbianceSound = ArrayCreate(64, 1)
  74.     amx_load_setting_string_arr(ZE_SETTING_FILE, "Sounds", "Nemesis Round Ambiance", g_szAmbianceSound)
  75.  
  76.     new iIndex, szSound[64]
  77.     if (ArraySize(g_szAmbianceSound) == 0)
  78.     {
  79.         for (iIndex = 0; iIndex < sizeof szAmbianceSound; iIndex++)
  80.             ArrayPushString(g_szAmbianceSound, szAmbianceSound[iIndex])
  81.        
  82.         // Save to external file
  83.         amx_save_setting_string_arr(ZE_SETTING_FILE, "Sounds", "Nemesis Round Ambiance", g_szAmbianceSound)
  84.     }
  85.  
  86.     for (iIndex = 0; iIndex < ArraySize(g_szAmbianceSound); iIndex++)
  87.     {
  88.         ArrayGetString(g_szAmbianceSound, iIndex, szSound, charsmax(szSound))
  89.        
  90.         if (equal(szSound[strlen(szSound)-4], ".mp3"))
  91.         {
  92.             format(szSound, charsmax(szSound), "sound/%s", szSound)
  93.             precache_generic(szSound)
  94.         }
  95.         else
  96.         {
  97.             precache_sound(szSound)
  98.         }
  99.     }
  100.  
  101.     #if defined USE_NEMESIS_MODEL
  102.         // Initialize arrays
  103.         g_aModels_Nemesis_Player = ArrayCreate(32, 1)
  104.         g_aModels_Nemesis_Claws = ArrayCreate(64, 1)
  105.        
  106.         // Load from external file
  107.         amx_load_setting_string_arr(ZE_SETTING_FILE, "Player Models", "NEMESIS MODEL", g_aModels_Nemesis_Player)
  108.         amx_load_setting_string_arr(ZE_SETTING_FILE, "Weapon Models", "V_KNIFE NEMESIS", g_aModels_Nemesis_Claws)
  109.        
  110.         // If we couldn't load from file, use and save default ones
  111.         if (ArraySize(g_aModels_Nemesis_Player) == 0)
  112.         {
  113.             for (iIndex = 0; iIndex < sizeof g_szModels_Nemesis_Player; iIndex++)
  114.                 ArrayPushString(g_aModels_Nemesis_Player, g_szModels_Nemesis_Player[iIndex])
  115.            
  116.             // Save to external file
  117.             amx_save_setting_string_arr(ZE_SETTING_FILE, "Player Models", "NEMESIS", g_aModels_Nemesis_Player)
  118.         }
  119.  
  120.         if (ArraySize(g_aModels_Nemesis_Claws) == 0)
  121.         {
  122.             for (iIndex = 0; iIndex < sizeof g_szModels_Nemesis_Claws; iIndex++)
  123.                 ArrayPushString(g_aModels_Nemesis_Claws, g_szModels_Nemesis_Claws[iIndex])
  124.            
  125.             // Save to external file
  126.             amx_save_setting_string_arr(ZE_SETTING_FILE, "Weapon Models", "V_KNIFE NEMESIS", g_aModels_Nemesis_Claws)
  127.         }
  128.        
  129.         // Precache models
  130.         new player_model[32], model[64], model_path[128]
  131.  
  132.         for (iIndex = 0; iIndex < ArraySize(g_aModels_Nemesis_Player); iIndex++)
  133.         {
  134.             ArrayGetString(g_aModels_Nemesis_Player, iIndex, player_model, charsmax(player_model))
  135.             formatex(model_path, charsmax(model_path), "models/player/%s/%s.mdl", player_model, player_model)
  136.             precache_model(model_path)
  137.             // Support modelT.mdl files
  138.             formatex(model_path, charsmax(model_path), "models/player/%s/%sT.mdl", player_model, player_model)
  139.             if (file_exists(model_path)) precache_model(model_path)
  140.         }
  141.  
  142.         for (iIndex = 0; iIndex < ArraySize(g_aModels_Nemesis_Claws); iIndex++)
  143.         {
  144.             ArrayGetString(g_aModels_Nemesis_Claws, iIndex, model, charsmax(model))
  145.             precache_model(model)
  146.         }
  147.     #endif
  148. }
  149.  
  150. public plugin_init()
  151. {
  152.     register_plugin("[ZE] Addons: Nemesis", "2.0", "Jack")
  153.  
  154.     RegisterHam(Ham_TakeDamage, "player", "Fw_TakeDamage")
  155.  
  156.     register_clcmd("ze_start_nemesis_next", "cmd_start_nemesis", STARTNEMESIS_ACCESS)
  157.     register_concmd("ze_nemesis", "cmd_nemsis", STARTNEMESIS_ACCESS)
  158.  
  159.     g_pCvarNemesisHP = register_cvar("ze_nemesis_hp", "20000")  // Nemesis health - Set 0 to use zombie HP
  160.     g_pCvarNemesisGravity = register_cvar("ze_nemesis_gravity", "600")  // Nemesis gravity - Set 0 to use zombie gravity
  161.     g_pCvarNemesisSpeed = register_cvar("ze_nemesis_speed", "300")  // Nemesis speed - Set 0 to use zombie speed
  162.     /*g_pCvarNemesisGlow = register_cvar("ze_nemesis_glow", "1")    // Nemesis glow - 1 = enable | 0 = disable
  163.     g_pCvarNemesisGlowColor[Red] = register_cvar("ze_nemesis_glow_r", "255")    // Nemesis glow color RED
  164.     g_pCvarNemesisGlowColor[Green] = register_cvar("ze_nemesis_glow_g", "255")  // Nemesis glow color GREEN
  165.     g_pCvarNemesisGlowColor[Blue] = register_cvar("ze_nemesis_glow_b", "255")   // Nemesis glow color BLUE*/
  166.     g_pCvarNemesisKB = register_cvar("ze_nemesis_kb", "200.0")  // Nemesis knockback - Set 0 to use zombie knockback
  167.     g_pCvarNemesisDmg = register_cvar("ze_nemesis_dmg", "200.0")    // Nemesis damage
  168.     g_pCvarNemesisFreeze = register_cvar("ze_nemesis_freeze", "0")  // Nemesis get frozen? - 1 = doesn't get frozen | 0 = gets frozen
  169.     g_pCvarNemesisFire = register_cvar("ze_nemesis_fire", "1")  // Nemesis set on fire? - 1 = doesn't set on fire | 0 = set on fire
  170. }
  171.  
  172. /*public client_disconnected(id)
  173. {
  174.     if (g_bIsNemesis[id])
  175.     {
  176.         new szPlayerName[2][32], iNewNemId
  177.         get_user_name(id, szPlayerName[0], charsmax(szPlayerName))
  178.         iNewNemId = GetRandomNemesis()
  179.         get_user_name(iNewNemId, szPlayerName[1], charsmax(szPlayerName))
  180.         g_bIsNemesis[id] = false
  181.         Set_Nemesis(iNewNemId)
  182.         ze_colored_print(0, "!g%s !thas left !n& !g%s !thas become nemesis!n.", szPlayerName[0], szPlayerName[1])
  183.     }
  184. }*/
  185.  
  186. public client_putinserver(id)
  187. {
  188.     if (g_bIsNemesis[id])
  189.         g_bIsNemesis[id] = false
  190. }
  191.  
  192. public ze_user_infected_pre(iVictim, iAttacker)
  193. {
  194.     if (g_bIsNemesis[iAttacker] && !ze_is_user_zombie(iVictim))
  195.     {
  196.         ExecuteHamB(Ham_Killed, iVictim, iAttacker, 0)
  197.                 return 1
  198.     }
  199.  
  200.     return 0
  201. }
  202.  
  203. public Fw_TakeDamage(iVictim, iInfector, iAttacker, Float:iDamage)
  204. {
  205.     if (iVictim == iAttacker || !is_user_alive(iAttacker))
  206.         return HAM_IGNORED
  207.  
  208.     if (g_bIsNemesis[iAttacker] && !ze_is_user_zombie(iVictim) && iInfector == iAttacker)
  209.     {
  210.         ExecuteHamB(Ham_Killed, iVictim, iAttacker, 0)
  211.                 return 1
  212.     }
  213.  
  214.     return HAM_IGNORED
  215. }
  216.  
  217. public ze_fire_pre(id)
  218. {
  219.     if (g_bIsNemesis[id] && get_pcvar_num(g_pCvarNemesisFire))
  220.         return PLUGIN_HANDLED
  221.     return PLUGIN_CONTINUE
  222. }
  223.  
  224. public ze_frost_pre(id)
  225. {
  226.     if (g_bIsNemesis[id] && get_pcvar_num(g_pCvarNemesisFreeze))
  227.         return PLUGIN_HANDLED
  228.     return PLUGIN_CONTINUE
  229. }
  230.  
  231. public ze_user_humanized(id)
  232. {
  233.     UnSet_Nemesis(id)
  234. }
  235.  
  236. public ze_roundend()
  237. {
  238.     remove_task(TASK_AMBIENCESOUND)
  239.     remove_task(TASK_REAMBIENCESOUND)
  240.     remove_task(TASK_MAKE_NEMESIS)
  241.    
  242.     for (new id = 0; id <= get_member_game(m_nMaxPlayers); id++)
  243.     {
  244.         if (is_user_alive(id) && g_bIsNemesis[id])
  245.             UnSet_Nemesis(id)
  246.     }
  247. }
  248.  
  249. public ze_game_started_pre()
  250. {
  251.     if (get_playersnum())
  252.     {
  253.         if (g_bIsNextRoundNemesis)
  254.         {
  255.             g_bIsNextRoundNemesis = false
  256.             g_iCountDown = 17
  257.             set_task(1.0, "StartNemesis", TASK_MAKE_NEMESIS, _, _, "b")
  258.             set_task(5.0, "AmbianceSound", TASK_AMBIENCESOUND)
  259.             return PLUGIN_HANDLED
  260.         }
  261.     }
  262.     else
  263.     {
  264.         g_bIsNextRoundNemesis = false
  265.         ze_colored_print(0, "!gThe server doesn't have enough players to start nemesis round !n(!tat least 1!n)!n.")
  266.     }
  267.  
  268.     return PLUGIN_CONTINUE
  269. }
  270.  
  271. public AmbianceSound()
  272. {
  273.     // Stop All Sounds
  274.     StopSound()
  275.    
  276.     // Play The Ambiance Sound For All Players
  277.     new szSound[64]
  278.     ArrayGetString(g_szAmbianceSound, random_num(0, ArraySize(g_szAmbianceSound) - 1), szSound, charsmax(szSound))
  279.    
  280.     for (new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
  281.     {
  282.         if (!is_user_connected(id))
  283.             continue
  284.  
  285.         PlaySound(id, szSound)
  286.     }
  287.  
  288.     // We should Set Task back again to replay (Repeated 5 times MAX)
  289.     set_task(float(g_iAmbianceSoundDuration), "AmbianceSound", TASK_REAMBIENCESOUND, _, _, "a", 5)
  290. }
  291.  
  292. public StartNemesis(taskid)
  293. {
  294.     if (!g_iCountDown)
  295.     {
  296.             new iNemesis, id
  297.    
  298.         while (iNemesis < RequiredNemesis())
  299.         {
  300.              id = GetRandomAlive(random_num(1, GetAllAlivePlayersNum()))
  301.        
  302.              if (!is_user_alive(id) || g_bIsNemesis[id])
  303.              continue
  304.  
  305.              Set_Nemesis(id)
  306.              iNemesis++
  307.         }
  308.  
  309.         g_iNemesisNum = iNemesis
  310.         remove_task(taskid)
  311.         return
  312.     }
  313.  
  314.     set_hudmessage(random(256), random(256), random(256), -1.0, 0.21, 0, 0.8, 0.8)
  315.     show_hudmessage(0, "Nemesis starts in %d second(s).", g_iCountDown--)
  316. }
  317.  
  318. public cmd_start_nemesis(id, level, cid)
  319. {
  320.     if (!cmd_access(id, STARTNEMESIS_ACCESS, cid, 0))
  321.     {
  322.         client_print(id, print_console, "You have not access.")
  323.         return PLUGIN_HANDLED
  324.     }
  325.    
  326.     g_bIsNextRoundNemesis = true
  327.     client_print(id, print_console, "Nemesis round will start next round.")
  328.     return PLUGIN_HANDLED
  329. }
  330.  
  331. public cmd_nemsis(id, level, cid)
  332. {
  333.     if (!cmd_access(id, STARTNEMESIS_ACCESS, cid, 0))
  334.     {
  335.         client_print(id, print_console, "You have not access.")
  336.         return PLUGIN_HANDLED
  337.     }
  338.    
  339.     // Retrieve arguments
  340.     new arg[32], player
  341.     read_argv(1, arg, charsmax(arg))
  342.     player = cmd_target(id, arg, (CMDTARGET_ONLY_ALIVE | CMDTARGET_ALLOW_SELF))
  343.    
  344.     // Invalid target
  345.     if (!player || !is_user_alive(player))
  346.     {
  347.         ze_colored_print(id, "Invalid player.")
  348.         return PLUGIN_HANDLED
  349.     }
  350.    
  351.     // Target not allowed to be nemesis
  352.     if (g_bIsNemesis[player])
  353.     {
  354.         new player_name[32]
  355.         get_user_name(player, player_name, charsmax(player_name))
  356.         client_print(id, print_console, "[ZE] %s is already nemesis.", player_name)
  357.         return PLUGIN_HANDLED
  358.     }
  359.    
  360.     Set_Nemesis(player)
  361.     return PLUGIN_HANDLED
  362. }
  363.  
  364. public Set_Nemesis(id)
  365. {
  366.     g_bIsNemesis[id] = true
  367.  
  368.     if (!ze_is_user_zombie(id))
  369.         ze_set_user_zombie(id)
  370.  
  371.     #if defined USE_NEMESIS_LEAP
  372.         ze_get_longjump(id)
  373.     #endif
  374.  
  375.     #if defined USE_NEMESIS_MODEL
  376.         new szPlayerModel[32], szModel[64]
  377.         ArrayGetString(g_aModels_Nemesis_Player, random_num(0, ArraySize(g_aModels_Nemesis_Player) - 1), szPlayerModel, charsmax(szPlayerModel))
  378.         cs_set_user_model(id, szPlayerModel)
  379.  
  380.         ArrayGetString(g_aModels_Nemesis_Claws, random_num(0, ArraySize(g_aModels_Nemesis_Claws) - 1), szModel, charsmax(szModel))
  381.         cs_set_player_view_model(id, CSW_KNIFE, szModel)
  382.     #endif
  383.    
  384.     if (get_pcvar_num(g_pCvarNemesisHP))
  385.     {
  386.         set_entvar(id, var_health, get_pcvar_float(g_pCvarNemesisHP))
  387.     }
  388.  
  389.     if (get_pcvar_num(g_pCvarNemesisSpeed))
  390.     {
  391.         ze_set_zombie_speed(id, get_pcvar_num(g_pCvarNemesisSpeed))
  392.     }
  393.  
  394.     if (get_pcvar_num(g_pCvarNemesisGravity))
  395.     {
  396.         ze_set_user_gravity(id, get_pcvar_num(g_pCvarNemesisGravity))
  397.     }
  398.  
  399.     if (get_pcvar_num(g_pCvarNemesisKB))
  400.     {
  401.         ze_set_user_knockback(id, get_pcvar_float(g_pCvarNemesisKB))
  402.     }
  403.  
  404.     /*if (get_pcvar_num(g_pCvarNemesisGlow))
  405.     {
  406.         set_user_rendering(id, fx = kRenderFxNone, r = 255, g = 0, b = 0, render = kRenderNormal, amount = 10)
  407.     }*/
  408.  
  409.     new szName[32]
  410.     get_user_name(id, szName, charsmax(szName))
  411.     set_hudmessage(255, 0, 0, -1.0, 0.21, 0, 0.0, 5.0, 0.1, 1.5)
  412.     show_hudmessage(id, "%s became Nemesis", szName)
  413.     ze_colored_print(0, "!g%s !tbecame !gNemesis!n.", szName)
  414.     ze_colored_print(id, "!gYou !tbecame !gNemesis!n.")
  415. }
  416.  
  417. public UnSet_Nemesis(id)
  418. {
  419.     if (!g_bIsNemesis[id] || !is_user_alive(id))
  420.         return
  421.  
  422.     g_bIsNemesis[id] = false
  423.  
  424.     #if defined USE_NEMESIS_LEAP
  425.         ze_remove_longjump(id)
  426.     #endif
  427.  
  428.         #if defined USE_NEMESIS_MODEL
  429.                 new szPlayerModel[32], szModel[64]
  430.                 ArrayGetString(g_aModels_Nemesis_Player, random_num(0, ArraySize(g_aModels_Nemesis_Player) - 1), szPlayerModel, charsmax(szPlayerModel))
  431.                 cs_reset_user_model(id)
  432.         #endif
  433.  
  434.     if (get_pcvar_num(g_pCvarNemesisSpeed))
  435.     {
  436.         ze_reset_zombie_speed(id)
  437.     }
  438.  
  439.     if (get_pcvar_num(g_pCvarNemesisGravity))
  440.     {
  441.         ze_reset_user_gravity(id)
  442.     }
  443.  
  444.     if (get_pcvar_num(g_pCvarNemesisKB))
  445.     {
  446.         ze_reset_user_knockback(id)
  447.     }
  448.  
  449.     /*if (get_pcvar_num(g_pCvarNemesisGlow))
  450.     {
  451.         Set_Rendering(id)
  452.     }*/
  453. }
  454.  
  455. public GetRandomNemesis()
  456. {
  457.     new iPlayers[32], iSelected[33], iCount = 0, iTotalPlayers, iRandomIndex
  458.     get_players(iPlayers, iTotalPlayers)
  459.  
  460.     if (iTotalPlayers > 0)
  461.     {
  462.         for (new i = 0; i < iTotalPlayers; i++)
  463.         {
  464.             iRandomIndex = iPlayers[i]
  465.  
  466.             if (is_user_alive(iRandomIndex))
  467.             {
  468.                 iSelected[iCount++] = iRandomIndex
  469.             }
  470.         }
  471.  
  472.         return iSelected[random(--iCount)]
  473.     }
  474.  
  475.     return 0
  476. }
  477.  
  478. public native_ze_is_user_nemesis(id)
  479. {
  480.     if (!is_user_connected(id))
  481.     {
  482.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  483.         return -1
  484.     }
  485.  
  486.     return g_bIsNemesis[id]
  487. }
  488.  
  489. public native_ze_set_user_nemesis(id, bool:set)
  490. {
  491.     if (!is_user_connected(id))
  492.     {
  493.         log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
  494.         return false
  495.     }
  496.  
  497.     if (set)
  498.     {
  499.         if (!g_bIsNemesis[id])
  500.             Set_Nemesis(id)
  501.     }
  502.     else
  503.     {
  504.         if (g_bIsNemesis[id])
  505.             UnSet_Nemesis(id)
  506.     }
  507.  
  508.     return true
  509. }
  510.  
  511. stock RequiredNemesis()
  512. {
  513.     switch(GetAllAlivePlayersNum())
  514.     {
  515.         case 2..5: return 1
  516.         case 6..15: return 2
  517.         case 16..25: return 3
  518.         case 26..32: return 4
  519.     }
  520.     return 0
  521. }
  522.  
  523. public native_ze_get_nemesis_number()
  524. {
  525.     return g_iNemesisNum
  526. }
Image

karan
Mod Tester
Mod Tester
India
Posts: 122
Joined: 6 years ago
Location: India
Contact:

#58

Post by karan » 2 years ago

try it i removed the glow cause its buggy...
Image

User avatar
z0h1r-LK
Mod Developer
Mod Developer
Morocco
Posts: 473
Joined: 5 years ago
Location: The Red City ❤
Contact:

#59

Post by z0h1r-LK » 2 years ago


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 4 guests