Approved Best Defender

Plug-ins compatibility with Zombie Escape 1.x only!


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

Best Defender

#1

Post by Raheem » 7 years ago

Humans Best Defender

Description:
  • This plugin will get the best defender in Humans teams based on the damage made. It will compare all players damage and the highest damage is the best defender. Best defender will be awarded double jumb and will be printed at the new round that he was best defender in the previous round.
Cvars:
  • ze_give_multijump 1 Enable or Disable MultiJump Award? 1 = Enable | 0 = Disable
  • ze_best_def_chat_notice 1 Enable or Disable Chat Notice? 1 = Enable | 0 = Disable
  • ze_best_def_give_xp 40 XP amount to be given For Best Defender? If you make it 0 he won't get anything.
  • ze_best_def_give_ec 20 Escape Coins amount to be given For Best Defender? If you make it 0 he won't get anything.
  • ze_show_best_def_stats 1 State Message: 0 = Disabled | 1 = Chat Message | 2 = Hud Message | 3 = DHud Message
Commands:
  • say /mydamage Show player his damage and how much damage needed to became Best Defender.
Installation & Instructions:
Changelog:
  • Spoiler!
    Version: 1.0
    • First Release.
    Version: 1.1
    • New Algorithm used to detect Highest one made damage.
    • New Cvar Added so you can give Best Defender some XP.
    • New Cvar Added so you can give Best Defender Some Escape Coins.
    • Chat Notice Message Updated with XP, EC Amounts.
    • Some Problems in Spawn Event has been fixed.
    Version: 1.2
    • Fixed chat message problem it was show wrong values.
    • Fixed If no one make damage. Message won't appear and No one will be awarded.
    • Fixed problem related to resting damage counter at new round.
    • Added New Chat/Hud/DHud message for stats by command.
    Version: 1.3 [Current Version]
    • Fixed some problems in code, I don't know how i make these mistakes.
    • Add damage to show to the best defender when he say /mydamage
Screenshots:
  • ImageImageImageImageImageImageImageImage

Downloads:
He who fails to plan is planning to fail

johnnysins2000
Veteran Member
Veteran Member
Paraguay
Posts: 678
Joined: 7 years ago
Location: Paraguay
Contact:

#2

Post by johnnysins2000 » 7 years ago

Instead of Multijump why don't we reward him Some Escape Coins ?
Nobody Is That Busy If They Make Time :roll:

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

#3

Post by Night Fury » 7 years ago

johnnysins2000 wrote: 7 years ago Instead of Multijump why don't we reward him Some Escape Coins ?
It does both, it'd be better if he made Cvar! :P
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

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

#4

Post by Raheem » 7 years ago

I'll make this in the next Update nice idea.
He who fails to plan is planning to fail

johnnysins2000
Veteran Member
Veteran Member
Paraguay
Posts: 678
Joined: 7 years ago
Location: Paraguay
Contact:

#5

Post by johnnysins2000 » 7 years ago

Raheem wrote: 7 years ago I'll make this in the next Update nice idea.

And Some XP too if the User is using Level xp system
Nobody Is That Busy If They Make Time :roll:

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

#6

Post by Raheem » 7 years ago

When i get time i'll make these nice ideas in the next versions.
He who fails to plan is planning to fail

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

#7

Post by Raheem » 7 years ago

New version Released.
Current Version Now: 1.1
He who fails to plan is planning to fail

User avatar
sam_bhosale4
Mod Tester
Mod Tester
India
Posts: 109
Joined: 7 years ago
Location: INDIA
Contact:

#8

Post by sam_bhosale4 » 6 years ago

Good plugins but needs some fixes raheem bro!
It Gives xp and coins even if no one defends! and shows 0 defend awards!
Please fix the values like minimum 800 or 1000 damage done needed to become best defender otherwise it keeps giving free xp and coins!
so it will balance it!
thanks!
-=SeRious-GaminG|Zombie Escape[Alien vs. Predator]|Asia=-
206.189.132.169:40000
Image

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

#9

Post by Raheem » 6 years ago

As best infector, Change:
  • Code: Select all

    	if (get_pcvar_num(cvar_give_xp) != 0 || get_pcvar_num(cvar_give_escape_coins) != 0)
    	{
    		if (g_iBestDefIndex == 0 || g_iBestDefIndex != id)
    			return
    		
    		ze_set_escape_coins(g_iBestDefIndex, get_pcvar_num(cvar_give_escape_coins) + ze_get_escape_coins(g_iBestDefIndex))
    		ze_set_user_xp(g_iBestDefIndex, get_pcvar_num(cvar_give_xp) + ze_get_user_xp(g_iBestDefIndex))
    	}
TO:
  • Code: Select all

    	if (get_pcvar_num(cvar_give_xp) != 0 || get_pcvar_num(cvar_give_escape_coins) != 0)
    	{
    		if (g_iBestDefIndex == 0 || g_iBestDefIndex != id || g_fDamage[id] <= 200.0)
    			return
    		
    		ze_set_escape_coins(g_iBestDefIndex, get_pcvar_num(cvar_give_escape_coins) + ze_get_escape_coins(g_iBestDefIndex))
    		ze_set_user_xp(g_iBestDefIndex, get_pcvar_num(cvar_give_xp) + ze_get_user_xp(g_iBestDefIndex))
    	}
Change the 200 to any value as you need: g_fDamage[id] <= 200.0

It will give the best defender the reward if the damage he made is higher than 200.0
He who fails to plan is planning to fail

johnnysins2000
Veteran Member
Veteran Member
Paraguay
Posts: 678
Joined: 7 years ago
Location: Paraguay
Contact:

#10

Post by johnnysins2000 » 6 years ago

this is for Sam! Sam try this ... it worked for me !

Code: Select all

#include <zombie_escape>
#include <ze_multijump>
#include <ze_levels>

// Variables
new Float:g_fDamage[33], g_iBestDefIndex

// Cvars
new cvar_give_multijump, cvar_show_chat_notice, cvar_give_xp, cvar_give_escape_coins

public plugin_init()
{
	register_plugin("[ZE] Best Defender", "1.1", "Raheem")
	
	// Hook Chains
	RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
	RegisterHookChain(RG_CBasePlayer_Spawn, "Fw_PlayerSpawn_Post", 1)
	
	// Cvars
	cvar_give_multijump = register_cvar("ze_give_multijump", "1")
	cvar_show_chat_notice = register_cvar("ze_best_def_chat_notice", "1")
	cvar_give_xp = register_cvar("ze_best_def_give_xp", "40")
	cvar_give_escape_coins = register_cvar("ze_best_def_give_ec", "20")
}

public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
	if (!is_user_alive(iVictim) || !is_user_alive(iAttacker))
		return HC_SUPERCEDE
	
	g_fDamage[iAttacker] += fDamage
	return HC_CONTINUE
}

public ze_roundend()
{
	Get_Best_Defender()
}

public Fw_PlayerSpawn_Post(id)
{
	if (get_pcvar_num(cvar_show_chat_notice) != 0)
	{
		new szName[32]
		get_user_name(g_iBestDefIndex, szName, charsmax(szName))
		
		if (g_iBestDefIndex == 0)
			return
		
		if (get_pcvar_num(cvar_give_multijump) == 0)
		{
			ze_colored_print(id, "!tBest Defender: !g%s. !tDamage: !g%i. !tAwards: !g%d XP, %d EC!y.", szName, floatround(g_fDamage[id]), get_pcvar_num(cvar_give_xp), get_pcvar_num(cvar_give_escape_coins))
		}
		else
		{
			ze_colored_print(id, "!tBest Defender: !g%s. !tDamage: !g%i. !tAwards: !g%d XP, %d EC, Multi-Jump!y.", szName, floatround(g_fDamage[id]), get_pcvar_num(cvar_give_xp), get_pcvar_num(cvar_give_escape_coins))
		}
	}
	
	if (get_pcvar_num(cvar_give_multijump) != 0)
	{
		if (g_iBestDefIndex == 0 || g_iBestDefIndex != id)
			return
		
		ze_give_user_multijump(g_iBestDefIndex)
	}
	
	if (get_pcvar_num(cvar_give_xp) != 0 || get_pcvar_num(cvar_give_escape_coins) != 0)
	{
		if (g_iBestDefIndex == 0 || g_iBestDefIndex != 500.0)
			return
		
		ze_set_escape_coins(g_iBestDefIndex, get_pcvar_num(cvar_give_escape_coins) + ze_get_escape_coins(g_iBestDefIndex))
		ze_set_user_xp(g_iBestDefIndex, get_pcvar_num(cvar_give_xp) + ze_get_user_xp(g_iBestDefIndex))
	}
	
	// Delay Needed
	set_task(3.0, "Rest_Damage", id, _, _, "a", 1)
}

public Rest_Damage(id)
{
	g_fDamage[id] = 0.0
}

public Get_Best_Defender()
{
	new Float:fTemp = 0.0
	
	for (new i = 0; i <= 32; i++)
	{
		if (g_fDamage[i] > fTemp)
		{
			fTemp += g_fDamage[i]
			g_iBestDefIndex = i
		}
	}
}
Nobody Is That Busy If They Make Time :roll:

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

#11

Post by Raheem » 6 years ago

Version 1.2 out.
He who fails to plan is planning to fail

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

#12

Post by Raheem » 6 years ago

New version released. Some important fixes inserted. Please if you run this plugin to update it.
He who fails to plan is planning to fail

CaseyG
Member
Member
United States of America
Posts: 1
Joined: 6 years ago
Contact:

#13

Post by CaseyG » 6 years ago

Raheeem wrote: 6 years ago New version released. Some important fixes inserted. Please if you run this plugin to update it.
Thanks for the plugin!
Last edited by CaseyG 6 years ago, edited 2 times in total.

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

#14

Post by Raheem » 6 years ago

You are welcome.
He who fails to plan is planning to fail

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#15

Post by sPe3doN » 5 years ago

Raheem can you remove escape coins & multi jump ? I want only xp
Image

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

#16

Post by czirimbolo » 5 years ago

here are the cvars:

ze_best_def_give_xp "40" - you can change this value
ze_best_def_give_ec 0
ze_give_multijump 0

am I right?
Image

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 258
Joined: 7 years ago
Contact:

#17

Post by sPe3doN » 5 years ago

czirimbolo wrote: 5 years ago here are the cvars:

ze_best_def_give_xp "40" - you can change this value
ze_best_def_give_ec 0
ze_give_multijump 0

am I right?
nah not like theat.. i want this plugin work with out multi jump plugin
Image

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

#18

Post by Raheem » 5 years ago

Code: Select all

#include <zombie_escape>
#include <ze_levels>

// Variables
new Float:g_fDamage[33], g_iBestDefIndex

// Cvars
new cvar_show_chat_notice, cvar_give_xp, cvar_give_escape_coins, cvar_show_stats

public plugin_init()
{
	register_plugin("[ZE] Best Defender", "1.3", "Raheem")
	
	// Hook Chains
	RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
	RegisterHookChain(RG_CBasePlayer_Spawn, "Fw_PlayerSpawn_Post", 1)
	
	// Cvars
	cvar_show_chat_notice = register_cvar("ze_best_def_chat_notice", "1")
	cvar_give_xp = register_cvar("ze_best_def_give_xp", "40")
	cvar_give_escape_coins = register_cvar("ze_best_def_give_ec", "20")
	cvar_show_stats = register_cvar("ze_show_best_def_stats", "1")
	
	// Commands
	register_clcmd("say /mydamage", "Cmd_BestDefenderStats")
}

public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
	if (!is_user_alive(iVictim) || !is_user_alive(iAttacker))
		return HC_CONTINUE
	
	g_fDamage[iAttacker] += fDamage
	return HC_CONTINUE
}

public ze_roundend()
{
	Get_Best_Defender()
}

public Cmd_BestDefenderStats(id)
{
	Get_Best_Defender()
	
	switch (get_pcvar_num(cvar_show_stats))
	{
		case 1:
		{
			if (id == g_iBestDefIndex)
			{
				ze_colored_print(id, "!tYou are now Best Defender !y[!g%d!y] !y:)", floatround(g_fDamage[g_iBestDefIndex]))
			}
			else
			{
				ze_colored_print(id, "!tYour Damage !g%d!y, !tYou need !g%d !tDamage To be Best Defender!y.", floatround(g_fDamage[id]), floatround(g_fDamage[g_iBestDefIndex] - g_fDamage[id]))
			}
		}
		case 2:
		{
			if (id == g_iBestDefIndex)
			{
				set_hudmessage(random(256), random(256), random(256), -1.0, 0.3, 2, 3.0, 5.0)
				show_hudmessage(id, "You are now Best Defender [%d] :)", floatround(g_fDamage[g_iBestDefIndex]))
			}
			else
			{
				set_hudmessage(random(256), random(256), random(256), -1.0, 0.3, 2, 3.0, 5.0)
				show_hudmessage(id, "Your Damage %d, You need %d Damage To be Best Defender.", floatround(g_fDamage[id]), floatround(g_fDamage[g_iBestDefIndex] - g_fDamage[id]))
			}
		}
		case 3:
		{
			if (id == g_iBestDefIndex)
			{
				set_dhudmessage(random(256), random(256), random(256), -1.0, 0.3, 2, 3.0, 5.0)
				show_dhudmessage(id, "You are now Best Defender [%d] :)", floatround(g_fDamage[g_iBestDefIndex]))
			}
			else
			{
				set_dhudmessage(random(256), random(256), random(256), -1.0, 0.3, 2, 3.0, 5.0)
				show_dhudmessage(id, "Your Damage %d, You need %d Damage To be Best Defender.", floatround(g_fDamage[id]), floatround(g_fDamage[g_iBestDefIndex] - g_fDamage[id]))
			}
		}
	}
}

public Fw_PlayerSpawn_Post(id)
{
	if (get_pcvar_num(cvar_show_chat_notice) != 0)
	{
		new szName[32]
		get_user_name(g_iBestDefIndex, szName, charsmax(szName))
		
		if (g_iBestDefIndex == 0 || g_fDamage[g_iBestDefIndex] == 0.0)
			return
		
		ze_colored_print(id, "!tBest Defender: !g%s. !tDamage: !g%i. !tAwards: !g%d XP, %d EC!y.", szName, floatround(g_fDamage[g_iBestDefIndex]), get_pcvar_num(cvar_give_xp), get_pcvar_num(cvar_give_escape_coins))
	}
	
	if (get_pcvar_num(cvar_give_xp) != 0 || get_pcvar_num(cvar_give_escape_coins) != 0)
	{
		if (g_iBestDefIndex == 0 || g_iBestDefIndex != id || g_fDamage[g_iBestDefIndex] == 0.0)
			return
		
		ze_set_escape_coins(g_iBestDefIndex, get_pcvar_num(cvar_give_escape_coins) + ze_get_escape_coins(g_iBestDefIndex))
		ze_set_user_xp(g_iBestDefIndex, get_pcvar_num(cvar_give_xp) + ze_get_user_xp(g_iBestDefIndex))
	}
}

public ze_game_started()
{
	set_task(5.0, "RestDamage")
}

public RestDamage()
{
	for (new i = 1; i <= get_member_game(m_nMaxPlayers); i++)
	{
		g_fDamage[i] = 0.0
	}
}

public Get_Best_Defender()
{
	new Float:fTemp = 0.0
	
	for (new i = 1; i <= get_member_game(m_nMaxPlayers); i++)
	{
		if (!is_user_connected(i))
			continue
		
		if (g_fDamage[i] > fTemp)
		{
			fTemp = g_fDamage[i]
			g_iBestDefIndex = i
		}
	}
}
He who fails to plan is planning to fail

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

#19

Post by czirimbolo » 5 years ago

L 08/19/2018 - 18:40:10: [ZE] Invalid Player id (6)
L 08/19/2018 - 18:40:10: [AMXX] Displaying debug trace (plugin "ze_best_defender.amxx", version "1.3")
L 08/19/2018 - 18:40:10: [AMXX] Run time error 10: native error (native "ze_get_escape_coins")
L 08/19/2018 - 18:40:10: [AMXX] [0] ze_best_defender.sma::Fw_PlayerSpawn_Post (line 123)
Image

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

#20

Post by czirimbolo » 5 years ago

can you fix this? I have everyday this error couple of times
Image

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