Approved Levels-XP System

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


User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

#51

Post by Spir0x » 6 years ago

dude i can not compile this.. test it with compiler v1.8.2 i think i'm using old one.

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

#52

Post by Raheem » 6 years ago

He who fails to plan is planning to fail

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 641
Joined: 7 years ago
Location: Tunisia
Contact:

#53

Post by Spir0x » 6 years ago

Thanks.

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

#54

Post by Night Fury » 6 years ago

Nice job, man! :D :D
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:

#55

Post by Raheem » 6 years ago

Jack GamePlay wrote: 6 years ago Nice jop, man! :D :D
It's job bro not jop :lol: :lol:
He who fails to plan is planning to fail

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

#56

Post by Night Fury » 6 years ago

I have great news for you. :)
Me & my players still lose our levels.
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:

#57

Post by Raheem » 6 years ago

This not great news, Second rest your old levels................
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:

#58

Post by sam_bhosale4 » 6 years ago

Jack GamePlay wrote: 6 years ago I have great news for you. :)
Me & my players still lose our levels.
same happening with my server!
few steamers and many non steamers loosing their levels..its just getting reset :( fix pls!
-=SeRious-GaminG|Zombie Escape[Alien vs. Predator]|Asia=-
206.189.132.169:40000
Image

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

#59

Post by Night Fury » 6 years ago

I kindly request everyone uses this mod to try this code.

NOTE: if you're using AMXMODX v183, you're gonna get some warning but it won't cause errors.
Good luck.

Code: Select all

#include <zombie_escape>

// 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_szVaultName[] = "Levels"
new const g_szRankVaultName[] = "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

// 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.5", "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()
}

public client_putinserver(id)
{
	if(is_user_connected(id))
	{
		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_disconnect(id) 
{
	if(is_user_connected(id))
	{
		SaveData(id)
	}
	
	remove_task(id+TASK_SHOWHUD)
	remove_task(id)
}

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
	}
	
	new iRed, iGreen, iBlue
	
	if (ze_is_user_zombie(iPlayer))
	{
		iRed = HUD_STATS_ZOMBIE_R
		iGreen = HUD_STATS_ZOMBIE_G
		iBlue = HUD_STATS_ZOMBIE_B
	}
	else
	{
		iRed = HUD_STATS_HUMAN_R
		iGreen = HUD_STATS_HUMAN_G
		iBlue = HUD_STATS_HUMAN_B
	}
	
	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
		{
			set_hudmessage(iRed, iGreen, iBlue, 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 (get_pcvar_num(Cvar_Add_Commas) == 1)
			{
				new szPlayerXP[15], szPlayerMaxXP[15]
				
				AddCommas(g_iXP[ID_SHOWHUD], szPlayerXP, charsmax(szPlayerXP))
				AddCommas(g_iMaxXP[ID_SHOWHUD], szPlayerMaxXP, charsmax(szPlayerMaxXP))
				
				set_hudmessage(iRed, iGreen, iBlue, 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], szPlayerXP, szPlayerMaxXP)
			}
			else
			{
				set_hudmessage(iRed, iGreen, iBlue, 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 (WinTeam == ZE_TEAM_HUMAN)
		{
			if(!is_user_alive(id) || ze_is_user_zombie(id))
				continue
			
			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()
		}
	}
	
	// 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
	}
	
	SaveData(id)
}

public ze_user_infected(iVictim, iInfector)
{
	if (iInfector == 0 || !is_user_alive(iInfector))
		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) || !get_pcvar_num(Cvar_Enable_DMG) ||
	get_member(iAttacker, m_iTeam) == get_member(iVictim, m_iTeam))	// Same Team?
		return HC_CONTINUE
	
	if (!ze_is_user_zombie(iAttacker) && ze_is_user_zombie(iVictim))
	{
		// 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
}

LoadData(id)
{
	new szData[256], szAuthID[35]
	
	get_user_authid(id, szAuthID, sizeof(szAuthID) - 1)
	
	if (equal(szAuthID, "STEAM_ID_LAN") || equal(szAuthID, "VALVE_ID_LAN"))
		return
		
	/*{
		new szName[32]
		get_user_name(id, szName, charsmax(szName))
		
		if(fvault_get_data(g_szVaultName, szName, szData, charsmax(szData)))
		{
			new iLevel[32], iXP[32], iMaxLevel[32]
			parse(szData, iLevel, charsmax(iLevel), iXP, charsmax(iXP), iMaxLevel, charsmax(iMaxLevel))
			
			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(fvault_get_data(g_szVaultName, szAuthID, szData, sizeof(szData) - 1))
	{
		new iLevel[32], iXP[32], iMaxLevel[32]
		parse(szData, iLevel, sizeof(iLevel) - 1, iXP, sizeof(iXP) - 1, iMaxLevel, sizeof(iMaxLevel) - 1)
		
		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)
	}
	//}
}

SaveData(id)
{
	new szAuthID[35], szData[256], szName[32]
	
	get_user_authid(id, szAuthID, sizeof(szAuthID) - 1)
	get_user_name(id, szName, sizeof(szName) - 1)
	formatex(szData , sizeof(szData) - 1, "%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"))
		return
	/*{
		new szName[32]
		get_user_name(id, szName, charsmax(szName))
		fvault_set_data(g_szVaultName, szName, szData)
		
		fvault_set_data(g_szRankVaultName, szName, szAuthID)
	}
	else
	{*/
	
	fvault_set_data(g_szVaultName, szAuthID, szData)
	fvault_set_data(g_szRankVaultName, szAuthID, szName)
	//}
}

// Rank System Writen by Raheem
public Cmd_Rank(id)
{
	if (get_pcvar_num(Cvar_Enable_Rank) == 0)
		return
	
	// Max elements in Levels.txt and Rank.txt (They are same)
	new iTotal = fvault_size(g_szVaultName)
	
	new szKey[32],	// To hold SteamID from Levels.txt
	szData[64],		// To hold Levels, XP from Levels.txt
	szKeyRank[32],	// To hold SteamID from Ranks.txt
	szDataRank[64]	// To hold Names from Ranks.txt
	
	new Array:iLevels,		// Dynamic Array to hold all Levels (szData) from Levels.txt
	Array:iXPs,				// Dynamic Array to hold all XPs (szData) from Levels.txt
	Array:szLevelsSteamIDs,	// Dynamic Array to hold all SteamIDs (szKey) from Levels.txt
	Array:szRankSteamIDs,	// Dynamic Array to hold all SteamIDs (szKeyRank) from Ranks.txt
	Array:szName			// Dynamic Array to hold all Names (szDataRank) from Ranks.txt
	
	// 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
	
	// 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.txt and Rank.txt
	for(i = 0; i < iTotal; i++)
	{
		// Get SteamID from Levels.txt and save to szKey
		fvault_get_keyname(g_szVaultName, i, szKey, charsmax(szKey))
		
		// Get Levels, XP for every SteamID from Levels.txt and save to szData
		fvault_get_data(g_szVaultName, szKey, szData, charsmax(szData))
		
		// Get SteamID from Ranks.txt and save to szKeyRank
		fvault_get_keyname(g_szRankVaultName, i, szKeyRank, charsmax(szKeyRank))
		
		// Get Name from Ranks.txt and save to szDataRank
		fvault_get_data(g_szRankVaultName, szKeyRank, szDataRank, charsmax(szDataRank))
		
		// 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.txt to our Dynamic Array
		ArrayPushString(szLevelsSteamIDs, szKey)
		
		// Save SteamID from Rank.txt to our Dynamic Array
		ArrayPushString(szRankSteamIDs, szKeyRank)
		
		// Save Name comes from Rank.txt 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 texts
	for(i = 0; i < iTotal; i++)
	{
		new szString[35];
		ArrayGetString(szLevelsSteamIDs, i, szString, charsmax(szString))
		
		// Another loop to get same SteamID from Rank.txt 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.txt 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)
}

public Cmd_Stats(id)
{
	// Max elements in Levels.txt and Rank.txt (They are same)
	new iTotal = fvault_size(g_szVaultName)
	
	new szKey[32],	// To hold SteamID from Levels.txt
	szData[64]		// To hold Levels, XP from Levels.txt
	
	new Array:iLevels,		// Dynamic Array to hold all Levels (szData) from Levels.txt
	Array:iXPs				// Dynamic Array to hold all XPs (szData) from Levels.txt
	
	// 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

	// Loop through all elements in our Levels.txt and Rank.txt
	for(i = 0; i < iTotal; i++)
	{
		// Get SteamID from Levels.txt and save to szKey
		fvault_get_keyname(g_szVaultName, i, szKey, charsmax(szKey))
		
		// Get Levels, XP for every SteamID from Levels.txt and save to szData
		fvault_get_data(g_szVaultName, szKey, szData, charsmax(szData))

		// 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)
}

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_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%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 (%d).", id)
		return -1
	}
	
	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 (%d).", id)
		return false
	}
	
	g_iLevel[id] = amount
	
	if (get_pcvar_num(Cvar_Start_From_Zero) == 1)
	{
		g_iXP[id] = 0
	}
	Check_User_Level(id)
	return true
}

public native_ze_get_user_max_xp(id)
{
	if(!is_user_connected(id))
	{
		log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player (%d).", id)
		return -1
	}
	
	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 (%d).", id)
		return -1
	}
	
	g_iMaxXP[id] = amount
	Check_User_Level(id)
	return true
}
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:

#60

Post by Raheem » 6 years ago

This can't help jack... You only removed support for old protocol users..

If someone can report the problem with more details i'll be able to solve it but for now i don't know the problem. Maybe problem from fVault system so we may migrate to another system but need details about the problem.
He who fails to plan is planning to fail

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

#61

Post by Raheem » 6 years ago

As an attempt we now using nVault system instead of fVault, This generalized also in our new version 1.2

New version of Levels-System are out which uses nVault. Please report if the levels, xp still resetting or not.

Just a tip, Stick with default settings in reunion.cfg so you get best experience with our levels system. Default reunion.cfg i speak about should be:

Code: Select all

# ========================================================
# 		REUNION CONFIGURATION
# ========================================================

#
# General rule for modifying this file:
#	DONT CHANGE ANYTHING IF YOU DONT KNOW WHAT IT MEANS!
#


# ========================================================
# 		AUTHID MANAGEMENT
# ========================================================

# ClientID types (for cid_* options)
#  1: Real (or generated by HW) steam (STEAM_xx:xx:xx)
#  2: Real (or generated by HW) valve (VALVE_xx:xx:xx)
#  3: STEAM_ by IP
#  4: VALVE_ by IP
#  5: Deprecated - client will be rejected
#  6: reserved for future use
#  7: HLTV
#  8: STEAM_ID_LAN
#  9: STEAM_ID_PENDING
#  10: VALVE_ID_LAN
#  11: VALVE_ID_PENDING
#  12: STEAM_666:88:666

# Use these options to set authid's for clients

### AUTH CONTROL ###

# For Legit Steam clients (default is real STEAM_xx:xx:xx [1])
cid_Steam = 1

# Client recognized as pending when they sucessfully authorized, but did not get steam id
# REMARK: Actually, it got steamid, but it is useless (STEAM_0:0:0 for example)
# default is STEAM_ID_PENDING [9]
cid_SteamPending = 9

# for HLTV (default is HLTV [7])
cid_HLTV = 7

# for p.47 clients that do not support unique id generation (default is STEAM_ID_LAN [8])
cid_NoSteam47 = 8

# for p.48 clients that do not support unique id generation (default is VALVE_ID_LAN [10])
cid_NoSteam48 = 8

# For players having revEmu ( >= 9.74) on client-side:
# default is real STEAM_xx:xx:xx [1]
cid_RevEmu = 1

# For players having RevEmu 2013 on client-side:
# default is real STEAM_xx:xx:xx [1]
cid_RevEmu2013 = 1

# For players having SteamClient 2009 / revEmu > 9.82 on client-side:
# default is real STEAM_xx:xx:xx [1]
cid_SC2009 = 1

# For players having old revEmu on client-side:
# default is real STEAM_xx:xx:xx [1]
cid_OldRevEmu = 1

# For players having hCupa's SteamEmu on client-side:
# default is real STEAM_xx:xx:xx [1]
cid_SteamEmu = 1

# For players having AVSMP (Cracked Steam) on client-side:
# default is real STEAM_xx:xx:xx [1]
cid_AVSMP = 1

# For SETTI ServerScanner
# default is STEAM_xx:xx:xx generated by IP [3]
cid_Setti = 3

# For SXEI Clients
# default is real STEAM_xx:xx:xx [1]
cid_SXEI = 1

# For players having SmartSteamEmu > 1.2.4 on client-side:
# default is real STEAM_xx:xx:xx [1]
cid_SSE3 = 1


### AUTH SETTINGS ###

# ServerInfoAnswerType (0/1/2)
# Sets server answer type for query requests
#   0 = New style (Source Engine)
#   1 = Old Style (Fix favorites list for p.47 clients)
#   2 = Hybrid mode - Server is visible anywhere, but there are 3 packets generated for every serverinfo request
ServerInfoAnswerType = 0

# EnableSXEIdGeneration (0 / 1)
# Turns on steamid generation based on info sent by sXeI client
# Enable this ONLY if you have sXeI server installed!
EnableSXEIdGeneration = 0

# SC2009_RevCompatMode (0 / 1)
# Enable fix to make steamids generated for SC2009 compatible with revEmu
SC2009_RevCompatMode = 1

# SteamIdHashSalt (string)
# Salt string for SteamIDs hashing. Irreversibly changes SteamIDs. Applies only to SteamIDs generated by emulators.
# Should be more than 16 chars length. If string is empty, hashing is not applied.
SteamIdHashSalt = 

# SteamIdHashDProtoCompat (0 / 1)
# Use less reliable method of SteamID hashing from dproto (deprecated).
SteamIdHashDProtoCompat = 0

# EnableGenPrefix2 (0 / 1)
# Enable second prefix (0 or 1) for generated by HW authids. Reduces chance of authid collisions. Works only with configured SteamIdHashSalt.
EnableGenPrefix2 = 0

# FixBuggedQuery (0 / 1)
# Enable fix for clients with bugged serverbrowser. Prevents hanging on connect.
FixBuggedQuery = 1

# HLTVExcept_IP (ip addr)
# HLTV from this IP will be able to join the server even if cid_HLTV is set to 5 (deprecated)
HLTVExcept_IP = 127.0.0.1

# QueryFloodBanTime (1 - 60)
# Ban time in minutes for server query flooding.
QueryFloodBanTime = 10


### AUTHID PREFIXES ###

# IPGen_Prefix1 (int)
# STEAM_a:b:c
# first prefix (a) for authids generated by IP
IPGen_Prefix1 = 0

# IPGen_Prefix2 (int)
# STEAM_a:b:c
# second prefix (b) for authids generated by IP
IPGen_Prefix2 = 4

# Native_Prefix1 (int)
# STEAM_a:b:c
# first prefix (a) for authids generated by native auth method (Steam)
Native_Prefix1 = 0;

# RevEmu_Prefix1 (int)
# STEAM_a:b:c
# first prefix (a) for authids generated by Steamclient 2009
SC2009_Prefix1 = 0;

# RevEmu_Prefix1 (int)
# STEAM_a:b:c
# first prefix (a) for authids generated by RevEmu
RevEmu_Prefix1 = 1;

# RevEmu2013_Prefix1 (int)
# STEAM_a:b:c
# first prefix (a) for authids generated by RevEmu2013
RevEmu2013_Prefix1 = 1;

# OldRevEmu_Prefix1 (int)
# STEAM_a:b:c
# first prefix (a) for authids generated by old RevEmu
OldRevEmu_Prefix1 = 2;

# SteamEmu_Prefix1 (int)
# STEAM_a:b:c
# first prefix (a) for authids generated by SteamEmu
SteamEmu_Prefix1 = 3;

# SteamEmu_Prefix1 (int)
# STEAM_a:b:c
# first prefix (a) for authids assigned for AVSMP Clients (Cracked steam)
AVSMP_Prefix1 = 4;

# Setti_Prefix1 (int)
# STEAM_a:b:c
# first prefix (a) for authids assigned for Setti server scanner
Setti_Prefix1 = 5;

# SXEI_Prefix1 (int)
# STEAM_a:b:c
# first prefix (a) for authids assigned for sXeI clients
SXEI_Prefix1 = 6;

# SSE3_Prefix1 (int)
# STEAM_a:b:c
# first prefix (a) for authids assigned for SSE3
SSE3_Prefix1 = 7;

# Note that banid will use steamid WITHOUT any prefixes!


# ========================================================
# 		OTHER STUFF
# ========================================================

# LoggingMode:
#   0 = None
#   1 = Console
#   2 = Log Files
#   3 = Both
LoggingMode = 2
He who fails to plan is planning to fail

User avatar
konno
Member
Member
Brazil
Posts: 44
Joined: 6 years ago
Location: Brazil
Contact:

#62

Post by konno » 6 years ago

My players' level is zeroing when changing maps can anyone help?

User avatar
TheWhitesmith
Member
Member
Morocco
Posts: 33
Joined: 6 years ago
Location: Temara/Rabat
Contact:

#63

Post by TheWhitesmith » 6 years ago

It's a common error, try my fix.
[SYA] CSGO-Mod for CS 1.6 [ Cases/Keys/Rank ][/size]
IP: 149.202.251.74:27016

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

#64

Post by Raheem » 6 years ago

Will find time to post the Temp. Solution that working without problems.
He who fails to plan is planning to fail

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

#65

Post by Raheem » 6 years ago

Version 1.7 OUT. I Back to code after long time of stopping i start with Levels because there is some issues still not fixed in it. My main target was to fix level, xp lose issue it's Temp. fix like coins one. And second important issue was related to the Top/Rank systems that in the Level system there was a problem in the code i write the function i write to be used in comparing every player XP, Level and sorting them from high to low it was take so long time to be processed and it was stopping server for 1, 2 seconds till it's sort and if players in nVault so much it may freeze your server forever. This because i was comparing data and right way is to compare using Pointers but you know PAWN have no pointers so my method fail. I searched for another way to use and get it. Another plugin is available for Rank/Top system you can use without problems: http://escapers-zone.net/viewtopic.php?f=15&t=2053. Report any issue if you find.

Have FUN.
He who fails to plan is planning to fail

Rain1153
Senior Member
Senior Member
India
Posts: 278
Joined: 6 years ago
Contact:

#66

Post by Rain1153 » 6 years ago

The levels reset at every map change and with every download is there any fixes?
LOL

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

#67

Post by Raheem » 6 years ago

I'll give a try to fix it later.
He who fails to plan is planning to fail

xxGamerxx
Member
Member
Jordan
Posts: 13
Joined: 6 years ago
Contact:

#68

Post by xxGamerxx » 6 years ago

Does this level system have MySQL system?

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

#69

Post by Raheem » 6 years ago

xxGamerxx wrote: 6 years ago Does this level system have MySQL system?
Right now NO, But maybe in next version be added and maybe not. It uses now: nVault.
He who fails to plan is planning to fail

xxGamerxx
Member
Member
Jordan
Posts: 13
Joined: 6 years ago
Contact:

#70

Post by xxGamerxx » 6 years ago

Raheem wrote: 6 years ago
xxGamerxx wrote: 6 years ago Does this level system have MySQL system?
Right now NO, But maybe in next version be added and maybe not. It uses now: nVault.

Did you know any good tutorial for using MySQL instead of nVault? Maybe i can do it.

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