Raised This Month: $32 Target: $400
 8% 

Rank System Add When you are dead shows statistics


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Drirr
New Member
Join Date: Oct 2012
Old 08-14-2017 , 04:11   Rank System Add When you are dead shows statistics
Reply With Quote #1

Can anyone add when you are dead shows statistics of the players you are looking at

Code:
#include <amxmodx>
#include <fvault>
#include <cstrike>
#include <wm_play>

#define PLUGIN "XP + LEVEL + RANK SYSTEM"
#define VERSION "1.1"

#define maxranks 16
#define maxlevels 50

#define xPrefix "RANK"

#define RANKS_Noobest 0
#define RANKS_Noob 1
#define RANKS_Newbiee 2
#define RANKS_Easy 3
#define RANKS_Normal 4
#define RANKS_Hard 5
#define RANKS_Expert 6
#define RANKS_SuperExpert 7
#define RANKS_Specialist 8
#define RANKS_Leader 9
#define RANKS_Mayor 10
#define RANKS_Pro 11
#define RANKS_SuperPro 12
#define RANKS_Heroic 13
#define RANKS_God 14
#define RANKS_God2 15


new const db_save[] = "level_xp_rank"

new level[33], xp[33], rank[33], cvars[3], g_status_sync

new const xp_num[maxlevels+1] = { 15, 70, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 1650,
	1750, 1850, 1950, 2050, 2150, 2250, 2350, 2450, 2550,2650, 2750, 2850, 2950, 3050, 3150, 3250, 3350, 3450, 3550, 3650, 
3750, 3850, 3950, 4050, 4150, 4250, 4350, 4450, 4550, 4650, 4750, 5000 }

new const ranks_names[maxranks][]=
{
	"Silver I",
	"Silver II",
	"Silver III",
	"Silver IV",
	"Silver elite",
	"Silver elite master",
	"Gold nova I",
	"Gold nova II",
	"Gold nova III",
	"Gold nova master",
	"Master guardian I",
	"Master guardian II",
	"Master guardian elite",
	"Distinguished master guardian",
	"Supreme master first class",
	"THE GLOBAL ELITE"
}

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

// system of xp+lvl+rank
cvars[0] = register_cvar("rank_level_bonus", "10000") // Amount of money when passing level.
cvars[1] = register_cvar("rank_save_type", "2") // 1 - IP || 2 - Nick || 3 - SteamID


register_event("StatusValue", "showStatus", "be", "1=2", "2!0")
register_event("StatusValue", "hideStatus", "be", "1=1", "2=0")
register_event("DeathMsg", "xDeathMsg", "a", "1>0") // Used for xps and etc...

g_status_sync = CreateHudSyncObj()
}

/*----------------------------------------------------------------------------------------------------------------
-HUD OF THE GAME
----------------------------------------------------------------------------------------------------------------*/
public hud_status(id)
{
	if(!is_user_alive(id) ||  !is_user_connected(id) )
	return;
	if(level[id] >= maxlevels)
	{
		//static r, g, b; r = random_num(0, 255), g = random_num(0, 255), b = random_num(0, 255);
		set_hudmessage(0,255,0,-1.0,0.85,0, 6.0, 12.0);
		show_hudmessage(id,"Poziom: %d/%d » Ranga: %s » Postep: %d/%d", level[id], maxlevels, ranks_names[rank[id]], xp[id], xp[id])
	}
	else
	{
		set_hudmessage(0,255,0,-1.0,0.85,0, 6.0, 12.0);
		show_hudmessage(id,"Poziom: %d/%d » Ranga: %s » Postep: %d/%d", level[id], maxlevels, ranks_names[rank[id]], xp[id], xp_num[level[id]])
	}
}

/*----------------------------------------------------------------------------------------------------------------
-EVENT TO ADD XP
----------------------------------------------------------------------------------------------------------------*/
public xDeathMsg()
{	
	new id = read_data(1)
	new hs = read_data(3)
	
	xp[id]++
	
	if(hs)
		xp[id] += 3
	
	check_level(id, 1)
	save_data(id)
}

/*----------------------------------------------------------------------------------------------------------------
-CHECK LEVEL OF ADD ++
----------------------------------------------------------------------------------------------------------------*/
public check_level(id, sound)
{
	if(!is_user_connected(id)) return PLUGIN_HANDLED;
	
	new name[32]; get_user_name(id, name, 31)
	
	if(level[id] < maxlevels) 
	{		
		while(xp[id] >= xp_num[level[id]])
		{
			level[id]++
			
			if(sound)
			{
				if(level[id] == maxlevels)
				{
					client_print_color(id, "!g[%s] !yOsiagnal maxymalny poziom. Poziom maximum: !t%s!y.", xPrefix, level[id])
					client_print_color(0, "!g%s !yOsiagniety maxymalny poziom. Poziom maximum: !t%s!y.", name, level[id])
					
					client_cmd(0, "spk ambience/wolfhowl02.wav")
					
					return PLUGIN_HANDLED
				}
				
				client_print_color(0, "!g%s !ywygral!t%d !ykasy za osiagniety poziom.", name, get_pcvar_num(cvars[0]))
				cs_set_user_money(id, cs_get_user_money(id) + get_pcvar_num(cvars[0]))
				
				client_cmd(0, "spk ambience/lv_fruit1.wav")
				
				set_ranks(id)
			}
		}
	} 
	
	// Bug Preventions... (Back to top)
	if(level[id] == maxlevels && xp[id] > xp_num[level[id]-1])
	{
		xp[id] = xp_num[level[id]-1]
		save_data(id)
	}
	
	if(level[id] >= maxlevels) 
	{	
		level[id] = maxlevels
		xp[id] = xp_num[level[id]-1]
		save_data(id)
	}
	
	return PLUGIN_HANDLED
}

/*----------------------------------------------------------------------------------------------------------------
-SET THE RANK POSITION
----------------------------------------------------------------------------------------------------------------*/
public set_ranks(id)
{
	if(level[id] <= 2) rank[id] = RANKS_Noobest
	if(level[id] >= 2) rank[id] = RANKS_Noob
	if(level[id] >= 5) rank[id] = RANKS_Newbiee
	if(level[id] >= 8) rank[id] = RANKS_Easy
	if(level[id] >= 11) rank[id] = RANKS_Normal
	if(level[id] >= 14) rank[id] = RANKS_Hard
	if(level[id] >= 17) rank[id] = RANKS_Expert
	if(level[id] >= 20) rank[id] = RANKS_SuperExpert
	if(level[id] >= 23) rank[id] = RANKS_Specialist
	if(level[id] >= 26) rank[id] = RANKS_Leader
	if(level[id] >= 29) rank[id] = RANKS_Mayor
	if(level[id] >= 32) rank[id] = RANKS_Pro
	if(level[id] >= 33) rank[id] = RANKS_SuperPro
	if(level[id] >= 36) rank[id] = RANKS_Heroic
	if(level[id] >= 43) rank[id] = RANKS_God
	if(level[id] >= 48) rank[id] = RANKS_God2
}

/*----------------------------------------------------------------------------------------------------------------
-SAVE LEVEL, XP AND RANK
----------------------------------------------------------------------------------------------------------------*/
public save_data(id)
{
	if(!is_user_connected(id)) return PLUGIN_HANDLED;
	
	new auth[40], data[50]
	
	switch(get_pcvar_num(cvars[1]))
	{
		case 1: get_user_ip(id, auth, charsmax(auth), 1)
			case 2: get_user_name(id, auth, charsmax(auth))
			case 3: get_user_authid(id, auth, charsmax(auth))
		}
	
	formatex(data, charsmax(data), "%d %d", level[id], xp[id])
	
	fvault_pset_data(db_save, auth, data)
	
	return PLUGIN_HANDLED;
}

/*----------------------------------------------------------------------------------------------------------------
-LOAD DATA
----------------------------------------------------------------------------------------------------------------*/
public client_putinserver(id)
{
	new auth[40], data[50], x1[10], x2[10]
	
	switch(get_pcvar_num(cvars[1]))
	{
		case 1: get_user_ip(id, auth, charsmax(auth), 1)
			case 2: get_user_name(id, auth, charsmax(auth))
			case 3: get_user_authid(id, auth, charsmax(auth))
		}
	
	fvault_get_data(db_save, auth, data, charsmax(data))
	parse(data, x1, charsmax(x1), x2, charsmax(x2))
	
	level[id] = str_to_num(x1)
	xp[id] = str_to_num(x2)
	
	set_task(2.0, "set_ranks", id)
	check_level(id, 0)
	
	set_task(1.1, "hud_status", id, _, _, "b")
}

/*----------------------------------------------------------------------------------------------------------------
-SHOW XP BY LOOKING AT THE PERSON
----------------------------------------------------------------------------------------------------------------*/

public showStatus(id)
{
	if(!is_user_bot(id) && is_user_connected(id)) 
	{
		new name[32], pid = read_data(2)
		
		get_user_name(pid, name, 31)
		new color1 = 0, color2 = 0
		
		new xxx = get_user_team(id)
		new xxx2 = get_user_team(pid)
		
		new team1 = xxx == 1, team2 = xxx2 == 1
		
		if (team2 == 1)
			color1 = 255
		else
			color2 = 255
		
		if (team1 == team2)    // friend
		{
			set_hudmessage(color1, 50, color2, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)
			ShowSyncHudMsg(id, g_status_sync, "Nick: %s^nRanga: %s^nPoziom: %d^nPostep: %d/%d", name, ranks_names[rank[pid]], level[pid], xp[pid], xp_num[level[pid]])
		}
	}
}

public hideStatus(id)
{
	ClearSyncHud(id, g_status_sync)
}
Drirr is offline
tarkan00
Senior Member
Join Date: Jan 2017
Old 08-14-2017 , 05:03   Re: Rank System Add When you are dead shows statistics
Reply With Quote #2

Quote:
public hud_status(id)
{
if(!is_user_alive(id) || !is_user_connected(id) )
return;
change ~>

Quote:
public hud_status(id)
{
if(!is_user_connected(id) )
return;
[/QUOTE]
tarkan00 is offline
Ayman Khaled
Senior Member
Join Date: Mar 2017
Location: Palestine
Old 08-14-2017 , 05:05   Re: Rank System Add When you are dead shows statistics
Reply With Quote #3

i made a small xpmod with your req . here is example
PHP Code:
#include <fakemeta_util> 
PHP Code:
const PEV_SPEC_TARGET pev_iuser2
PHP Code:
new g_MaxClients
plugin_init --
PHP Code:
g_MaxClients get_maxplayers(); 
get spectating name ( in hud_status )
PHP Code:
new iSpecPlayer pev(idPEV_SPEC_TARGET);;  
new 
SpecName[32]
    
get_user_name(iSpecPlayerSpecNamecharsmax(SpecName)) 
in hud_status
PHP Code:
if(!(<= iSpecPlayer <= g_MaxClients)) /* this for if you are not spectating any one, it shouldn't view server name, xp, and level. */
            
return

set_dhudmessage 1061208, -1.00.206.00.5 ); 
show_dhudmessage id"[Name: %s | Level %d: %s | XP: %d/%d]"SpecNameiLevel [iSpecPlayer], RANKNAMES[iLevel[iSpecPlayer]], iExp [iSpecPlayer], LEVELS[iLevel[iSpecPlayer]]); 
__________________

Last edited by Ayman Khaled; 08-14-2017 at 05:14.
Ayman Khaled is offline
Drirr
New Member
Join Date: Oct 2012
Old 08-14-2017 , 07:25   Re: Rank System Add When you are dead shows statistics
Reply With Quote #4

Thx
Drirr is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode