Resolved [Compile Error]

Installation Problems Support
Post Reply
shehzad1234
Member
Member
India
Posts: 9
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 0
Contact:

[Compile Error]

#1

Post by shehzad1234 » 2 Years Ago

i m getting this error in latest amx version 1.8.3 and all includes

Error
AMX Mod X Compiler 1.8.3-dev+5123
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2013 AMX Mod X Team

D:\Steam\steamapps\common\Half-Life\cstrike\addons\amxmodx\scripting\include\amxmisc.inc(619) : error 021: symbol already defined: "register_menu"

1 Error.
Could not locate output file D:\Steam\steamapps\common\Half-Life\cstrike\addons\amxmodx\scripting\ze_level_system.amx (compile failed).

plugins code

Code: Select all

#include <zombie_escape>
#include <nvault_util>

// Defines
#define MAX_LEVEL 50
#define MAX_XP 500000
#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"

// Messages
const Float:HUD_SPECT_X = -1.0
const Float:HUD_SPECT_Y = 0.70
const Float:HUD_STATS_X = -1.0
const Float:HUD_STATS_Y = 0.90

const HUD_STATS_ZOMBIE_R = 200
const HUD_STATS_ZOMBIE_G = 220
const HUD_STATS_ZOMBIE_B = 0

const HUD_STATS_HUMAN_R = 0
const HUD_STATS_HUMAN_G = 200
const HUD_STATS_HUMAN_B = 210

const HUD_STATS_SPEC_R = 100
const HUD_STATS_SPEC_G = 100
const HUD_STATS_SPEC_B = 100

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

// Cvars
new Cvar_ZM_Infect, Cvar_Escape_Success, Cvar_Enable_DMG, Cvar_Required_DMG, 
Cvar_DMG_Award, Cvar_Start_XP, Cvar_MaxLevels_Increment, Cvar_MaxXP_FirstLevel,
Cvar_Percentage_Style, Cvar_Start_From_Zero, Cvar_Add_Commas, Cvar_Enable_Rank,
Cvar_Levels_To_Show, Cvar_Save_Time, Cvar_Level_Effects

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.6", "Raheem/JaCk")
	
	// Hook Chains
	RegisterHookChain(RG_CBasePlayer_TakeDamage, "Fw_TakeDamage_Post", 1)
	
	// Cvars
	Cvar_ZM_Infect = register_cvar("ze_zombie_infect", "3")
	Cvar_Escape_Success = register_cvar("ze_escape_success", "5")
	Cvar_Enable_DMG = register_cvar("ze_enable_dmg", "1")
	Cvar_Required_DMG = register_cvar("ze_required_dmg", "50.0")
	Cvar_DMG_Award = register_cvar("ze_dmg_award", "3")
	Cvar_Start_XP = register_cvar("ze_start_xp", "50")
	Cvar_MaxLevels_Increment = register_cvar("ze_maxlevels_increment", "2.0")
	Cvar_MaxXP_FirstLevel = register_cvar("ze_max_xp_first_level", "100")
	Cvar_Percentage_Style = register_cvar("ze_enable_percentage_style", "1")
	Cvar_Start_From_Zero = register_cvar("ze_new_level_zero_xp", "0")
	Cvar_Add_Commas = register_cvar("ze_add_commas_to_xp", "1")
	Cvar_Enable_Rank = register_cvar("ze_enable_rank_system", "1")
	Cvar_Levels_To_Show = register_cvar("ze_levels_rank_number", "10")
	Cvar_Save_Time = register_cvar("ze_save_every", "5.0")
	Cvar_Level_Effects = register_cvar("ze_level_up_effects", "1")
	
	// Commands
	register_clcmd("say /lvlrank", "Cmd_Rank")
	register_clcmd("say_team /lvlrank", "Cmd_Rank")
	register_clcmd("say /myrank", "Cmd_Stats")
	register_clcmd("say_team /myrank", "Cmd_Stats")
	
	// Messages
	g_MsgSync = CreateHudSyncObj()
	
	// Open Vaults
	g_iLevelsVaultHandle = nvault_open(g_szLevelsVault)
	g_iRanksVaultHandle = nvault_open(g_szRanksVault)
	
	if (g_iLevelsVaultHandle == INVALID_HANDLE || g_iRanksVaultHandle == INVALID_HANDLE)
	{
		set_fail_state("Error opening nVault")
	}
}

public client_putinserver(id)
{
	if(is_user_hltv(id) || is_user_bot(id))
		return

	LoadData(id)
	
	set_task(1.0, "Show_Hud", id+TASK_SHOWHUD, _, _, "b")
	set_task(get_pcvar_float(Cvar_Save_Time), "Save_Levels", id, _, _, "b")
	set_task(0.1, "Check_MaxXP", id, _, _, "b")
}

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

public plugin_end()
{
	// Closing Vaults
	nvault_close(g_iLevelsVaultHandle)
	nvault_close(g_iRanksVaultHandle)
}

public Save_Levels(id)
{
	SaveData(id)
}

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

public Show_Hud(taskid)
{	
	new iPlayer = ID_SHOWHUD
	
	if (!is_user_alive(iPlayer))
	{
		iPlayer = pev(iPlayer, pev_iuser2)
		
		if (!is_user_alive(iPlayer))
			return
	}
	
	if (get_pcvar_num(Cvar_Percentage_Style) != 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 | XP: %0.2f %", g_iLevel[iPlayer], (float(g_iXP[iPlayer])/float(g_iMaxXP[iPlayer])) * 100.0)
		}
		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 | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
		}
		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 | XP: %0.2f %", g_iLevel[ID_SHOWHUD], (float(g_iXP[ID_SHOWHUD])/float(g_iMaxXP[ID_SHOWHUD])) * 100.0)
		}
	}
	else
	{
		if(iPlayer != ID_SHOWHUD)
		{
			if (get_pcvar_num(Cvar_Add_Commas) == 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 | XP: %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 | XP: %d/%d", g_iLevel[iPlayer], g_iXP[iPlayer], g_iMaxXP[iPlayer])
			}	
		}
		else if (ze_is_user_zombie(iPlayer))
		{
			if (get_pcvar_num(Cvar_Add_Commas) == 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 | XP: %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 | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
			}
		}
		else
		{
			if (get_pcvar_num(Cvar_Add_Commas) == 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 | XP: %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 | XP: %d/%d", g_iLevel[ID_SHOWHUD], g_iXP[ID_SHOWHUD], g_iMaxXP[ID_SHOWHUD])
			}
		}
	}
}

public ze_roundend(WinTeam)
{
	for(new id = 1; id <= get_member_game(m_nMaxPlayers); id++)
	{
		if(!is_user_alive(id) || get_member(id, m_iTeam) == TEAM_TERRORIST)
			continue
		
		if (WinTeam == ZE_TEAM_HUMAN)
		{
			g_iXP[id] += get_pcvar_num(Cvar_Escape_Success)
			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(Cvar_Start_From_Zero) == 1)
		{
			g_iXP[id] = 0
		}
		
		new szName[32]
		g_iLevel[id] ++
		g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * get_pcvar_float(Cvar_MaxLevels_Increment))
		get_user_name(id, szName, charsmax(szName))
		ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
		
		PlaySound(id, LEVELUP)
		
		if (get_pcvar_num(Cvar_Level_Effects) != 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_iXP[iInfector] += get_pcvar_num(Cvar_ZM_Infect)
	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(Cvar_Enable_DMG))
		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(Cvar_Required_DMG))
	{
		// Give Player The Coins
		g_iXP[iAttacker] += get_pcvar_num(Cvar_DMG_Award)
		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))
	
	// 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 , 255, "%i %i %i", g_iLevel[id], g_iXP[id], g_iMaxXP[id])
	
	// Saves His Data
	if (equal(szAuthID, "STEAM_ID_LAN") || equal(szAuthID, "VALVE_ID_LAN"))
	{
		get_user_name(id, szName, charsmax(szName))
		
		nvault_set(g_iLevelsVaultHandle, szName, szData)
		
		nvault_set(g_iRanksVaultHandle, szName, szAuthID)
	}
	else
	{
		get_user_name(id, szName, charsmax(szName))
		
		nvault_set(g_iLevelsVaultHandle, szAuthID, szData)
		
		nvault_set(g_iRanksVaultHandle, szAuthID, szName)
	}
}

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
	
	if (equal(szAuthID, "STEAM_ID_LAN") || equal(szAuthID, "VALVE_ID_LAN"))
	{
		if(nvault_lookup(g_iLevelsVaultHandle, szName, szData, charsmax(szData), iTimestamp))
		{
			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)
		}
		else
		{
			g_iLevel[id] = 0
			g_iXP[id] = get_pcvar_num(Cvar_Start_XP)
			g_iMaxXP[id] = get_pcvar_num(Cvar_MaxXP_FirstLevel)
		}
	}
	else
	{
		if(nvault_lookup(g_iLevelsVaultHandle, szAuthID, szData, charsmax(szData), iTimestamp))
		{
			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)
		}
		else
		{
			g_iLevel[id] = 0
			g_iXP[id] = get_pcvar_num(Cvar_Start_XP)
			g_iMaxXP[id] = get_pcvar_num(Cvar_MaxXP_FirstLevel)
		}
	}
}

// Rank System Writen by Raheem
public Cmd_Rank(id)
{
	if (get_pcvar_num(Cvar_Enable_Rank) == 0)
		return
	
	// Open the two vaults using UTIL functions
	new iLevelsVaultHandle = nvault_util_open(g_szLevelsVault)
	new iRanksVaultHandle = nvault_util_open(g_szRanksVault)
	
	// Max elements in Levels.vault and Rank.vault (They are same)
	new iTotal = nvault_util_count(iLevelsVaultHandle)
	
	new szKey[32],	// To hold SteamID from Levels.vault
	szData[64],		// To hold Levels, XP from Levels.vault
	szKeyRank[32],	// To hold SteamID from Ranks.vault
	szDataRank[64]	// To hold Names from Ranks.vault
	
	new Array:iLevels,		// Dynamic Array to hold all Levels (szData) from Levels.vault
	Array:iXPs,				// Dynamic Array to hold all XPs (szData) from Levels.vault
	Array:szLevelsSteamIDs,	// Dynamic Array to hold all SteamIDs (szKey) from Levels.vault
	Array:szRankSteamIDs,	// Dynamic Array to hold all SteamIDs (szKeyRank) from Ranks.vault
	Array:szName			// Dynamic Array to hold all Names (szDataRank) from Ranks.vault
	
	// Useless Variables
	new szVal[64], iTimeStamp
	
	// Create Our Arrays with proper lengths [As we don't know iTotal Length so we use Dynamic]
	iLevels = ArrayCreate(32)
	iXPs = ArrayCreate(32)
	szLevelsSteamIDs = ArrayCreate(35)
	szRankSteamIDs = ArrayCreate(35)
	szName = ArrayCreate(32)
	
	// Some integer counters to be used down
	new i, j, iIndex, iShowCount = 0, iPos1 = 0, iPos2 = 0
	
	// Format motd Header
	new szMotd[1501], iLen
	
	iLen = formatex(szMotd, charsmax(szMotd), "<body bgcolor=#000000><font color=#CBA50B><h3><pre>")
	iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "%-3s %-32s %-11s %s^n", "#", "Name", "# Level", "# XP")
	
	// Loop through all elements in our Levels.vault and Rank.vault
	for(i = 0; i < iTotal; i++)
	{
		// Get SteamID from Levels.vault and save to szKey
		iPos1 = nvault_util_read(iLevelsVaultHandle, iPos1, szKey, charsmax(szKey), szVal, charsmax(szVal), iTimeStamp)
		
		// Get Levels, XP for every SteamID from Levels.vault and save to szData
		nvault_lookup(g_iLevelsVaultHandle, szKey, szData, charsmax(szData), iTimeStamp)
		
		// Get SteamID from Ranks.vault and save to szKeyRank
		iPos2 = nvault_util_read(iRanksVaultHandle, iPos2, szKeyRank, charsmax(szKeyRank), szVal, charsmax(szVal), iTimeStamp)
		
		// Get Name from Ranks.vault and save to szDataRank
		nvault_lookup(g_iRanksVaultHandle, szKeyRank, szDataRank, charsmax(szDataRank), iTimeStamp)
		
		// Spliting szData to Level and XP and Save them
		new iLevel[32], iXP[32], iMaxLevel[32]
		parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
		
		// Save our Level to Dynamic Array
		ArrayPushCell(iLevels, str_to_num(iLevel))
		
		// Save our XP to Dynamic Array
		ArrayPushCell(iXPs, str_to_num(iXP))
		
		// Save SteamID comes from Levels.vault to our Dynamic Array
		ArrayPushString(szLevelsSteamIDs, szKey)
		
		// Save SteamID from Rank.vault to our Dynamic Array
		ArrayPushString(szRankSteamIDs, szKeyRank)
		
		// Save Name comes from Rank.vault to our Dynamic array
		ArrayPushString(szName, szDataRank)
	}
	
	// Loop through all elements in our Levels Dynamic Array [To Rank like 5, 4, 2, 0]
	for (i = 0; i < ArraySize(iLevels); i++)
	{
		// Every time to compare i with element down him it's i+1
		for (j = i + 1; j < ArraySize(iLevels); j++)
		{
			// The down element is higher than upper one?
			if (ArrayGetCell(iLevels, j) > ArrayGetCell(iLevels, i))
			{
				// If yes change the two elements position (j to come upper and i to be down)
				ArraySwap(iLevels, i, j);
				ArraySwap(szLevelsSteamIDs, i, j); // Change also for steam so we get ranked steam ids
				ArraySwap(iXPs, i, j); // Rank also XP
			}
			else if (ArrayGetCell(iLevels, j) == ArrayGetCell(iLevels, i)) // They are Equal?
			{
				// Rank now Depend on Who have much XP
				if (ArrayGetCell(iXPs, j) > ArrayGetCell(iXPs, i))
				{
					ArraySwap(iLevels, i, j);
					ArraySwap(szLevelsSteamIDs, i, j);
					ArraySwap(iXPs, i, j);
				}
			}
		}
	}
	
	// Loop through all elements in our vaults
	for(i = 0; i < iTotal; i++)
	{
		new szString[35];
		ArrayGetString(szLevelsSteamIDs, i, szString, charsmax(szString))
		
		// Another loop to get same SteamID from Rank.vault like one we get in szString [So we can get player name based on his steamid even if he was offline we already saved his name]
		for (j = 0; j < iTotal; j++)
		{
			// Save SteamID from Ranks.vault to szTemp
			new szTemp[35];
			ArrayGetString(szRankSteamIDs, j, szTemp, charsmax(szTemp))
			
			// Compare if the two steamids same save this index
			if (equal(szString, szTemp))
			{
				iIndex = j
				break
			}
		}
		
		// Check how much values we formated if more than our cvar break the loop
		if (iShowCount >= get_pcvar_num(Cvar_Levels_To_Show))
			break
		
		new szNameF[32]
		ArrayGetString(szName, iIndex, szNameF, charsmax(szNameF))
		
		if (equal(szNameF, "STEAM_ID_LAN") || equal(szNameF, "VALVE_ID_LAN"))
		{
			ArrayGetString(szRankSteamIDs, iIndex, szNameF, charsmax(szNameF))
		}
		else
		{
			ArrayGetString(szName, iIndex, szNameF, charsmax(szNameF))
		}
		
		for (j = 0; j < charsmax(szNameF); j++)
		{
			if (is_char_mb(szNameF[j]) > 0)
			{
				szNameF[j] = ' '
			}
		}

		// Add player information to our Motd
		iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "%-3d %-32s %-11d %d^n", i + 1, szNameF, ArrayGetCell(iLevels, i), ArrayGetCell(iXPs, i))
		
		// Increase the counter by 1
		iShowCount++
	}
	
	// Format end of motd
	iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "</body></font></h3></pre>")
	
	// Finally Show motd to the player
	show_motd(id, szMotd, "Levels Rank")
	
	// Free our memory
	ArrayDestroy(iLevels)
	ArrayDestroy(iXPs)
	ArrayDestroy(szLevelsSteamIDs)
	ArrayDestroy(szName)
	ArrayDestroy(szRankSteamIDs)
	
	// Closing UTIL Vaults
	nvault_util_close(iLevelsVaultHandle)
	nvault_util_close(iRanksVaultHandle)
}

public Cmd_Stats(id)
{
	// Open Levels vault via UTIL function
	new iLevelsVaultHandle = nvault_util_open(g_szLevelsVault)
	
	// Max elements in Levels.vault and Rank.vault (They are same)
	new iTotal = nvault_util_count(iLevelsVaultHandle)
	
	new szKey[32],	// To hold SteamID from Levels.vault
	szData[64]		// To hold Levels, XP from Levels.vault
	
	new Array:iLevels,		// Dynamic Array to hold all Levels (szData) from Levels.vault
	Array:iXPs				// Dynamic Array to hold all XPs (szData) from Levels.vault
	
	// Useless Variables
	new szVal[64], iTimeStamp
	
	// Create Our Arrays with proper lengths [As we don't iTotal Length so we use Dynamic]
	iLevels = ArrayCreate(32)
	iXPs = ArrayCreate(32)
	
	// Some integer counters to be used down
	new i, j, iPos = 0

	// Loop through all elements in our Levels.vault and Rank.vault
	for(i = 0; i < iTotal; i++)
	{
		// Get SteamID from Levels.vault and save to szKey
		iPos = nvault_util_read(iLevelsVaultHandle, iPos, szKey, charsmax(szKey), szVal, charsmax(szVal), iTimeStamp)
		
		// Get Levels, XP for every SteamID from Levels.vault and save to szData
		nvault_lookup(g_iLevelsVaultHandle, szKey, szData, charsmax(szData), iTimeStamp)

		// Spliting szData to Level and XP and Save them
		new iLevel[32], iXP[32], iMaxLevel[32]
		parse(szData, iLevel, 31, iXP, 31, iMaxLevel, 31)
		
		// Save our Level to Dynamic Array
		ArrayPushCell(iLevels, str_to_num(iLevel))
		
		// Save our XP to Dynamic Array
		ArrayPushCell(iXPs, str_to_num(iXP))
	}
	
	// Loop through all elements in our Levels Dynamic Array [To Rank like 5, 4, 2, 0]
	for (i = 0; i < ArraySize(iLevels); i++)
	{
		// Every time to compare i with element down him it's i+1
		for (j = i + 1; j < ArraySize(iLevels); j++)
		{
			// The down element is higher than upper one?
			if (ArrayGetCell(iLevels, j) > ArrayGetCell(iLevels, i))
			{
				// If yes change the two elements position (j to come upper and i to be down)
				ArraySwap(iLevels, i, j);
				ArraySwap(iXPs, i, j); // Rank also XP
			}
			else if (ArrayGetCell(iLevels, j) == ArrayGetCell(iLevels, i)) // They are Equal?
			{
				// Rank now Depend on Who have much XP
				if (ArrayGetCell(iXPs, j) > ArrayGetCell(iXPs, i))
				{
					ArraySwap(iLevels, i, j);
					ArraySwap(iXPs, i, j);
				}
			}
		}
	}
	
	new iIndex = 0;
	
	for (i = 0; i < ArraySize(iLevels); i++)
	{
		if (ArrayGetCell(iLevels, i) == g_iLevel[id] && ArrayGetCell(iXPs, i) == g_iXP[id])
		{
			iIndex = i
			break;
		}
	}
	
	ze_colored_print(id, "!tYour rank is !g%i !tof !g%i!y.", iIndex + 1, iTotal - 1)
	
	// Free our memory
	ArrayDestroy(iLevels)
	ArrayDestroy(iXPs)
	
	// Closing UTIL Vault
	nvault_util_close(iLevelsVaultHandle)
}

public native_ze_get_user_xp(id)
{
	if(!is_user_connected(id))
	{
		log_amx("[ZE] Invalid Player.")
	}
	
	return g_iXP[id]
}

public native_ze_set_user_xp(id, amount)
{
	if(!is_user_connected(id))
	{
		log_amx("[ZE] Invalid Player.")
	}
	
	g_iXP[id] = amount
	
	Check_User_Level(id)
}

public native_ze_get_user_level(id)
{
	if(!is_user_connected(id))
	{
		log_amx("[ZE] Invalid Player.")
	}
	
	return g_iLevel[id]
}

public native_ze_set_user_level(id, amount)
{
	if(!is_user_connected(id))
	{
		log_amx("[ZE] Invalid Player.")
	}
	
	g_iLevel[id] = amount
	
	if (get_pcvar_num(Cvar_Start_From_Zero) == 1)
	{
		g_iXP[id] = 0
	}
}

public native_ze_get_user_max_xp(id)
{
	if(!is_user_connected(id))
	{
		log_amx("[ZE] Invalid Player.")
	}
	
	return g_iMaxXP[id]
}

public native_ze_set_user_max_xp(id, amount)
{
	if(!is_user_connected(id))
	{
		log_amx("[ZE] Invalid Player.")
	}
	
	g_iMaxXP[id] = amount
}

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#2

Post by Raheem » 2 Years Ago

You should update your zombie_escape_stocks.inc in includes folder to latest. Download the final ZE release and then copy that file to your compiler.
You don't know? Learn and you will know.

shehzad1234
Member
Member
India
Posts: 9
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 0
Contact:

#3

Post by shehzad1234 » 2 Years Ago

can u upload include here for me please??,

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#4

Post by Raheem » 2 Years Ago

You don't know? Learn and you will know.

shehzad1234
Member
Member
India
Posts: 9
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 0
Contact:

#5

Post by shehzad1234 » 2 Years Ago

ty

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#6

Post by Raheem » 2 Years Ago

Solved, Simply use the updated compiler: viewtopic.php?f=6&p=4182
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests