Guns with Levels/XP.

Unpaid Requests, Public Plugins
Locked
neverminddw
Member
Member
Posts: 32
Joined: 3 Years Ago
Has thanked: 0
Been thanked: 2 times
Contact:

Guns with Levels/XP.

#1

Post by neverminddw » 3 Years Ago

Hi, I request a guns menu with levels.
Lv1: Famas + Usp
Lv2: Galil + 223 Compact (b-1-3)
Lv3: Aug + Dual Elites
Lv4: AK47 + Deagle
Lv5: M4A1 + Glock
Lv6: nothing new
Lv7: nothing new
Lv8: nothing new
Lv9: nothing new
Lv10: M249 + Five Seven
Lv11: nothing new
Lv12: nothing new
Lv13: nothing new
Lv14: nothing new
Lv15: P90 + no secondary new weapon
AND MAXIMUM level is 50, but from level 15 no more new weapons, only these.
Please make it work with this level plugin:

Code: Select all

#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <levels>
#include <nvault>
#include <sqlx>

#define TASK_SHOW_LEVEL 10113
#define MAXLEVEL 24

new const LEVELS[MAXLEVEL] = { 
90, // Needed on level 1
180, // Needed on level 2
300, // Needed on level 3
450, // Needed on level 4
700, // Needed on level 5
1200, // Needed on level 6
1800, // Needed on level 7
2800, // Needed on level 8
4100, // Needed on level 9
5200, // Needed on level 10
6000, // Needed on level 11
6800, // Needed on level 12
8200, // Needed on level 13
10200, // Needed on level 14
12000, // Needed on level 15
15000, // Needed on level 16
17500, // Needed on level 17
20500, // Needed on level 18
25500, // Needed on level 19
29000, // Needed on level 20
35000, // Needed on level 21
46000, // Needed on level 22
58000, // Needed on level 23
150000 // Needed on level 24
}; // Needed Xp on each Levels

new const szTables[][] = 
{
	"CREATE TABLE IF NOT EXISTS `mytable` ( `player_id` varchar(32) NOT NULL,`player_level` int(8) default NULL,`player_xp` int(16) default NULL,PRIMARY KEY (`player_id`) ) TYPE=MyISAM;"
}

new PlayerXp[33]
new PlayerLevel[33]
new Handle:g_hTuple;

new g_Vault
new g_kills[33]
new g_maxplayers, g_msgHudSync1
new savexp, save_type, xp_kill, xp_triple, enable_triple, triple_kills, xp_ultra, ultra_kills, enable_ultra, escape_xp, damage_hp, damage_xp

new mysqlx_host, mysqlx_user, mysqlx_db, mysqlx_pass

public plugin_init()
{
	register_plugin("[ZE] Levels XP", "1.0", "Raheem");

	save_type = register_cvar("levels_savetype","0"); // Save Xp to : 1 = MySQL, 0 = NVault.
	savexp = register_cvar("levels_save","2"); // Save Xp by : 2 = Name, 1 = SteamID, 0 = IP.
	xp_kill = register_cvar("levels_xp","10"); // How much xp gain if you killed someone?

	enable_triple = register_cvar("levels_triple","1"); // Enable Triple Kill bonus xp? 1 = Yes, 0 = No.
	xp_triple = register_cvar("levels_triple_xp","3"); // How much bonus xp give for Triple Kill?
	triple_kills = register_cvar("levels_triple_kills","3"); // How much kills needed to give bonus xp?
	enable_ultra = register_cvar("levels_ultra","1"); // Enable Ultra Kill bonus xp? 1 = Yes, 0 = No.
	xp_ultra = register_cvar("levels_ultra_xp","5"); // How much bonus xp give for Ultra Kill?
	ultra_kills = register_cvar("levels_ultra_kills","6"); // How much kills needed to give bonus xp?
	escape_xp = register_cvar("escape_xp_amount", "20") // How much XP given to Humans when escape success?
	damage_hp = register_cvar("required_damage_hp", "60") // The damage if the player made more than it he will awarded.
	damage_xp = register_cvar("damage_xp_amount", "2") //How much XP given to human who make damage more than damage_hp?
	

	// SQLx cvars
	mysqlx_host = register_cvar ("levels_host", ""); // The host from the db
	mysqlx_user = register_cvar ("levels_user", ""); // The username from the db login
	mysqlx_pass = register_cvar ("levels_pass", ""); // The password from the db login
	mysqlx_db = register_cvar ("levels_dbname", ""); // The database name 

	// Events
	register_event("DeathMsg", "event_deathmsg", "a");
	register_event("StatusValue", "Event_StatusValue", "bd", "1=2")
	register_event("Damage", "on_damage", "b", "2!0", "3=0", "4!0")


	// Forwards //
	RegisterHam(Ham_Spawn, "player", "fwd_PlayerSpawn", 1);

	MySQLx_Init()

	g_msgHudSync1 = CreateHudSyncObj()
	g_maxplayers = get_maxplayers();
}

public plugin_cfg()
{
	//Open our vault and have g_Vault store the handle.
	g_Vault = nvault_open( "levels" );

	//Make the plugin error if vault did not successfully open
	if ( g_Vault == INVALID_HANDLE )
		set_fail_state( "Error opening levels nVault, file does not exist!" );
}

public plugin_precache()
{
    precache_sound( "levelup_ZE/ze_levelup.wav" );
}

public plugin_natives()
{
	register_native("get_user_xp", "native_get_user_xp", 1);
	register_native("set_user_xp", "native_set_user_xp", 1);
	register_native("get_user_level", "native_get_user_level", 1);
	register_native("set_user_level", "native_set_user_level", 1);
	register_native("get_user_max_level", "native_get_user_max_level", 1);
}

public plugin_end()
{
	//Close the vault when the plugin ends (map change\server shutdown\restart)
	nvault_close( g_Vault );
}

public client_connect(id)
{
	LoadLevel(id)
}

public client_disconnect(id)
{
	SaveLevel(id)

	PlayerXp[id] = 0;
	PlayerLevel[id] = 0;

	remove_task( TASK_SHOW_LEVEL + id );
}

public fwd_PlayerSpawn(id)
{
	
	if(!is_user_alive(id))
		return;
	
	g_kills[id] = 0

	remove_task( TASK_SHOW_LEVEL + id );		

	set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)
}

public event_deathmsg()
{	
	new g_attacker = read_data(1);
	new g_victim = read_data(2);
	
	new counted_triple = get_pcvar_num(xp_kill) + get_pcvar_num(xp_triple)
	new counted_ultra = get_pcvar_num(xp_kill) + get_pcvar_num(xp_ultra)
	
	if((1 <= g_attacker <= g_maxplayers))
	{
		if(g_victim != g_attacker)
		{
			g_kills[g_attacker]++;
			if(PlayerLevel[g_attacker] < MAXLEVEL-1) 
			{

				if ( g_kills[g_attacker] == get_pcvar_num(triple_kills) && get_pcvar_num(enable_triple) )
				{
					PlayerXp[g_attacker] += counted_triple
						
					set_hudmessage(0, 40, 255, 0.50, 0.33, 1, 2.0, 8.0)
					show_hudmessage(g_attacker, "+%i Triple Kill XP!", counted_triple)
				}
				else if ( g_kills[g_attacker] == get_pcvar_num(ultra_kills) && get_pcvar_num(enable_ultra) )
				{
					PlayerXp[g_attacker] += counted_ultra
						
					set_hudmessage(255, 30, 0, 0.50, 0.33, 1, 2.0, 8.0)
					show_hudmessage(g_attacker, "+%i Ultra Kill XP!", counted_ultra)
				}
				else
				{
					PlayerXp[g_attacker] += get_pcvar_num(xp_kill)
					
					set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 8.0)
					show_hudmessage(g_attacker, "+%i XP", get_pcvar_num(xp_kill))
				}
				
				check_level(g_attacker)
			}
		}
	}
}

public ze_roundend()
{
	new Alive_Terrorists_Number = GetPlayersNum(CsTeams:CS_TEAM_T)
	new Alive_CT_Numbers = GetPlayersNum(CsTeams:CS_TEAM_CT)
	
	new iPlayers[32], iNum
	get_players(iPlayers, iNum, "ace", "CT")

	for (new i = 0; i < iNum; i++)
	{
		if(PlayerLevel[iPlayers[i]] < MAXLEVEL-1)
		{
			if((Alive_CT_Numbers > Alive_Terrorists_Number) && (Alive_Terrorists_Number == 0))
			{
				set_user_xp(iPlayers[i], get_user_xp(iPlayers[i]) + get_pcvar_num(escape_xp))
				client_print_color(iPlayers[i], "!y[!gLevel!y-!gSystem!y] !t+%i XP!y.", get_pcvar_num(escape_xp))
			}
			check_level(iPlayers[i])
		}
	}
}

public on_damage(id)
{
	static attacker,damage;
	
	attacker = get_user_attacker(id)
	damage = read_data(2)
	if(PlayerLevel[attacker] < MAXLEVEL-1)
	{
		if ((damage >= get_pcvar_num(damage_hp)) && is_user_connected(attacker) && (cs_get_user_team(attacker) == CS_TEAM_CT) && (attacker != id))
		{
			set_user_xp(attacker, get_user_xp(attacker) + get_pcvar_num(damage_xp))
			set_hudmessage(random(256), random(256), random(256), -1.0, 0.7, 1, 3.0, 8.0, 0.5, 0.5)
			show_hudmessage(attacker, "+%i XP", get_pcvar_num(damage_xp))
		}
		
		check_level(attacker)
	}
}

public Event_StatusValue(id)
{
	new target = read_data(2)
  	if(target != id && target != 0)
  	{
		static sName[32];
		get_user_name(target, sName, 31)

		set_hudmessage(0, 255, 255, -1.0, 0.3, 0, 0.0, 6.0, 0.0, 0.0, 2)
		ShowSyncHudMsg(id, g_msgHudSync1, "[Name: %s || Level: %d]", sName, PlayerLevel[target])
	}
}

public task_show_level(task)
{
	new id = task - TASK_SHOW_LEVEL
	
	if(!is_user_alive(id))
		return;
	
	set_hudmessage(0, 255, 255, 0.02, 0.05, 0, 0.0, 0.3, 0.0, 0.0)
	ShowSyncHudMsg(id, g_msgHudSync1 , "[Level : %i || XP : %i / %i]", PlayerLevel[id], PlayerXp[id], LEVELS[PlayerLevel[id]])
	
	set_task(0.1, "task_show_level", TASK_SHOW_LEVEL + id)		
}

public check_level(id)
{
	if(PlayerLevel[id] < MAXLEVEL-1)
	{
		while(PlayerXp[id] >= LEVELS[PlayerLevel[id]])
		{
			PlayerLevel[id]++;
			
			static name[32] ; get_user_name(id, name, charsmax(name));
			client_cmd(id,"spk levelup_ZE/ze_levelup.wav")
			client_print_color(0, "!y[!gLevel!y-!gSystem!y] !t%s !yReaches Level !t%i!y.", name, PlayerLevel[id]);
		}
	} 
}

public MySQLx_Init()
{
	if (!get_pcvar_num(save_type))
		return;
	
	new szHost[64], szUser[32], szPass[32], szDB[128];
	
	get_pcvar_string( mysqlx_host, szHost, charsmax( szHost ) );
	get_pcvar_string( mysqlx_user, szUser, charsmax( szUser ) );
	get_pcvar_string( mysqlx_pass, szPass, charsmax( szPass ) );
	get_pcvar_string( mysqlx_db, szDB, charsmax( szDB ) );
	
	g_hTuple = SQL_MakeDbTuple( szHost, szUser, szPass, szDB );
	
	for ( new i = 0; i < sizeof szTables; i++ )
	{
		SQL_ThreadQuery( g_hTuple, "QueryCreateTable", szTables[i])
	}
}

public QueryCreateTable( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
}

SaveLevel(id)
{ 
	new szAuth[33];
	new szKey[64];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];
	
		formatex( szData , 255 , "%i#%i#" , PlayerLevel[id], PlayerXp[id] );
		
		nvault_set( g_Vault , szKey , szData );
	}
	else
	{	
		static szQuery[ 128 ]; 

		formatex( szQuery, 127, "REPLACE INTO `mytable` (`player_id`, `player_level`, `player_xp`) VALUES ('%s', '%d', '%d');", szAuth , PlayerLevel[id], PlayerXp[id] );
		
		SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery);
	}
}

LoadLevel(id)
{
	new szAuth[33];
	new szKey[40];

	if ( get_pcvar_num(savexp) == 0 )
	{
		get_user_ip( id, szAuth , charsmax(szAuth), 1);
		formatex( szKey , 63 , "%s-IP" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 1 )
	{
		get_user_authid( id , szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-ID" , szAuth);
	}
	else if ( get_pcvar_num(savexp) == 2 )
	{
		get_user_name( id, szAuth , charsmax(szAuth) );
		formatex( szKey , 63 , "%s-NAME" , szAuth);
	}

	if ( !get_pcvar_num(save_type) )
	{
		new szData[256];

		formatex(szData , 255, "%i#%i#", PlayerLevel[id], PlayerXp[id]) 
			
		nvault_get(g_Vault, szKey, szData, 255) 

		replace_all(szData , 255, "#", " ")
		new xp[32], level[32] 
		parse(szData, level, 31, xp, 31) 
		PlayerLevel[id] = str_to_num(level)
		PlayerXp[id] = str_to_num(xp)  
	}
	else
	{
		static szQuery[ 128 ], iData[ 1 ]; 
		formatex( szQuery, 127, "SELECT `player_level`, `player_xp` FROM `mytable` WHERE ( `player_id` = '%s' );", szAuth ); 
     
		iData[ 0 ] = id;
		SQL_ThreadQuery( g_hTuple, "QuerySelectData", szQuery, iData, 1 );
	}
}

public QuerySelectData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError );
		
		return;
	} 
	else 
	{ 
		new id = iData[ 0 ];
		
		new ColLevel = SQL_FieldNameToNum(hQuery, "player_level") 
		new ColXp = SQL_FieldNameToNum(hQuery, "player_xp")
		
		while (SQL_MoreResults(hQuery)) 
		{
			PlayerLevel[id] = SQL_ReadResult(hQuery, ColLevel);
			PlayerXp[id] = SQL_ReadResult(hQuery, ColXp);
					
			SQL_NextRow(hQuery)
		}
	} 
}

public QuerySetData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) 
{ 
	if( iFailState == TQUERY_CONNECT_FAILED 
	|| iFailState == TQUERY_QUERY_FAILED ) 
	{ 
		log_amx( "%s", szError ); 
		
		return;
	} 
}

//======================Natives======================//

// Native: get_user_xp
public native_get_user_xp(id)
{
	return PlayerXp[id];
}
// Native: set_user_xp
public native_set_user_xp(id, amount)
{
	PlayerXp[id] = amount;
}
// Native: get_user_level
public native_get_user_level(id)
{
	return PlayerLevel[id];
}
// Native: set_user_xp
public native_set_user_level(id, amount)
{
	PlayerLevel[id] = amount;
}
// Native: Gets user level by Xp
public native_get_user_max_level(id)
{
	return LEVELS[PlayerLevel[id]];
}

//==================================================//

//======================STOCKS======================//

stock GetPlayersNum(CsTeams:iTeam) {
    new iNum;
    for( new i = 1; i <= get_maxplayers(); i++ ) {
        if(is_user_connected(i) && is_user_alive(i) && cs_get_user_team(i) == iTeam)
            iNum++;
    }
    return iNum;
}

stock client_print_color(const id, const input[], any:...)  
{  
    new count = 1, players[32];  
    static msg[191];  
    vformat(msg, 190, input, 3);  

    replace_all(msg, 190, "!g", "^x04"); // Green Color  
    replace_all(msg, 190, "!y", "^x01"); // Default Color  
    replace_all(msg, 190, "!t", "^x03"); // Team Color  

    if (id) players[0] = id; else get_players(players, count, "ch");  
    {  
        for (new i = 0; i < count; i++)  
        {  
            if (is_user_connected(players[i]))  
            {  
                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);  
                write_byte(players[i]);  
                write_string(msg);  
                message_end();  
            }  
        }  
    }  
}

//==================================================//

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 2031
Joined: 3 Years Ago
Location: Egypt
Has thanked: 39 times
Been thanked: 124 times
Age: 22
Contact:

#2

Post by Raheem » 3 Years Ago

Old works not supported, So if you need me to edit the Guns-XP like what you need with our current Levels-XP system ok just tell me.

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 3 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 23
Contact:

#3

Post by johnnysins2000 » 3 Years Ago

Use Zombie Escape V1.0 which is available on this forum
Then use the gun level xp system in this forum posted by Raheem

Then u can request something about that plugin here
Nobody Is That Busy If They Make Time :roll:

neverminddw
Member
Member
Posts: 32
Joined: 3 Years Ago
Has thanked: 0
Been thanked: 2 times
Contact:

#4

Post by neverminddw » 3 Years Ago

Okay, I agree.
Edit it like I said with your current Levels XP System.

User avatar
Spir0x
Veteran Member
Veteran Member
Tunisia
Posts: 640
Joined: 3 Years Ago
Location: Tunisia
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#5

Post by Spir0x » 3 Years Ago

@neverminddw bro forget it. this plugin is from old mod 2.3 not supported here, you can only use the newest levels exp by jack & updated by raheem.
I trynna make money, not friends.

Locked

Who is online

Users browsing this forum: No registered users and 8 guests