Resolved Problem

Unpaid Requests, Public Plugins
Post Reply
User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 187
Joined: 2 Years Ago
Has thanked: 14 times
Been thanked: 7 times
Age: 19
Contact:

Problem

#1

Post by sPe3doN » 1 Month Ago

hi all :)
i have problem on this can anyone fix it
Image
Code:

Code: Select all

#include <zombie_escape>

// Defines
#define MAX_LEVEL 60
#define MAX_XP 50000
#define TASK_SHOWHUD 2020
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
#define LEVELUP "levelup_ZE/ze_levelup.wav"

// Constants
new const g_szLevelsVault[] = "Levels"
new const g_szRanksVault[] = "Ranks"
new g_iKills[33]
new Float:g_fDamage[33]

// Messages
const Float:HUD_SPECT_X = 0.015
const Float:HUD_SPECT_Y = 0.16
const Float:HUD_STATS_X = 0.015
const Float:HUD_STATS_Y = 0.16

const HUD_STATS_ZOMBIE_R = 0
const HUD_STATS_ZOMBIE_G = 250
const HUD_STATS_ZOMBIE_B = 0

const HUD_STATS_HUMAN_R = 0
const HUD_STATS_HUMAN_G = 250
const HUD_STATS_HUMAN_B = 0

const HUD_STATS_SPEC_R = 0
const HUD_STATS_SPEC_G = 250
const HUD_STATS_SPEC_B = 0

// Variables
new g_iLevel[33], 
	g_iXP[33], 
	g_iMaxXP[33],
	Float:g_fDamage[33],
	g_MsgSync, 
	g_iLevelsVaultHandle, 
	g_iRanksVaultHandle

// Cvars
new g_pCvarZombieInfect, 
	g_pCvarEscapeSuccess, 
	g_pCvarEnableDamage, 
	g_pCvarRequiredDamage, 
	g_pCvarDamageAward, 
	g_pCvarStartXP, 
	g_pCvarMaxLevelsIncrement, 
	g_pCvarMaxXPFirstLevel,
	g_pCvarPercentageStyle, 
	g_pCvarStartFromZero, 
	g_pCvarAddCommas, 
	g_pCvarLevelEffects

public plugin_natives()
{
	register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
	register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
	register_native("ze_get_user_level", "native_ze_get_user_level", 1)
	register_native("ze_set_user_level", "native_ze_set_user_level", 1)
	register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
	register_native("ze_set_user_max_xp", "native_ze_set_user_max_xp", 1)
}

public plugin_precache()
{
	precache_sound(LEVELUP)
}

public plugin_init()
{
	register_plugin("[ZE] Level-XP System", "1.0", "EliVvo.")
	
	// Hook Chains
	RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
	
	// Cvars
	g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "2")
	g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "10")
	g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "0")
	g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "0.0")
	g_pCvarDamageAward = register_cvar("ze_dmg_award", "0")
	g_pCvarStartXP = register_cvar("ze_start_xp", "10")
	g_pCvarMaxLevelsIncrement = register_cvar("ze_maxlevels_increment", "1.1")
	g_pCvarMaxXPFirstLevel = register_cvar("ze_max_xp_first_level", "130")
	g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "1")
	g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "1")
	g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
	g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "0")
	
	// Messages
	g_MsgSync = CreateHudSyncObj()
}

public client_putinserver(id)
{
	if(is_user_hltv(id) || is_user_bot(id))
		return
	
	// Just 1 second delay
	set_task(1.0, "DelayLoad", id)

	// Other tasks
	set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
	set_task(0.1, "Check_MaxXP", id, _, _, "b")
}

public DelayLoad(id)
{
	// Load his data
	LoadData(id)
}

public client_disconnected(id) 
{
	if(is_user_hltv(id) || is_user_bot(id))
		return
		
	remove_task(id+TASK_SHOWHUD)
	remove_task(id)
}

public Check_MaxXP(id)
{
	new iCurrentMaxXP = g_iMaxXP[id]
	
	new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)
	
	for (new i = 1; i <= g_iLevel[id]; i++)
	{
		iMaxXP = floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
	}
	
	if (iCurrentMaxXP != iMaxXP)
	{
		g_iMaxXP[id] = iMaxXP
	}
}

public Show_Hud(taskid, id)
{	
	new iPlayer = ID_SHOWHUD
	
	if (!is_user_alive(iPlayer))
	{
		iPlayer = pev(iPlayer, pev_iuser2)
		
		if (!is_user_alive(iPlayer))
			return
	}
	
	if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
	{
		if(iPlayer != ID_SHOWHUD)
		{
			set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
			ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d [%0.2f%%%/100%%%]^nExp: %d/%d", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0, g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
		}
		else if (ze_is_user_zombie(iPlayer))
		{
			set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
			ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d [%0.2f%%%/100%%%]^nExp: %d/%d^nInfect: %d", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0, g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD], g_iKills[ID_SHOWHUD])
		}
		else
		{
			set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
			ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d [%0.2f%%%/100%%%]^nExp: %d/%d^nDamage: %d", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0, g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD], floatround(g_fDamage[ID_SHOWHUD]))
		}
	}
	else
	{
		if(iPlayer != ID_SHOWHUD)
		{
			if (get_pcvar_num(g_pCvarAddCommas) == 1)
			{
				new szSpecXP[15], szSpecMaxXP[15]
				
				AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
				AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
				
				set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
			}
			else
			{
				set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
			}	
		}
		else if (ze_is_user_zombie(iPlayer))
		{
			if (get_pcvar_num(g_pCvarAddCommas) == 1)
			{
				new szZombieXP[15], szZombieMaxXP[15]
				
				AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
				AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
				
				set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
			}
			else
			{
				set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
			}
		}
		else
		{
			if (get_pcvar_num(g_pCvarAddCommas) == 1)
			{
				new szHumanXP[15], szHumanMaxXP[15]
				
				AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
				AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
				
				set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
			}
			else
			{
				set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
			}
		}
	}
}

public ze_roundend(WinTeam)
{
	if (WinTeam == ZE_TEAM_HUMAN)
	{
		for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
		{
			if (!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)
				continue
			
			g_iXP[id] += get_pcvar_num(g_pCvarEscapeSuccess)
			SaveData(id)
			Check_User_Level(id)
		}
	}
	
	remove_task(TASK_SHOWHUD)
}

public Check_User_Level(id)
{
	if(!is_user_connected(id))
		return

	if(g_iXP[id] >= g_iMaxXP[id])
	{
		if (get_pcvar_num(g_pCvarStartFromZero) == 1)
		{
			g_iXP[id] = 0
		}
		
		new szName[32]
		g_iLevel[id] ++
		g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
		get_user_name(id, szName, charsmax(szName))
		ze_colored_print(0, "!g%s !yNow in Level !g%i!y.", szName, g_iLevel[id])
		
		SaveData(id)
		
		PlaySound(id, LEVELUP)
		
		if (get_pcvar_num(g_pCvarLevelEffects) != 0)
		{
			// Screen Fade
			message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
			write_short(4096*2)
			write_short(4096*5)
			write_short(0x0001) 
			write_byte(random(256))
			write_byte(random(256))
			write_byte(random(256))
			write_byte(150)
			message_end()
			
			// Screen Shake
			message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
			write_short(255<<14)
			write_short(10<<14)
			write_short(255<<14)
			message_end()
		}
	}
}

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

	g_iKills[iInfector]++
	g_iXP[iInfector] += get_pcvar_num(g_pCvarZombieInfect)
	SaveData(iInfector)
	Check_User_Level(iInfector)
}

public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
	// Player Damage Himself
	if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
		return HC_CONTINUE
	
	// Same Team?
	if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
		return HC_CONTINUE
	
	// Store Damage For every Player
	g_fDamage[iAttacker] += fDamage
	
	// Damage Calculator Equal or Higher than needed damage
	if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
	{
		// Give Player The Coins
		g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)
		SaveData(iAttacker)
		Check_User_Level(iAttacker)
		
		// Rest The Damage Calculator
		g_fDamage[iAttacker] = 0.0
	}
	return HC_CONTINUE
}

public SaveData(id)
{
	new szAuthID[35], szName[32]
	get_user_authid(id, szAuthID, charsmax(szAuthID))
	get_user_name(id, szName, charsmax(szName))
	
	// Set Him to max if he Higher than Max Value
	if(g_iLevel[id] > MAX_LEVEL)
	{
		g_iLevel[id] = MAX_LEVEL
	}
	
	if(g_iXP[id] > MAX_XP)
	{
		g_iXP[id] = MAX_XP
	}
	
	new szData[256]
	formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])
	
	// Open the Vaults
	g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
	g_iRanksVaultHandle = nvault_open(g_szRanksVault)

	// Saves His Data
	nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
	nvault_set(g_iRanksVaultHandle, szAuthID, szName)
	
	// Close Vaults
	nvault_close(g_iLevelsVaultHandle)
	nvault_close(g_iRanksVaultHandle)
}

public LoadData(id)
{
	new szData[256], szAuthID[35], szName[32]
	
	get_user_authid(id, szAuthID, charsmax(szAuthID))
	get_user_name(id, szName, charsmax(szName))
	
	// Useless Variable
	new iTimestamp, iExists
	
	// Open the Vault
	g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
	
	iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
	
	// Close Vault
	nvault_close(g_iLevelsVaultHandle)
	
	if (!iExists)
	{
		g_iLevel[id] = 0
		g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
		g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
		SaveData(id)
	}
	else
	{
		new iLevel[32], iXP[32], iMaxLevel[32]
		parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
		
		g_iLevel[id] = str_to_num(iLevel)
		g_iXP[id] = str_to_num(iXP)
		g_iMaxXP[id] = str_to_num(iMaxLevel)
	}
}

public ze_game_started()
{
	set_task(2.0, "RestKills")
	set_task(2.0, "RestDamage")
}

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

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

public native_ze_get_user_xp(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	return g_iXP[id]
}

public native_ze_set_user_xp(id, amount)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	g_iXP[id] = amount
	
	Check_User_Level(id)
	return true;
}

public native_ze_get_user_level(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	return g_iLevel[id]
}

public native_ze_set_user_level(id, amount)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	g_iLevel[id] = amount
	
	if (get_pcvar_num(g_pCvarStartFromZero) == 1)
	{
		g_iXP[id] = 0
	}
	
	return true;
}

public native_ze_get_user_max_xp(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	return g_iMaxXP[id]
}

public native_ze_set_user_max_xp(id, amount)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	g_iMaxXP[id] = amount
	return true;
}

[ Post made via Android ]

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1873
Joined: 2 Years Ago
Location: Egypt
Has thanked: 31 times
Been thanked: 101 times
Age: 21
Contact:

#2

Post by Raheem » 1 Month Ago

Remove: new Float:g_fDamage[33]
You don't know? Learn and you will know.

User avatar
Muhammet20
Senior Member
Senior Member
Syria
Posts: 267
Joined: 10 Months Ago
Location: Turkey
Has thanked: 29 times
Been thanked: 2 times
Age: 13
Contact:

#3

Post by Muhammet20 » 2 Weeks Ago

sPe3doN wrote:
1 Month Ago
hi all :)
i have problem on this can anyone fix it
Image
Code:

Code: Select all

#include <zombie_escape>

// Defines
#define MAX_LEVEL 60
#define MAX_XP 50000
#define TASK_SHOWHUD 2020
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
#define LEVELUP "levelup_ZE/ze_levelup.wav"

// Constants
new const g_szLevelsVault[] = "Levels"
new const g_szRanksVault[] = "Ranks"
new g_iKills[33]
new Float:g_fDamage[33]

// Messages
const Float:HUD_SPECT_X = 0.015
const Float:HUD_SPECT_Y = 0.16
const Float:HUD_STATS_X = 0.015
const Float:HUD_STATS_Y = 0.16

const HUD_STATS_ZOMBIE_R = 0
const HUD_STATS_ZOMBIE_G = 250
const HUD_STATS_ZOMBIE_B = 0

const HUD_STATS_HUMAN_R = 0
const HUD_STATS_HUMAN_G = 250
const HUD_STATS_HUMAN_B = 0

const HUD_STATS_SPEC_R = 0
const HUD_STATS_SPEC_G = 250
const HUD_STATS_SPEC_B = 0

// Variables
new g_iLevel[33], 
	g_iXP[33], 
	g_iMaxXP[33],
	Float:g_fDamage[33],
	g_MsgSync, 
	g_iLevelsVaultHandle, 
	g_iRanksVaultHandle

// Cvars
new g_pCvarZombieInfect, 
	g_pCvarEscapeSuccess, 
	g_pCvarEnableDamage, 
	g_pCvarRequiredDamage, 
	g_pCvarDamageAward, 
	g_pCvarStartXP, 
	g_pCvarMaxLevelsIncrement, 
	g_pCvarMaxXPFirstLevel,
	g_pCvarPercentageStyle, 
	g_pCvarStartFromZero, 
	g_pCvarAddCommas, 
	g_pCvarLevelEffects

public plugin_natives()
{
	register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
	register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
	register_native("ze_get_user_level", "native_ze_get_user_level", 1)
	register_native("ze_set_user_level", "native_ze_set_user_level", 1)
	register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
	register_native("ze_set_user_max_xp", "native_ze_set_user_max_xp", 1)
}

public plugin_precache()
{
	precache_sound(LEVELUP)
}

public plugin_init()
{
	register_plugin("[ZE] Level-XP System", "1.0", "EliVvo.")
	
	// Hook Chains
	RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
	
	// Cvars
	g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "2")
	g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "10")
	g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "0")
	g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "0.0")
	g_pCvarDamageAward = register_cvar("ze_dmg_award", "0")
	g_pCvarStartXP = register_cvar("ze_start_xp", "10")
	g_pCvarMaxLevelsIncrement = register_cvar("ze_maxlevels_increment", "1.1")
	g_pCvarMaxXPFirstLevel = register_cvar("ze_max_xp_first_level", "130")
	g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "1")
	g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "1")
	g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
	g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "0")
	
	// Messages
	g_MsgSync = CreateHudSyncObj()
}

public client_putinserver(id)
{
	if(is_user_hltv(id) || is_user_bot(id))
		return
	
	// Just 1 second delay
	set_task(1.0, "DelayLoad", id)

	// Other tasks
	set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
	set_task(0.1, "Check_MaxXP", id, _, _, "b")
}

public DelayLoad(id)
{
	// Load his data
	LoadData(id)
}

public client_disconnected(id) 
{
	if(is_user_hltv(id) || is_user_bot(id))
		return
		
	remove_task(id+TASK_SHOWHUD)
	remove_task(id)
}

public Check_MaxXP(id)
{
	new iCurrentMaxXP = g_iMaxXP[id]
	
	new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)
	
	for (new i = 1; i <= g_iLevel[id]; i++)
	{
		iMaxXP = floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
	}
	
	if (iCurrentMaxXP != iMaxXP)
	{
		g_iMaxXP[id] = iMaxXP
	}
}

public Show_Hud(taskid, id)
{	
	new iPlayer = ID_SHOWHUD
	
	if (!is_user_alive(iPlayer))
	{
		iPlayer = pev(iPlayer, pev_iuser2)
		
		if (!is_user_alive(iPlayer))
			return
	}
	
	if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
	{
		if(iPlayer != ID_SHOWHUD)
		{
			set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
			ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d [%0.2f%%%/100%%%]^nExp: %d/%d", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0, g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
		}
		else if (ze_is_user_zombie(iPlayer))
		{
			set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
			ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d [%0.2f%%%/100%%%]^nExp: %d/%d^nInfect: %d", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0, g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD], g_iKills[ID_SHOWHUD])
		}
		else
		{
			set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
			ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d [%0.2f%%%/100%%%]^nExp: %d/%d^nDamage: %d", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0, g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD], floatround(g_fDamage[ID_SHOWHUD]))
		}
	}
	else
	{
		if(iPlayer != ID_SHOWHUD)
		{
			if (get_pcvar_num(g_pCvarAddCommas) == 1)
			{
				new szSpecXP[15], szSpecMaxXP[15]
				
				AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
				AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
				
				set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
			}
			else
			{
				set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
			}	
		}
		else if (ze_is_user_zombie(iPlayer))
		{
			if (get_pcvar_num(g_pCvarAddCommas) == 1)
			{
				new szZombieXP[15], szZombieMaxXP[15]
				
				AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
				AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
				
				set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
			}
			else
			{
				set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
			}
		}
		else
		{
			if (get_pcvar_num(g_pCvarAddCommas) == 1)
			{
				new szHumanXP[15], szHumanMaxXP[15]
				
				AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
				AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
				
				set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
			}
			else
			{
				set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
			}
		}
	}
}

public ze_roundend(WinTeam)
{
	if (WinTeam == ZE_TEAM_HUMAN)
	{
		for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
		{
			if (!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)
				continue
			
			g_iXP[id] += get_pcvar_num(g_pCvarEscapeSuccess)
			SaveData(id)
			Check_User_Level(id)
		}
	}
	
	remove_task(TASK_SHOWHUD)
}

public Check_User_Level(id)
{
	if(!is_user_connected(id))
		return

	if(g_iXP[id] >= g_iMaxXP[id])
	{
		if (get_pcvar_num(g_pCvarStartFromZero) == 1)
		{
			g_iXP[id] = 0
		}
		
		new szName[32]
		g_iLevel[id] ++
		g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
		get_user_name(id, szName, charsmax(szName))
		ze_colored_print(0, "!g%s !yNow in Level !g%i!y.", szName, g_iLevel[id])
		
		SaveData(id)
		
		PlaySound(id, LEVELUP)
		
		if (get_pcvar_num(g_pCvarLevelEffects) != 0)
		{
			// Screen Fade
			message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
			write_short(4096*2)
			write_short(4096*5)
			write_short(0x0001) 
			write_byte(random(256))
			write_byte(random(256))
			write_byte(random(256))
			write_byte(150)
			message_end()
			
			// Screen Shake
			message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
			write_short(255<<14)
			write_short(10<<14)
			write_short(255<<14)
			message_end()
		}
	}
}

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

	g_iKills[iInfector]++
	g_iXP[iInfector] += get_pcvar_num(g_pCvarZombieInfect)
	SaveData(iInfector)
	Check_User_Level(iInfector)
}

public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
	// Player Damage Himself
	if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
		return HC_CONTINUE
	
	// Same Team?
	if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
		return HC_CONTINUE
	
	// Store Damage For every Player
	g_fDamage[iAttacker] += fDamage
	
	// Damage Calculator Equal or Higher than needed damage
	if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
	{
		// Give Player The Coins
		g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)
		SaveData(iAttacker)
		Check_User_Level(iAttacker)
		
		// Rest The Damage Calculator
		g_fDamage[iAttacker] = 0.0
	}
	return HC_CONTINUE
}

public SaveData(id)
{
	new szAuthID[35], szName[32]
	get_user_authid(id, szAuthID, charsmax(szAuthID))
	get_user_name(id, szName, charsmax(szName))
	
	// Set Him to max if he Higher than Max Value
	if(g_iLevel[id] > MAX_LEVEL)
	{
		g_iLevel[id] = MAX_LEVEL
	}
	
	if(g_iXP[id] > MAX_XP)
	{
		g_iXP[id] = MAX_XP
	}
	
	new szData[256]
	formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])
	
	// Open the Vaults
	g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
	g_iRanksVaultHandle = nvault_open(g_szRanksVault)

	// Saves His Data
	nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
	nvault_set(g_iRanksVaultHandle, szAuthID, szName)
	
	// Close Vaults
	nvault_close(g_iLevelsVaultHandle)
	nvault_close(g_iRanksVaultHandle)
}

public LoadData(id)
{
	new szData[256], szAuthID[35], szName[32]
	
	get_user_authid(id, szAuthID, charsmax(szAuthID))
	get_user_name(id, szName, charsmax(szName))
	
	// Useless Variable
	new iTimestamp, iExists
	
	// Open the Vault
	g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
	
	iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
	
	// Close Vault
	nvault_close(g_iLevelsVaultHandle)
	
	if (!iExists)
	{
		g_iLevel[id] = 0
		g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
		g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
		SaveData(id)
	}
	else
	{
		new iLevel[32], iXP[32], iMaxLevel[32]
		parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
		
		g_iLevel[id] = str_to_num(iLevel)
		g_iXP[id] = str_to_num(iXP)
		g_iMaxXP[id] = str_to_num(iMaxLevel)
	}
}

public ze_game_started()
{
	set_task(2.0, "RestKills")
	set_task(2.0, "RestDamage")
}

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

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

public native_ze_get_user_xp(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	return g_iXP[id]
}

public native_ze_set_user_xp(id, amount)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	g_iXP[id] = amount
	
	Check_User_Level(id)
	return true;
}

public native_ze_get_user_level(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	return g_iLevel[id]
}

public native_ze_set_user_level(id, amount)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	g_iLevel[id] = amount
	
	if (get_pcvar_num(g_pCvarStartFromZero) == 1)
	{
		g_iXP[id] = 0
	}
	
	return true;
}

public native_ze_get_user_max_xp(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	return g_iMaxXP[id]
}

public native_ze_set_user_max_xp(id, amount)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	g_iMaxXP[id] = amount
	return true;
}
can you give me block tank guns plugin please ?
I just believe in two things , First one is who i see him in the mirror , and second one is who i don't see him in the sky.

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 187
Joined: 2 Years Ago
Has thanked: 14 times
Been thanked: 7 times
Age: 19
Contact:

#4

Post by sPe3doN » 2 Weeks Ago

Muhammet20 wrote:
2 Weeks Ago
sPe3doN wrote:
1 Month Ago
hi all :)
i have problem on this can anyone fix it
Image
Code:

Code: Select all

#include <zombie_escape>

// Defines
#define MAX_LEVEL 60
#define MAX_XP 50000
#define TASK_SHOWHUD 2020
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
#define LEVELUP "levelup_ZE/ze_levelup.wav"

// Constants
new const g_szLevelsVault[] = "Levels"
new const g_szRanksVault[] = "Ranks"
new g_iKills[33]
new Float:g_fDamage[33]

// Messages
const Float:HUD_SPECT_X = 0.015
const Float:HUD_SPECT_Y = 0.16
const Float:HUD_STATS_X = 0.015
const Float:HUD_STATS_Y = 0.16

const HUD_STATS_ZOMBIE_R = 0
const HUD_STATS_ZOMBIE_G = 250
const HUD_STATS_ZOMBIE_B = 0

const HUD_STATS_HUMAN_R = 0
const HUD_STATS_HUMAN_G = 250
const HUD_STATS_HUMAN_B = 0

const HUD_STATS_SPEC_R = 0
const HUD_STATS_SPEC_G = 250
const HUD_STATS_SPEC_B = 0

// Variables
new g_iLevel[33], 
	g_iXP[33], 
	g_iMaxXP[33],
	Float:g_fDamage[33],
	g_MsgSync, 
	g_iLevelsVaultHandle, 
	g_iRanksVaultHandle

// Cvars
new g_pCvarZombieInfect, 
	g_pCvarEscapeSuccess, 
	g_pCvarEnableDamage, 
	g_pCvarRequiredDamage, 
	g_pCvarDamageAward, 
	g_pCvarStartXP, 
	g_pCvarMaxLevelsIncrement, 
	g_pCvarMaxXPFirstLevel,
	g_pCvarPercentageStyle, 
	g_pCvarStartFromZero, 
	g_pCvarAddCommas, 
	g_pCvarLevelEffects

public plugin_natives()
{
	register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
	register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
	register_native("ze_get_user_level", "native_ze_get_user_level", 1)
	register_native("ze_set_user_level", "native_ze_set_user_level", 1)
	register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
	register_native("ze_set_user_max_xp", "native_ze_set_user_max_xp", 1)
}

public plugin_precache()
{
	precache_sound(LEVELUP)
}

public plugin_init()
{
	register_plugin("[ZE] Level-XP System", "1.0", "EliVvo.")
	
	// Hook Chains
	RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
	
	// Cvars
	g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "2")
	g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "10")
	g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "0")
	g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "0.0")
	g_pCvarDamageAward = register_cvar("ze_dmg_award", "0")
	g_pCvarStartXP = register_cvar("ze_start_xp", "10")
	g_pCvarMaxLevelsIncrement = register_cvar("ze_maxlevels_increment", "1.1")
	g_pCvarMaxXPFirstLevel = register_cvar("ze_max_xp_first_level", "130")
	g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "1")
	g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "1")
	g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
	g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "0")
	
	// Messages
	g_MsgSync = CreateHudSyncObj()
}

public client_putinserver(id)
{
	if(is_user_hltv(id) || is_user_bot(id))
		return
	
	// Just 1 second delay
	set_task(1.0, "DelayLoad", id)

	// Other tasks
	set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
	set_task(0.1, "Check_MaxXP", id, _, _, "b")
}

public DelayLoad(id)
{
	// Load his data
	LoadData(id)
}

public client_disconnected(id) 
{
	if(is_user_hltv(id) || is_user_bot(id))
		return
		
	remove_task(id+TASK_SHOWHUD)
	remove_task(id)
}

public Check_MaxXP(id)
{
	new iCurrentMaxXP = g_iMaxXP[id]
	
	new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)
	
	for (new i = 1; i <= g_iLevel[id]; i++)
	{
		iMaxXP = floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
	}
	
	if (iCurrentMaxXP != iMaxXP)
	{
		g_iMaxXP[id] = iMaxXP
	}
}

public Show_Hud(taskid, id)
{	
	new iPlayer = ID_SHOWHUD
	
	if (!is_user_alive(iPlayer))
	{
		iPlayer = pev(iPlayer, pev_iuser2)
		
		if (!is_user_alive(iPlayer))
			return
	}
	
	if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
	{
		if(iPlayer != ID_SHOWHUD)
		{
			set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
			ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d [%0.2f%%%/100%%%]^nExp: %d/%d", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0, g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
		}
		else if (ze_is_user_zombie(iPlayer))
		{
			set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
			ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d [%0.2f%%%/100%%%]^nExp: %d/%d^nInfect: %d", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0, g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD], g_iKills[ID_SHOWHUD])
		}
		else
		{
			set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
			ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d [%0.2f%%%/100%%%]^nExp: %d/%d^nDamage: %d", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0, g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD], floatround(g_fDamage[ID_SHOWHUD]))
		}
	}
	else
	{
		if(iPlayer != ID_SHOWHUD)
		{
			if (get_pcvar_num(g_pCvarAddCommas) == 1)
			{
				new szSpecXP[15], szSpecMaxXP[15]
				
				AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
				AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
				
				set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
			}
			else
			{
				set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
			}	
		}
		else if (ze_is_user_zombie(iPlayer))
		{
			if (get_pcvar_num(g_pCvarAddCommas) == 1)
			{
				new szZombieXP[15], szZombieMaxXP[15]
				
				AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
				AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
				
				set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
			}
			else
			{
				set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
			}
		}
		else
		{
			if (get_pcvar_num(g_pCvarAddCommas) == 1)
			{
				new szHumanXP[15], szHumanMaxXP[15]
				
				AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
				AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
				
				set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
			}
			else
			{
				set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
			}
		}
	}
}

public ze_roundend(WinTeam)
{
	if (WinTeam == ZE_TEAM_HUMAN)
	{
		for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
		{
			if (!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)
				continue
			
			g_iXP[id] += get_pcvar_num(g_pCvarEscapeSuccess)
			SaveData(id)
			Check_User_Level(id)
		}
	}
	
	remove_task(TASK_SHOWHUD)
}

public Check_User_Level(id)
{
	if(!is_user_connected(id))
		return

	if(g_iXP[id] >= g_iMaxXP[id])
	{
		if (get_pcvar_num(g_pCvarStartFromZero) == 1)
		{
			g_iXP[id] = 0
		}
		
		new szName[32]
		g_iLevel[id] ++
		g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
		get_user_name(id, szName, charsmax(szName))
		ze_colored_print(0, "!g%s !yNow in Level !g%i!y.", szName, g_iLevel[id])
		
		SaveData(id)
		
		PlaySound(id, LEVELUP)
		
		if (get_pcvar_num(g_pCvarLevelEffects) != 0)
		{
			// Screen Fade
			message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
			write_short(4096*2)
			write_short(4096*5)
			write_short(0x0001) 
			write_byte(random(256))
			write_byte(random(256))
			write_byte(random(256))
			write_byte(150)
			message_end()
			
			// Screen Shake
			message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
			write_short(255<<14)
			write_short(10<<14)
			write_short(255<<14)
			message_end()
		}
	}
}

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

	g_iKills[iInfector]++
	g_iXP[iInfector] += get_pcvar_num(g_pCvarZombieInfect)
	SaveData(iInfector)
	Check_User_Level(iInfector)
}

public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
	// Player Damage Himself
	if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
		return HC_CONTINUE
	
	// Same Team?
	if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
		return HC_CONTINUE
	
	// Store Damage For every Player
	g_fDamage[iAttacker] += fDamage
	
	// Damage Calculator Equal or Higher than needed damage
	if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
	{
		// Give Player The Coins
		g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)
		SaveData(iAttacker)
		Check_User_Level(iAttacker)
		
		// Rest The Damage Calculator
		g_fDamage[iAttacker] = 0.0
	}
	return HC_CONTINUE
}

public SaveData(id)
{
	new szAuthID[35], szName[32]
	get_user_authid(id, szAuthID, charsmax(szAuthID))
	get_user_name(id, szName, charsmax(szName))
	
	// Set Him to max if he Higher than Max Value
	if(g_iLevel[id] > MAX_LEVEL)
	{
		g_iLevel[id] = MAX_LEVEL
	}
	
	if(g_iXP[id] > MAX_XP)
	{
		g_iXP[id] = MAX_XP
	}
	
	new szData[256]
	formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])
	
	// Open the Vaults
	g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
	g_iRanksVaultHandle = nvault_open(g_szRanksVault)

	// Saves His Data
	nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
	nvault_set(g_iRanksVaultHandle, szAuthID, szName)
	
	// Close Vaults
	nvault_close(g_iLevelsVaultHandle)
	nvault_close(g_iRanksVaultHandle)
}

public LoadData(id)
{
	new szData[256], szAuthID[35], szName[32]
	
	get_user_authid(id, szAuthID, charsmax(szAuthID))
	get_user_name(id, szName, charsmax(szName))
	
	// Useless Variable
	new iTimestamp, iExists
	
	// Open the Vault
	g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
	
	iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
	
	// Close Vault
	nvault_close(g_iLevelsVaultHandle)
	
	if (!iExists)
	{
		g_iLevel[id] = 0
		g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
		g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
		SaveData(id)
	}
	else
	{
		new iLevel[32], iXP[32], iMaxLevel[32]
		parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
		
		g_iLevel[id] = str_to_num(iLevel)
		g_iXP[id] = str_to_num(iXP)
		g_iMaxXP[id] = str_to_num(iMaxLevel)
	}
}

public ze_game_started()
{
	set_task(2.0, "RestKills")
	set_task(2.0, "RestDamage")
}

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

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

public native_ze_get_user_xp(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	return g_iXP[id]
}

public native_ze_set_user_xp(id, amount)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	g_iXP[id] = amount
	
	Check_User_Level(id)
	return true;
}

public native_ze_get_user_level(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	return g_iLevel[id]
}

public native_ze_set_user_level(id, amount)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	g_iLevel[id] = amount
	
	if (get_pcvar_num(g_pCvarStartFromZero) == 1)
	{
		g_iXP[id] = 0
	}
	
	return true;
}

public native_ze_get_user_max_xp(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	return g_iMaxXP[id]
}

public native_ze_set_user_max_xp(id, amount)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	g_iMaxXP[id] = amount
	return true;
}
can you give me block tank guns plugin please ?

Code: Select all

#include <zombie_escape>

// Cvars
new Cvar_Tank_Use

public plugin_init()
{
	register_plugin("[ZE] Tank-Gun Control", "1.1", "Raheem")
	
	// Hams
	RegisterHam(Ham_Use, "func_tank", "Fw_UseStationaryGun_Pre", 0)
	RegisterHam(Ham_Use, "func_tankmortar", "Fw_UseStationaryGun_Pre", 0)
	RegisterHam(Ham_Use, "func_tankrocket", "Fw_UseStationaryGun_Pre", 0)
	RegisterHam(Ham_Use, "func_tanklaser", "Fw_UseStationaryGun_Pre", 0)

	// Cvars
	Cvar_Tank_Use = register_cvar("ze_tank_gun_team", "1")
}

public Fw_UseStationaryGun_Pre(iEnt, id)
{
	if (get_pcvar_num(Cvar_Tank_Use) == 0)
	{
		return HAM_SUPERCEDE
	}
	else if (get_pcvar_num(Cvar_Tank_Use) == 1)
	{
		if (ze_is_user_zombie(id))
		{
			return HAM_SUPERCEDE
		}
	}
	else if (get_pcvar_num(Cvar_Tank_Use) == 2)
	{
		if (!ze_is_user_zombie(id))
		{
			return HAM_SUPERCEDE
		}
	}
	
	return HAM_IGNORED
}
These users thanked the author sPe3doN for the post:
Muhammet20 (2 Weeks Ago)

User avatar
Muhammet20
Senior Member
Senior Member
Syria
Posts: 267
Joined: 10 Months Ago
Location: Turkey
Has thanked: 29 times
Been thanked: 2 times
Age: 13
Contact:

#5

Post by Muhammet20 » 2 Weeks Ago

sPe3doN wrote:
2 Weeks Ago
Muhammet20 wrote:
2 Weeks Ago
sPe3doN wrote:
1 Month Ago
hi all :)
i have problem on this can anyone fix it
Image
Code:

Code: Select all

#include <zombie_escape>

// Defines
#define MAX_LEVEL 60
#define MAX_XP 50000
#define TASK_SHOWHUD 2020
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
#define LEVELUP "levelup_ZE/ze_levelup.wav"

// Constants
new const g_szLevelsVault[] = "Levels"
new const g_szRanksVault[] = "Ranks"
new g_iKills[33]
new Float:g_fDamage[33]

// Messages
const Float:HUD_SPECT_X = 0.015
const Float:HUD_SPECT_Y = 0.16
const Float:HUD_STATS_X = 0.015
const Float:HUD_STATS_Y = 0.16

const HUD_STATS_ZOMBIE_R = 0
const HUD_STATS_ZOMBIE_G = 250
const HUD_STATS_ZOMBIE_B = 0

const HUD_STATS_HUMAN_R = 0
const HUD_STATS_HUMAN_G = 250
const HUD_STATS_HUMAN_B = 0

const HUD_STATS_SPEC_R = 0
const HUD_STATS_SPEC_G = 250
const HUD_STATS_SPEC_B = 0

// Variables
new g_iLevel[33], 
	g_iXP[33], 
	g_iMaxXP[33],
	Float:g_fDamage[33],
	g_MsgSync, 
	g_iLevelsVaultHandle, 
	g_iRanksVaultHandle

// Cvars
new g_pCvarZombieInfect, 
	g_pCvarEscapeSuccess, 
	g_pCvarEnableDamage, 
	g_pCvarRequiredDamage, 
	g_pCvarDamageAward, 
	g_pCvarStartXP, 
	g_pCvarMaxLevelsIncrement, 
	g_pCvarMaxXPFirstLevel,
	g_pCvarPercentageStyle, 
	g_pCvarStartFromZero, 
	g_pCvarAddCommas, 
	g_pCvarLevelEffects

public plugin_natives()
{
	register_native("ze_get_user_xp", "native_ze_get_user_xp", 1)
	register_native("ze_set_user_xp", "native_ze_set_user_xp", 1)
	register_native("ze_get_user_level", "native_ze_get_user_level", 1)
	register_native("ze_set_user_level", "native_ze_set_user_level", 1)
	register_native("ze_get_user_max_xp", "native_ze_get_user_max_xp", 1)
	register_native("ze_set_user_max_xp", "native_ze_set_user_max_xp", 1)
}

public plugin_precache()
{
	precache_sound(LEVELUP)
}

public plugin_init()
{
	register_plugin("[ZE] Level-XP System", "1.0", "EliVvo.")
	
	// Hook Chains
	RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
	
	// Cvars
	g_pCvarZombieInfect = register_cvar("ze_zombie_infect", "2")
	g_pCvarEscapeSuccess = register_cvar("ze_escape_success", "10")
	g_pCvarEnableDamage = register_cvar("ze_enable_dmg", "0")
	g_pCvarRequiredDamage = register_cvar("ze_required_dmg", "0.0")
	g_pCvarDamageAward = register_cvar("ze_dmg_award", "0")
	g_pCvarStartXP = register_cvar("ze_start_xp", "10")
	g_pCvarMaxLevelsIncrement = register_cvar("ze_maxlevels_increment", "1.1")
	g_pCvarMaxXPFirstLevel = register_cvar("ze_max_xp_first_level", "130")
	g_pCvarPercentageStyle = register_cvar("ze_enable_percentage_style", "1")
	g_pCvarStartFromZero = register_cvar("ze_new_level_zero_xp", "1")
	g_pCvarAddCommas = register_cvar("ze_add_commas_to_xp", "1")
	g_pCvarLevelEffects = register_cvar("ze_level_up_effects", "0")
	
	// Messages
	g_MsgSync = CreateHudSyncObj()
}

public client_putinserver(id)
{
	if(is_user_hltv(id) || is_user_bot(id))
		return
	
	// Just 1 second delay
	set_task(1.0, "DelayLoad", id)

	// Other tasks
	set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
	set_task(0.1, "Check_MaxXP", id, _, _, "b")
}

public DelayLoad(id)
{
	// Load his data
	LoadData(id)
}

public client_disconnected(id) 
{
	if(is_user_hltv(id) || is_user_bot(id))
		return
		
	remove_task(id+TASK_SHOWHUD)
	remove_task(id)
}

public Check_MaxXP(id)
{
	new iCurrentMaxXP = g_iMaxXP[id]
	
	new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)
	
	for (new i = 1; i <= g_iLevel[id]; i++)
	{
		iMaxXP = floatround(float(iMaxXP) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
	}
	
	if (iCurrentMaxXP != iMaxXP)
	{
		g_iMaxXP[id] = iMaxXP
	}
}

public Show_Hud(taskid, id)
{	
	new iPlayer = ID_SHOWHUD
	
	if (!is_user_alive(iPlayer))
	{
		iPlayer = pev(iPlayer, pev_iuser2)
		
		if (!is_user_alive(iPlayer))
			return
	}
	
	if (get_pcvar_num(g_pCvarPercentageStyle) != 0)
	{
		if(iPlayer != ID_SHOWHUD)
		{
			set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
			ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d [%0.2f%%%/100%%%]^nExp: %d/%d", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0, g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
		}
		else if (ze_is_user_zombie(iPlayer))
		{
			set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
			ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d [%0.2f%%%/100%%%]^nExp: %d/%d^nInfect: %d", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0, g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD], g_iKills[ID_SHOWHUD])
		}
		else
		{
			set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
			ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d [%0.2f%%%/100%%%]^nExp: %d/%d^nDamage: %d", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0, g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD], floatround(g_fDamage[ID_SHOWHUD]))
		}
	}
	else
	{
		if(iPlayer != ID_SHOWHUD)
		{
			if (get_pcvar_num(g_pCvarAddCommas) == 1)
			{
				new szSpecXP[15], szSpecMaxXP[15]
				
				AddCommas(g_iXP[iPlayer], szSpecXP, charsmax(szSpecXP))
				AddCommas(g_iMaxXP[iPlayer], szSpecMaxXP, charsmax(szSpecMaxXP))
				
				set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %s/%s", g_iLevel[iPlayer], szSpecXP, szSpecMaxXP)
			}
			else
			{
				set_hudmessage(HUD_STATS_SPEC_R, HUD_STATS_SPEC_G, HUD_STATS_SPEC_B, HUD_SPECT_X, HUD_SPECT_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
			}	
		}
		else if (ze_is_user_zombie(iPlayer))
		{
			if (get_pcvar_num(g_pCvarAddCommas) == 1)
			{
				new szZombieXP[15], szZombieMaxXP[15]
				
				AddCommas(g_iXP[ID_SHOWHUD], szZombieXP, charsmax(szZombieXP))
				AddCommas(g_iMaxXP[ID_SHOWHUD], szZombieMaxXP, charsmax(szZombieMaxXP))
				
				set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %s/%s", g_iLevel[ID_SHOWHUD], szZombieXP, szZombieMaxXP)
			}
			else
			{
				set_hudmessage(HUD_STATS_ZOMBIE_R, HUD_STATS_ZOMBIE_G, HUD_STATS_ZOMBIE_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
			}
		}
		else
		{
			if (get_pcvar_num(g_pCvarAddCommas) == 1)
			{
				new szHumanXP[15], szHumanMaxXP[15]
				
				AddCommas(g_iXP[ID_SHOWHUD], szHumanXP, charsmax(szHumanXP))
				AddCommas(g_iMaxXP[ID_SHOWHUD], szHumanMaxXP, charsmax(szHumanMaxXP))
				
				set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %s/%s", g_iLevel[ID_SHOWHUD], szHumanXP, szHumanMaxXP)
			}
			else
			{
				set_hudmessage(HUD_STATS_HUMAN_R, HUD_STATS_HUMAN_G, HUD_STATS_HUMAN_B, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync, "Level: %d | Exp: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
			}
		}
	}
}

public ze_roundend(WinTeam)
{
	if (WinTeam == ZE_TEAM_HUMAN)
	{
		for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
		{
			if (!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)
				continue
			
			g_iXP[id] += get_pcvar_num(g_pCvarEscapeSuccess)
			SaveData(id)
			Check_User_Level(id)
		}
	}
	
	remove_task(TASK_SHOWHUD)
}

public Check_User_Level(id)
{
	if(!is_user_connected(id))
		return

	if(g_iXP[id] >= g_iMaxXP[id])
	{
		if (get_pcvar_num(g_pCvarStartFromZero) == 1)
		{
			g_iXP[id] = 0
		}
		
		new szName[32]
		g_iLevel[id] ++
		g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(g_pCvarMaxLevelsIncrement))
		get_user_name(id, szName, charsmax(szName))
		ze_colored_print(0, "!g%s !yNow in Level !g%i!y.", szName, g_iLevel[id])
		
		SaveData(id)
		
		PlaySound(id, LEVELUP)
		
		if (get_pcvar_num(g_pCvarLevelEffects) != 0)
		{
			// Screen Fade
			message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
			write_short(4096*2)
			write_short(4096*5)
			write_short(0x0001) 
			write_byte(random(256))
			write_byte(random(256))
			write_byte(random(256))
			write_byte(150)
			message_end()
			
			// Screen Shake
			message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
			write_short(255<<14)
			write_short(10<<14)
			write_short(255<<14)
			message_end()
		}
	}
}

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

	g_iKills[iInfector]++
	g_iXP[iInfector] += get_pcvar_num(g_pCvarZombieInfect)
	SaveData(iInfector)
	Check_User_Level(iInfector)
}

public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
	// Player Damage Himself
	if (iVictim == iAttacker || !is_user_alive(iVictim) || !is_user_alive(iAttacker) || ze_is_user_zombie(iAttacker) || !get_pcvar_num(g_pCvarEnableDamage))
		return HC_CONTINUE
	
	// Same Team?
	if (get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))
		return HC_CONTINUE
	
	// Store Damage For every Player
	g_fDamage[iAttacker] += fDamage
	
	// Damage Calculator Equal or Higher than needed damage
	if (g_fDamage[iAttacker] >= get_pcvar_float(g_pCvarRequiredDamage))
	{
		// Give Player The Coins
		g_iXP[iAttacker] += get_pcvar_num(g_pCvarDamageAward)
		SaveData(iAttacker)
		Check_User_Level(iAttacker)
		
		// Rest The Damage Calculator
		g_fDamage[iAttacker] = 0.0
	}
	return HC_CONTINUE
}

public SaveData(id)
{
	new szAuthID[35], szName[32]
	get_user_authid(id, szAuthID, charsmax(szAuthID))
	get_user_name(id, szName, charsmax(szName))
	
	// Set Him to max if he Higher than Max Value
	if(g_iLevel[id] > MAX_LEVEL)
	{
		g_iLevel[id] = MAX_LEVEL
	}
	
	if(g_iXP[id] > MAX_XP)
	{
		g_iXP[id] = MAX_XP
	}
	
	new szData[256]
	formatex(szData , charsmax(szData), "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])
	
	// Open the Vaults
	g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
	g_iRanksVaultHandle = nvault_open(g_szRanksVault)

	// Saves His Data
	nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
	nvault_set(g_iRanksVaultHandle, szAuthID, szName)
	
	// Close Vaults
	nvault_close(g_iLevelsVaultHandle)
	nvault_close(g_iRanksVaultHandle)
}

public LoadData(id)
{
	new szData[256], szAuthID[35], szName[32]
	
	get_user_authid(id, szAuthID, charsmax(szAuthID))
	get_user_name(id, szName, charsmax(szName))
	
	// Useless Variable
	new iTimestamp, iExists
	
	// Open the Vault
	g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
	
	iExists = nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp)
	
	// Close Vault
	nvault_close(g_iLevelsVaultHandle)
	
	if (!iExists)
	{
		g_iLevel[id] = 0
		g_iXP[id] = get_pcvar_num(g_pCvarStartXP)
		g_iMaxXP[id] = get_pcvar_num(g_pCvarMaxXPFirstLevel)
		SaveData(id)
	}
	else
	{
		new iLevel[32], iXP[32], iMaxLevel[32]
		parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
		
		g_iLevel[id] = str_to_num(iLevel)
		g_iXP[id] = str_to_num(iXP)
		g_iMaxXP[id] = str_to_num(iMaxLevel)
	}
}

public ze_game_started()
{
	set_task(2.0, "RestKills")
	set_task(2.0, "RestDamage")
}

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

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

public native_ze_get_user_xp(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	return g_iXP[id]
}

public native_ze_set_user_xp(id, amount)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	g_iXP[id] = amount
	
	Check_User_Level(id)
	return true;
}

public native_ze_get_user_level(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	return g_iLevel[id]
}

public native_ze_set_user_level(id, amount)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	g_iLevel[id] = amount
	
	if (get_pcvar_num(g_pCvarStartFromZero) == 1)
	{
		g_iXP[id] = 0
	}
	
	return true;
}

public native_ze_get_user_max_xp(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	return g_iMaxXP[id]
}

public native_ze_set_user_max_xp(id, amount)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
		return false;
	}
	
	g_iMaxXP[id] = amount
	return true;
}
can you give me block tank guns plugin please ?

Code: Select all

#include <zombie_escape>

// Cvars
new Cvar_Tank_Use

public plugin_init()
{
	register_plugin("[ZE] Tank-Gun Control", "1.1", "Raheem")
	
	// Hams
	RegisterHam(Ham_Use, "func_tank", "Fw_UseStationaryGun_Pre", 0)
	RegisterHam(Ham_Use, "func_tankmortar", "Fw_UseStationaryGun_Pre", 0)
	RegisterHam(Ham_Use, "func_tankrocket", "Fw_UseStationaryGun_Pre", 0)
	RegisterHam(Ham_Use, "func_tanklaser", "Fw_UseStationaryGun_Pre", 0)

	// Cvars
	Cvar_Tank_Use = register_cvar("ze_tank_gun_team", "1")
}

public Fw_UseStationaryGun_Pre(iEnt, id)
{
	if (get_pcvar_num(Cvar_Tank_Use) == 0)
	{
		return HAM_SUPERCEDE
	}
	else if (get_pcvar_num(Cvar_Tank_Use) == 1)
	{
		if (ze_is_user_zombie(id))
		{
			return HAM_SUPERCEDE
		}
	}
	else if (get_pcvar_num(Cvar_Tank_Use) == 2)
	{
		if (!ze_is_user_zombie(id))
		{
			return HAM_SUPERCEDE
		}
	}
	
	return HAM_IGNORED
}
Thanks you man :)
I just believe in two things , First one is who i see him in the mirror , and second one is who i don't see him in the sky.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests