Approved Best Infector

Gameplay Addons
User avatar
sam_bhosale4
Mod Tester
Mod Tester
India
Posts: 109
Joined: 1 Year Ago
Location: INDIA
Has thanked: 5 times
Been thanked: 2 times
Age: 20
Contact:

Re: Best Infector

#11

Post by sam_bhosale4 » 1 Year Ago

Good plugins but needs some fixes raheem bro!
It Gives xp and coins even if no one infected not a single infection and shows 0 infection awards!
Please fix the values like minimum 3 or 5 infections needed for best infector otherwise it keeps giving free xp and coins!
thanks!
-=SeRious-GaminG|Zombie Escape[Alien vs. Predator]|Asia=-
206.189.132.169:40000
Image

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1720
Joined: 1 Year Ago
Location: Egypt
Has thanked: 28 times
Been thanked: 78 times
Age: 21
Contact:

#12

Post by Raheem » 1 Year Ago

To stop giving rewards if the infections == 0 or <= Anynumber just change:
  • Code: Select all

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

    	if (get_pcvar_num(cvar_give_xp) != 0 || get_pcvar_num(cvar_give_escape_coins) != 0)
    	{
    		if (iBestInfecIndex == 0 || iBestInfecIndex != id || g_iKills[id] <= 0)
    			return
    		
    		ze_set_escape_coins(iBestInfecIndex, get_pcvar_num(cvar_give_escape_coins) + ze_get_escape_coins(iBestInfecIndex))
    		ze_set_user_xp(iBestInfecIndex, get_pcvar_num(cvar_give_xp) + ze_get_user_xp(iBestInfecIndex))
    	}
-g_iKills[id] <= 0 Chage the 0 to any value you need. If you need it 1 then: g_iKills[id] <= 1 and so on.
You don't know? Learn and you will know.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1720
Joined: 1 Year Ago
Location: Egypt
Has thanked: 28 times
Been thanked: 78 times
Age: 21
Contact:

#13

Post by Raheem » 1 Year Ago

Version 1.2 Out.
You don't know? Learn and you will know.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1720
Joined: 1 Year Ago
Location: Egypt
Has thanked: 28 times
Been thanked: 78 times
Age: 21
Contact:

#14

Post by Raheem » 1 Year Ago

New version released. Some important fixes inserted. Please if you run this plugin to update it.
You don't know? Learn and you will know.

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 441
Joined: 1 Year Ago
Has thanked: 17 times
Been thanked: 1 time
Contact:

#15

Post by czirimbolo » 2 Months Ago

I got every day this error. Jack, can you fix it?

L 11/06/2018 - 07:19:20: [ZE] Invalid Player id (2)
L 11/06/2018 - 07:19:20: [AMXX] Displaying debug trace (plugin "ze_best_infector.amxx", version "1.3")
L 11/06/2018 - 07:19:20: [AMXX] Run time error 10: native error (native "ze_get_escape_coins")
L 11/06/2018 - 07:19:20: [AMXX] [0] ze_best_infector.sma::Fw_PlayerSpawn_Post (line 121)

Code: Select all

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

// Variables
new g_iKills[33], g_iBestInfecIndex

// Cvars
new cvar_give_multijump, cvar_show_chat_notice, cvar_give_xp, cvar_give_escape_coins, cvar_show_stats

public plugin_init()
{
	register_plugin("[ZE] Best Infector", "1.3", "Raheem")
	
	// Hook Chains
	RegisterHookChain(RG_CBasePlayer_Spawn, "Fw_PlayerSpawn_Post", 1)
	
	// Cvars
	cvar_give_multijump = register_cvar("ze_give_best_infector_multijump", "1")
	cvar_show_chat_notice = register_cvar("ze_best_infc_chat_notice", "1")
	cvar_give_xp = register_cvar("ze_best_infc_give_xp", "40")
	cvar_give_escape_coins = register_cvar("ze_best_infc_give_ec", "20")
	cvar_show_stats = register_cvar("ze_show_best_infec_stats", "1")
	
	// Commands
	register_clcmd("say /myinfects", "Cmd_BestInfectorStats")
}

public ze_roundend()
{
	Get_Best_Infector()
}

public ze_user_infected(iVictim, iInfector)
{
	if (iInfector == 0)
		return

	g_iKills[iInfector]++
}

public Cmd_BestInfectorStats(id)
{
	Get_Best_Infector()
	
	switch (get_pcvar_num(cvar_show_stats))
	{
		case 1:
		{
			if (id == g_iBestInfecIndex)
			{
				ze_colored_print(id, "!tYou are now Best Infector !y[!g%d!y] !y:)", g_iKills[g_iBestInfecIndex])
			}
			else
			{
				ze_colored_print(id, "!tYour Infects !g%d!y, !tYou need !g%d !tInfects To be Best Infector!y.", g_iKills[id], g_iKills[g_iBestInfecIndex] - g_iKills[id])
			}
		}
		case 2:
		{
			if (id == g_iBestInfecIndex)
			{
				set_hudmessage(random(256), random(256), random(256), -1.0, 0.3, 2, 3.0, 5.0)
				show_hudmessage(id, "You are now Best Infector [%d] :)", g_iKills[g_iBestInfecIndex])
			}
			else
			{
				set_hudmessage(random(256), random(256), random(256), -1.0, 0.3, 2, 3.0, 5.0)
				show_hudmessage(id, "Your Infects %d, You need %d Infects To be Best Infector.", g_iKills[id], g_iKills[g_iBestInfecIndex] - g_iKills[id])
			}
		}
		case 3:
		{
			if (id == g_iBestInfecIndex)
			{
				set_dhudmessage(random(256), random(256), random(256), -1.0, 0.3, 2, 3.0, 5.0)
				show_dhudmessage(id, "You are now Best Infector [%d] :)", g_iKills[g_iBestInfecIndex])
			}
			else
			{
				set_dhudmessage(random(256), random(256), random(256), -1.0, 0.3, 2, 3.0, 5.0)
				show_dhudmessage(id, "Your Infects %d, You need %d Infects To be Best Infector.", g_iKills[id], g_iKills[g_iBestInfecIndex] - g_iKills[id])
			}
		}
	}
}

public Fw_PlayerSpawn_Post(id)
{
	if (get_pcvar_num(cvar_show_chat_notice) != 0)
	{
		if (g_iBestInfecIndex == 0 || g_iKills[g_iBestInfecIndex] == 0)
			return
		
		new szName[32]
		get_user_name(g_iBestInfecIndex, szName, charsmax(szName))
		
		if (get_pcvar_num(cvar_give_multijump) == 0)
		{
			ze_colored_print(id, "!tBest Infector: !g%s. !tInfects: !g%i. !tAwards: !g%d XP, %d EC!y.", szName, g_iKills[g_iBestInfecIndex], get_pcvar_num(cvar_give_xp), get_pcvar_num(cvar_give_escape_coins))
		}
		else
		{
			ze_colored_print(id, "!tBest Infector: !g%s. !tInfects: !g%i. !tAwards: !g%d XP, %d EC, Multi-Jump!y.", szName, g_iKills[g_iBestInfecIndex], get_pcvar_num(cvar_give_xp), get_pcvar_num(cvar_give_escape_coins))
		}
	}
	
	if (get_pcvar_num(cvar_give_multijump) != 0)
	{
		if (g_iBestInfecIndex == 0 || g_iBestInfecIndex != id || g_iKills[g_iBestInfecIndex] == 0)
			return
		
		ze_give_user_multijump(g_iBestInfecIndex)
	}
	
	if (get_pcvar_num(cvar_give_xp) != 0 || get_pcvar_num(cvar_give_escape_coins) != 0)
	{
		if (g_iBestInfecIndex == 0 || g_iBestInfecIndex != id || g_iKills[g_iBestInfecIndex] == 0)
			return
		
		ze_set_escape_coins(g_iBestInfecIndex, get_pcvar_num(cvar_give_escape_coins) + ze_get_escape_coins(g_iBestInfecIndex))
		ze_set_user_xp(g_iBestInfecIndex, get_pcvar_num(cvar_give_xp) + ze_get_user_xp(g_iBestInfecIndex))
	}
}

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

public RestKills()
{
	for (new i = 1; i <= get_member_game(m_nMaxPlayers); i++)
	{
		g_iKills[i] = 0
	}
}

public Get_Best_Infector()
{
	new iTemp = 0
	
	for (new i = 1; i <= get_member_game(m_nMaxPlayers); i++)
	{
		if (!is_user_connected(i))
			continue
		
		if (g_iKills[i] > iTemp)
		{
			iTemp = g_iKills[i]
			g_iBestInfecIndex = i
		}
	}
}
Image

User avatar
Jack GamePlay
Mod Developer
Mod Developer
Egypt
Posts: 534
Joined: 1 Year Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 42 times
Age: 19
Contact:

#16

Post by Jack GamePlay » 2 Months Ago

Try:

Code: Select all

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

// Variables
new g_iKills[33], g_iBestInfecIndex

// Cvars
new cvar_give_multijump, cvar_show_chat_notice, cvar_give_xp, cvar_give_escape_coins, cvar_show_stats

public plugin_init()
{
	register_plugin("[ZE] Best Infector", "1.3", "Raheem")
	
	// Hook Chains
	RegisterHookChain(RG_CBasePlayer_Spawn, "Fw_PlayerSpawn_Post", 1)
	
	// Cvars
	cvar_give_multijump = register_cvar("ze_give_best_infector_multijump", "1")
	cvar_show_chat_notice = register_cvar("ze_best_infc_chat_notice", "1")
	cvar_give_xp = register_cvar("ze_best_infc_give_xp", "40")
	cvar_give_escape_coins = register_cvar("ze_best_infc_give_ec", "20")
	cvar_show_stats = register_cvar("ze_show_best_infec_stats", "1")
	
	// Commands
	register_clcmd("say /myinfects", "Cmd_BestInfectorStats")
}

public ze_roundend()
{
	Get_Best_Infector()
}

public ze_user_infected(iVictim, iInfector)
{
	if (iInfector == 0)
		return

	g_iKills[iInfector]++
}

public Cmd_BestInfectorStats(id)
{
	Get_Best_Infector()
	
	switch (get_pcvar_num(cvar_show_stats))
	{
		case 1:
		{
			if (id == g_iBestInfecIndex)
			{
				ze_colored_print(id, "!tYou are now Best Infector !y[!g%d!y] !y:)", g_iKills[g_iBestInfecIndex])
			}
			else
			{
				ze_colored_print(id, "!tYour Infects !g%d!y, !tYou need !g%d !tInfects To be Best Infector!y.", g_iKills[id], g_iKills[g_iBestInfecIndex] - g_iKills[id])
			}
		}
		case 2:
		{
			if (id == g_iBestInfecIndex)
			{
				set_hudmessage(random(256), random(256), random(256), -1.0, 0.3, 2, 3.0, 5.0)
				show_hudmessage(id, "You are now Best Infector [%d] :)", g_iKills[g_iBestInfecIndex])
			}
			else
			{
				set_hudmessage(random(256), random(256), random(256), -1.0, 0.3, 2, 3.0, 5.0)
				show_hudmessage(id, "Your Infects %d, You need %d Infects To be Best Infector.", g_iKills[id], g_iKills[g_iBestInfecIndex] - g_iKills[id])
			}
		}
		case 3:
		{
			if (id == g_iBestInfecIndex)
			{
				set_dhudmessage(random(256), random(256), random(256), -1.0, 0.3, 2, 3.0, 5.0)
				show_dhudmessage(id, "You are now Best Infector [%d] :)", g_iKills[g_iBestInfecIndex])
			}
			else
			{
				set_dhudmessage(random(256), random(256), random(256), -1.0, 0.3, 2, 3.0, 5.0)
				show_dhudmessage(id, "Your Infects %d, You need %d Infects To be Best Infector.", g_iKills[id], g_iKills[g_iBestInfecIndex] - g_iKills[id])
			}
		}
	}
}

public Fw_PlayerSpawn_Post(id)
{
	if (!is_user_connected(id))
		return
		
	if (get_pcvar_num(cvar_show_chat_notice) != 0)
	{
		if (g_iBestInfecIndex == 0 || g_iKills[g_iBestInfecIndex] == 0)
			return
		
		new szName[32]
		get_user_name(g_iBestInfecIndex, szName, charsmax(szName))
		
		if (get_pcvar_num(cvar_give_multijump) == 0)
		{
			ze_colored_print(id, "!tBest Infector: !g%s. !tInfects: !g%i. !tAwards: !g%d XP, %d EC!y.", szName, g_iKills[g_iBestInfecIndex], get_pcvar_num(cvar_give_xp), get_pcvar_num(cvar_give_escape_coins))
		}
		else
		{
			ze_colored_print(id, "!tBest Infector: !g%s. !tInfects: !g%i. !tAwards: !g%d XP, %d EC, Multi-Jump!y.", szName, g_iKills[g_iBestInfecIndex], get_pcvar_num(cvar_give_xp), get_pcvar_num(cvar_give_escape_coins))
		}
	}
	
	if (get_pcvar_num(cvar_give_multijump) != 0)
	{
		if (g_iBestInfecIndex == 0 || g_iBestInfecIndex != id || g_iKills[g_iBestInfecIndex] == 0)
			return
		
		ze_give_user_multijump(g_iBestInfecIndex)
	}
	
	if (get_pcvar_num(cvar_give_xp) != 0 || get_pcvar_num(cvar_give_escape_coins) != 0)
	{
		if (g_iBestInfecIndex == 0 || g_iBestInfecIndex != id || g_iKills[g_iBestInfecIndex] == 0)
			return
		
		ze_set_escape_coins(g_iBestInfecIndex, get_pcvar_num(cvar_give_escape_coins) + ze_get_escape_coins(g_iBestInfecIndex))
		ze_set_user_xp(g_iBestInfecIndex, get_pcvar_num(cvar_give_xp) + ze_get_user_xp(g_iBestInfecIndex))
	}
}

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

public RestKills()
{
	for (new i = 1; i <= get_member_game(m_nMaxPlayers); i++)
	{
		g_iKills[i] = 0
	}
}

public Get_Best_Infector()
{
	new iTemp = 0
	
	for (new i = 1; i <= get_member_game(m_nMaxPlayers); i++)
	{
		if (!is_user_connected(i))
			continue
		
		if (g_iKills[i] > iTemp)
		{
			iTemp = g_iKills[i]
			g_iBestInfecIndex = i
		}
	}
}
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest