CERERE modificare plugin

Modificari necesare ale pluginurilor

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
User avatar
sssss
Utilizator neserios (tepar)
Utilizator neserios (tepar)
Posts: 108
Joined: 15 Dec 2021, 20:14
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 4 times
Been thanked: 3 times

25 Apr 2022, 09:52

pluginuri-extream/advanced-points-system-t225514.html

Am băgat acest sistem de puncte pe server, totul bine vreo 2 zile, după care s-au resetat toate punctele dintr o dată, nu erau erori în logs, am verificat tot, serverul nu a picat.. Însă să spunem ca a picat si s a restartat instant . Atunci este posibil să se fi resetat?
User avatar
N3v3rM1nd
Membru, skill +2
Membru, skill +2
Posts: 690
Joined: 06 Oct 2018, 13:41
Detinator Steam: Da
SteamID: /id/kidd0x/
Fond eXtream: 0
Location: Constangeles
Discord: kidd0x#1886
Has thanked: 111 times
Been thanked: 52 times

25 Apr 2022, 12:55

Verifica fisierul points (cel fara vreo extensie) si vezi in el
MIX-CORE Apasa aici
User avatar
sssss
Utilizator neserios (tepar)
Utilizator neserios (tepar)
Posts: 108
Joined: 15 Dec 2021, 20:14
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 4 times
Been thanked: 3 times

25 Apr 2022, 14:16

N3v3rM1nd wrote:
25 Apr 2022, 12:55
Verifica fisierul points (cel fara vreo extensie) si vezi in el
Nu înțeleg unde, are doar în configs fișierul points.cfg unde setez comenzile, și în data fișierul unde sunt salvate punctele cu extensia dat în rest nimic
User avatar
CyBer[N]eTicK
Membru, skill 0
Membru, skill 0
Posts: 90
Joined: 29 May 2020, 04:35
Detinator Steam: Da
CS Status: Citesc & Ajut | BB Force
Detinator server CS: BB.BlackGames.Ro
SteamID: CyBerNrcs
Fond eXtream: 0
Location: LocalHost
Discord: CyBer[N]eTicK#1206
Has thanked: 12 times
Been thanked: 5 times
Contact:

08 May 2022, 21:39

sssss wrote:
25 Apr 2022, 14:16
N3v3rM1nd wrote:
25 Apr 2022, 12:55
Verifica fisierul points (cel fara vreo extensie) si vezi in el
Nu înțeleg unde, are doar în configs fișierul points.cfg unde setez comenzile, și în data fișierul unde sunt salvate punctele cu extensia dat în rest nimic
Poftim

Code: Select all

/*===========================================================================================================================

				        *********************************************************
				         *********** [ Advanced Points System 1.1 ] ************
				        *********************************************************

		-------------------------
		   ---- * Description * ----
		-------------------------

			- Acest plugin este un sistem de puncte ! Ce inseamna asta? Cand faci un frag vei primi X puncte si de asemenea
		mai faci puncte si pe alte obiective !

		-------------------------
		   --- * Configuration * ---
		-------------------------

			points_show_info "0 / 1"			- 0: Afiseaza datele in HUD sub radar | 1: Afiseaza datele deasupra vietii
			points_bombevents_rewards "0 / 1"		- 0: Dezactivat | 1: Activat -> Puncte obtinute pe plantarea/dezamorsarea/explodearea bombei
			points_costonepoint	"MONEY"			- Cat sa coste un punct atunci cand il cumperi prin comanda "/buypoint"
			points_per_headshot "PUNCTE"		- Cate puncte sa primesti pe HeadShot !
			points_bomb_planted "X"			- Cate puncte sa primesti pe plantarea bombei
			points_bomb_exploded "Y"			- Cate puncte sa primesti pe explodarea bombei
			points_bomb_defused "Z"			- Cate puncte sa primesti pe dezamorsarea bombei
			points_gamename "Adv. Points System v1.1"	- Schimbi numele default( Counter-Strike ) cu altul
			points_add_newround "PUNCTE"		- Cate puncte sa primesti la fiecare runda !
			points_enable_respawn "0 / 1"		- Activeaza / Dezactiveaza respawn-ul cand victima moare doar daca are X PUNCTE
			points_for_respawn "PUNCTE"		- Cate puncte sa aiba victima ca sa poata reinvia atunci cand este omorata
			points_respawn_chance "SANSE"		- De cate sanse are nevoie victima ca sa invie atunci cand are X PUNCTE

		-------------------------
		   ----- * Modules * -----
		-------------------------

				- Hamsandwich;
			- Fakemeta;
		- Cstrike;

		-------------------------
		      --- * Credits * ---
		-------------------------

			- sDs|Aragon* - sistemul avansat de salvare al punctelor;

		-------------------------
		    --- * Changelog * ---
		-------------------------

			* v1.0:
			   - Initial release | Private | ( 15th Oct 2013 ) :D

			* v1.1:
			   - Public Source ( 13th Dec 2013 )

		-------------------------
		    --- * Update * ---
		-------------------------

				        *********************************************************
				         *********** [ Advanced Points System 1.1 ] ************
				        *********************************************************

===========================================================================================================================*/

#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < hamsandwich >
#include < CC_ColorChat >
#include < csx >
#include < cstrike >
#include < nvault >

#pragma semicolon 1

#define ADMIN_ACCESS ADMIN_RCON
#define is_user_player(%1) ( 1 <= %1 <= g_MaxPlayers )

#define PLUGIN_NAME 	"Advanced Points System"
#define PLUGIN_VERSION 	"1.1"
#define PLUGIN_AUTHOR 	"YONTU"

new const g_szTag[  ] = "Sistem puncte";
new g_Vault;

// Make files?
new const szWriteCvarsPoints[  ] = "addons/amxmodx/configs/points/points.cfg";
new const szLocationPoints[  ] = "addons/amxmodx/configs/points";

const PEV_SPEC_TARGET = pev_iuser2;

new g_iUserPoints[ 33 ];

new SyncHudMessage, g_MaxPlayers;

enum _:iCvars {

	EnableBombEvents,
	ShowType,
	CostOnePoint,
	PointsPerHS,
	PointsBombPlanted,
	PointsBombExploded,
	PointsBombDefused,
	AddPointsNewRound,
	EnableRespawn,
	PointsForRespawn,
	PointsForRespawnChance
}
;
new g_iCvar[ iCvars ];

public plugin_init( ) {

	register_plugin( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR );
	
	register_event( "DeathMsg", "event_DeathMsg", "a" );

	register_forward( FM_GetGameDescription, "GameDesc" ); 
	register_forward( FM_PlayerPreThink, "fwd_PlayerPreThink" );

	RegisterHam( Ham_Spawn, "player", "Ham_PlayerSpawned_Post", 1 );
	RegisterHam( Ham_Killed, "player", "Ham_PlayerKilled", 1 );
	
	register_clcmd( "say /cumparapuncte", "ClCmdSayBuyPoint" );
	register_clcmd( "say_team /cumparapuncte", "ClCmdSayBuyPoint" );

	register_clcmd( "say /ptop", "ClCmdSayShowAllPoints" );
	register_clcmd( "say_team /ptop", "ClCmdSayShowAllPoints" );

	register_clcmd( "say /puncte", "ClCmdSayPoints" );
	register_clcmd( "say_team /puncte", "ClCmdSayPoints" );

	register_concmd( "amx_give_points" ,"ClCmdGivePoints", ADMIN_ACCESS, "< nume / @ALL / @T / @CT > < Puncte >" );
	register_concmd( "amx_take_points", "ClCmdTakePoints", ADMIN_ACCESS, "< nume > < Puncte >" );
	register_concmd( "amx_reset_points", "ClCmdResetPoints", ADMIN_ACCESS, "< nume / @ALL >" );
	
	g_iCvar[ ShowType ] = register_cvar( "points_show_info", "0" );
	g_iCvar[ EnableBombEvents ] = register_cvar( "points_bombevents_rewards", "1" );
	g_iCvar[ CostOnePoint ] = register_cvar( "points_costonepoint", "16000" );
	g_iCvar[ PointsPerHS ] = register_cvar( "points_per_headshot", "3" );
	g_iCvar[ PointsBombPlanted ] = register_cvar( "points_bomb_planted", "1" );
	g_iCvar[ PointsBombExploded ] = register_cvar( "points_bomb_exploded", "2" );
	g_iCvar[ PointsBombDefused ] = register_cvar( "points_bomb_defused", "2" );
	g_iCvar[ PointsForRespawn ] = register_cvar( "points_for_respawn", "10000" );
	g_iCvar[ PointsForRespawnChance ] = register_cvar( "points_respawn_chance", "70" );
	g_iCvar[ EnableRespawn ] = register_cvar( "points_enable_respawn", "0" );

	SyncHudMessage = CreateHudSyncObj(  );
	g_MaxPlayers = global_get( glb_maxClients );

	g_Vault = nvault_open( "AdvPointsSystem" );
}

public plugin_precache(  ) {

	server_cmd( "exec %s", szWriteCvarsPoints );
       
	if( !dir_exists( szLocationPoints ) )
		mkdir( szLocationPoints );

	if( !file_exists( szWriteCvarsPoints ) ) {

		write_file( szWriteCvarsPoints, "// In acest fisier se afla cvar-urile legate despre puncte:");
		write_file( szWriteCvarsPoints, " ");
		write_file( szWriteCvarsPoints, "points_show_info ^"0^" // 0: Afiseaza datele in HUD sub radar | 1: Afiseaza datele deasupra vietii" );
		write_file( szWriteCvarsPoints, "points_bombevents_rewards ^"1^" // 0: Dezactivat | 1: Activat -> Puncte obtinute pe plantarea/dezamorsarea/explodearea bombei" );
		write_file( szWriteCvarsPoints, "points_costonepoint ^"16000^" // Cat sa coste un punct atunci cand il cumperi prin comanda /buypoint" );
		write_file( szWriteCvarsPoints, "points_per_headshot ^"3^" // Cate puncte sa primesti pe HeadShot !" );
		write_file( szWriteCvarsPoints, "points_bomb_planted ^"1^" // Cate puncte sa primesti pe plantarea bombei" );
		write_file( szWriteCvarsPoints, "points_bomb_exploded ^"2^" // Cate puncte sa primesti pe explodarea bombei" );
		write_file( szWriteCvarsPoints, "points_bomb_defused ^"2^" // Cate puncte sa primesti pe dezamorsarea bombei" );
		write_file( szWriteCvarsPoints, "points_enable_respawn ^"0^" // Activeaza / Dezactiveaza respawn-ul cand victima moare doar daca are X PUNCTE" );
		write_file( szWriteCvarsPoints, "points_for_respawn ^"10000^" // Cate puncte sa aiba victima ca sa poata reinvia atunci cand este omorata" );
		write_file( szWriteCvarsPoints, "points_respawn_chance ^"40^" // Cate sanse sa aiba victima ca sa poata reinvia" );
	}
}

public plugin_natives( ) {

	register_native( "get_user_points", "native_get_user_points", 1 );
	register_native( "set_user_points", "native_set_user_points", 1 );
}

public native_get_user_points( id ) {

	return g_iUserPoints[ id ];
}

public native_set_user_points( id, points ) {

	g_iUserPoints[ id ] = points;
}

public client_putinserver( id ) {

	LoadUserPoints( id );
}

public client_disconnect( id ) {

	SaveUserPoints( id );
}

public fwdPlayerPreThink( id ) {
	
	if( is_user_alive( id ) ) {
		
		new target, body; 
		get_user_aiming( id, target, body, 9999 );
		
		new CsTeams:team = cs_get_user_team( id );
		
		if( is_user_alive( target ) ) {

			if( is_user_player( target ) ) {
			
				new CsTeams:targetTeam = cs_get_user_team( target );
				
				new szName[ 32 ];
				get_user_name( target,  szName, sizeof( szName ) -1 );
							
				new sMessage[ 160 ];
				if( targetTeam == team ) {

					formatex( sMessage, sizeof( sMessage ) -1, "%s: %s^nHP: %i | Puncte: %i", is_user_vip( target ) ? "VIP" : "Friend", szName, get_user_health( target ), g_iUserPoints[ target ] );
				}

				else if( targetTeam != team && team != CS_TEAM_CT ) {

					formatex( sMessage, sizeof( sMessage ) -1, "%s: %s^nHP: %i | Puncte: %i", is_user_vip( target ) ? "VIP" : "Enemy", szName, get_user_health( target ), g_iUserPoints[ target ] );
				}
					
				if( targetTeam == CS_TEAM_CT ) {

					set_hudmessage( 0, 255, 0, -1.0, 0.6, 0, 0.0, 0.1, 0.0, 0.0, -1 );
				}

				else if( targetTeam == CS_TEAM_T ) {

					set_hudmessage( 127, 0, 0, -1.0, 0.6, 0, 0.0, 0.1, 0.0, 0.0, -1 );
				}	
				
				show_hudmessage( id, "%s",  sMessage );
			}
		}
	}
	
	return FMRES_IGNORED;
}

public event_DeathMsg( ) {

	new iKiller = read_data( 1 );
	new iVictim = read_data( 2 );
	new iHeadshot = read_data( 3 );
	
	if( !is_user_connected( iKiller ) || !is_user_connected( iVictim ) ) {

		return;
	}
	
	if( iKiller == iVictim ) {

		return;
	}
	
	if( iHeadshot ) {

		g_iUserPoints[ iKiller ] += get_pcvar_num( g_iCvar[ PointsPerHS ] );
		set_hudmessage( 0, 255, 0, 0.6, 0.7, 1, 6.0, 7.0 );
		show_hudmessage( iKiller, "+%i points", get_pcvar_num( g_iCvar[ PointsPerHS ] ) );
	}

	else {

		g_iUserPoints[ iKiller ]++;
		set_hudmessage( 0, 255, 0, 0.6, 0.7, 0, 6.0, 7.0 );
		show_hudmessage( iKiller, "+1 point" );
	}
}

public Ham_PlayerSpawned_Post( id ) {

	if( is_user_connected( id ) && is_user_alive( id ) ) {

		set_task( 1.0, "ShowHud", id, _, _, "b" );
	}
}

public Ham_PlayerKilled( iVictim, iAttacker, iShouldgib ) {

	if( get_pcvar_num( g_iCvar[ EnableRespawn ] ) == 0 || !is_user_connected( iVictim ) )
		return PLUGIN_CONTINUE;

	new iPoints = get_pcvar_num( g_iCvar[ PointsForRespawn ] );
	new iChance = random_num( 1, 100 );
	new iAccepted = get_pcvar_num( g_iCvar[ PointsForRespawnChance ] );

	if( g_iUserPoints[ iVictim ] == iPoints ) {

		if( iChance <= iAccepted ) {

			ExecuteHamB( Ham_CS_RoundRespawn, iVictim );
			ColorChat( 0, TEAM_COLOR, "^x04%s^x01 Tocmai ai fost inviat pentru ca ai avut^x03 %i^x01 sanse !", g_szTag, iChance );
		}

		if( iChance >= iAccepted ) {

			ColorChat( 0, TEAM_COLOR, "^x04%s^x01 Poate runda viitoare vei avea^x03 %i^x01 sanse pentru a putea reinvia !", g_szTag, iChance );
		}
	}

	return PLUGIN_CONTINUE;
}

public ShowHud( id ) {

	switch( get_pcvar_num( g_iCvar[ ShowType ] ) ) {

		case 0: {
	
			if( is_user_connected( id ) && is_user_alive( id ) && ( get_user_team( id ) == 1 || get_user_team( id ) == 2 ) ) {

				set_hudmessage( 0, 255, 0, 0.01, 0.23, 0, 0.5, 15.0, 2.0, 2.0, -1 );
				ShowSyncHudMsg( id, SyncHudMessage, "Puncte: %d", g_iUserPoints[ id ] );
			}

			else {

				new idSpec;
				new iPlayerName[ 32 ];

				idSpec = pev( id, PEV_SPEC_TARGET );
				get_user_name( idSpec, iPlayerName, 31 );

				set_hudmessage( 0, 255, 0, 0.01, 0.22, 0, 0.5, 15.0, 2.0, 2.0, -1 );
				ShowSyncHudMsg( id, SyncHudMessage, "Jucator: %s^nHP: %d^nPuncte: %d", iPlayerName, get_user_health( idSpec ), g_iUserPoints[ idSpec ] );
			}
		}

		case 1: {
	
			if( is_user_connected( id ) && is_user_alive( id ) && ( get_user_team( id ) == 1 || get_user_team( id ) == 2 ) ) {

				set_hudmessage( 0, 0, 254, 0.01, 0.91, 0, 0.5, 15.0, 2.0, 2.0, -1 );
				ShowSyncHudMsg( id, SyncHudMessage, "HP: %d | AP: %d | Puncte: %d", get_user_health( id ), get_user_armor( id ), g_iUserPoints[ id ] );
			}

			else {

				new idSpec;
				new iPlayerName[ 32 ];

				idSpec = pev( id, PEV_SPEC_TARGET );
				get_user_name( idSpec, iPlayerName, 31 );

				set_hudmessage( 0, 255, 0, -1.0, 0.7, 0, 0.5, 15.0, 2.0, 2.0, -1 );
				ShowSyncHudMsg( id, SyncHudMessage, "Jucator: %s^nHP: %d^nPuncte: %d", iPlayerName, get_user_health( idSpec ), g_iUserPoints[ idSpec ] );
			}
		}
	}
}

public ClCmdSayBuyPoint( id ) {

	if( is_user_connected( id ) )
	{
		new g_iUserMoney = cs_get_user_money( id );
		new iNeededMoney = get_pcvar_num( g_iCvar[ CostOnePoint ] );
 
		if( g_iUserMoney < iNeededMoney )
 
		ColorChat( id, TEAM_COLOR, "^x01[%s^x01] Mai ai nevoie de^x03 %d $^x01 pentru a cumpara^x03 10 puncte^x01", g_szTag, iNeededMoney - g_iUserMoney );
 
		else {
 
			g_iUserPoints[ id ] += 10;
			cs_set_user_money( id, g_iUserMoney - iNeededMoney );
			ColorChat( id, TEAM_COLOR, "^x01[^%s^x01] Tocmai ai cumparat^x03 10 puncte^x01 pentru^x03 $%d", g_szTag, iNeededMoney );
		}
	}
}

public ClCmdSayShowAllPoints( id ) {

	new iPlayers[ 32 ], iPlayersNum, szName[ 40 ], szMotd[ 1024 ], len;
	len = formatex( szMotd, charsmax( szMotd ), "<html><table style='font-family: Courier New; font-size: 12px; background-color: black; color: yellow; border: 1px solid yellow; padding: 2px; width: 300px'><tr colspan='2'><td>Puncte jucatori online</td></tr><tr><td>Nume</td><td>Puncte</td></tr>");
	get_players( iPlayers, iPlayersNum );

	for( new i = 0 ; i < iPlayersNum ; i++ ) {

		get_user_name( iPlayers[ i ], szName, charsmax( szName ) );
		len += formatex( szMotd[ len ], charsmax( szMotd ) - len, "<tr><td>%s</td><td>%i</td></tr>", szName, g_iUserPoints[ iPlayers[ i ] ] );
	}

	formatex( szMotd[ len ], charsmax( szMotd ) - len, "</table></html>" );
	show_motd( id, szMotd );	
}

public ClCmdSayPoints( id ) {

	set_hudmessage( 127, 42, 255, 0.03, 0.86, 2, 6.0, 10.0 );
	show_hudmessage( id, "[^x04Sistem puncte^x01] Ai %i puncte", g_iUserPoints[ id ] );
	
	ColorChat( id, TEAM_COLOR, "^x01[^%s^x01] Ai^x03 %i^x01 puncte", g_szTag, g_iUserPoints[ id ] );
	
	return PLUGIN_CONTINUE;
}

public bomb_planted( iPlanter ) {

	if( get_pcvar_num( g_iCvar[ EnableBombEvents ] ) == 0 || !is_user_connected( iPlanter ) )
		return PLUGIN_CONTINUE;
		
	g_iUserPoints[ iPlanter ] += get_pcvar_num( g_iCvar[ PointsBombPlanted ] );
	//show_hudmessage(iPlanter, "[^x04Sistem puncte^x01] Ai primit^x03 1 punct^x01 pentru plantarea bombei", g_szTag);
	ColorChat( iPlanter, TEAM_COLOR, "^x01[%s^x01] Ai primit^x03 1 punct^x01 pentru plantarea bombei", g_szTag);
	return PLUGIN_CONTINUE;
}

public bomb_explode( iExploder ) {
	
	if( get_pcvar_num( g_iCvar[ EnableBombEvents ] ) == 0 || !is_user_connected( iExploder ) )
		return PLUGIN_CONTINUE;
		
	g_iUserPoints[ iExploder ] += get_pcvar_num( g_iCvar[ PointsBombExploded ] );
	//show_hudmessage(iExploder, "[^x04Sistem puncte^x01] Ai primit^x03 2 puncte^x01 pentru ca bomba a explodat", g_szTag);
	ColorChat( iExploder, TEAM_COLOR, "^x01[%s^x01] Ai primit^x03 2 puncte^x01 pentru ca bomba a explodat", g_szTag);
	return PLUGIN_CONTINUE;
}

public bomb_defused( iDefuser ) {

	if( get_pcvar_num( g_iCvar[ EnableBombEvents ] ) == 0 || !is_user_connected( iDefuser ) )
		return PLUGIN_CONTINUE;
		
	g_iUserPoints[ iDefuser ] += get_pcvar_num( g_iCvar[ PointsBombDefused ] );
	//show_hudmessage(iDefuser, "[^x04Sistem puncte^x01] Ai primit ^x03 2 puncte^x01 pentru dezamorsarea bombei", g_szTag);
	ColorChat( iDefuser, TEAM_COLOR, "^x01[%s^x01] Ai primit^x03 2 puncte^x01 pentru dezamorsarea bombei", g_szTag);
	return PLUGIN_CONTINUE;
}

public ClCmdGivePoints( id ) {

	if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) {

		client_cmd( id, "echo Nu ai acces la aceasta comanda!" );
		return 1;
	}
	
	new szFirstArg[ 32 ], szSecondArg[ 10 ];
	
	read_argv( 1, szFirstArg, sizeof ( szFirstArg ) -1 );
	read_argv( 2, szSecondArg, sizeof ( szSecondArg ) -1 );
	
	if( equal( szFirstArg, "" ) || equal( szSecondArg, "" ) ) {

		client_cmd( id, "echo amx_give_points < nume / @ALL / @T / @CT > <puncte>" );
		return 1;
	}
	
	new iPlayers[ 32 ];
	new iPlayersNum;
	
	new iPoints = str_to_num( szSecondArg );
	if( iPoints <= 0 ) {

		client_cmd( id, "echo Numarul de puncte trebuie sa fie mai mare decat 0!" );
		return 1;
	}
	
	if( szFirstArg[ 0 ] == '@' ) {

		switch ( szFirstArg[ 1 ] ) {

			case 'A': {

				if( equal( szFirstArg, "@ALL" ) ) {
					
					get_players( iPlayers, iPlayersNum, "ch" );
					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserPoints[ iPlayers[ i ] ] += iPoints;
						
					ColorChat( 0, TEAM_COLOR, "^x01[%s^x01] Adminul^x03 %s^x01 le-a dat^x03 %i punct(e)^x01 tuturor jucatorilor", g_szTag, get_name( id ), iPoints );
					return 1;
				}
			}
			
			case 'T': {

				if( equal( szFirstArg, "@T" ) ) {
					
					get_players( iPlayers, iPlayersNum, "ceh", "TERRORIST" );
					if( iPlayersNum == 0 ) {

						client_cmd( id, "echo Nu se afla nici un jucator in aceasta echipa!" );
						return 1;
					}

					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserPoints[ iPlayers[ i ] ] += iPoints;
						
					ColorChat( 0, TEAM_COLOR, "^x01[%s^x01] Adminul^x03 %s^x01 le-a dat^x03 %i punct(e)^x01 jucatorilor din echipa^x03 T^x01", g_szTag, get_name( id ), iPoints );
					return 1;
				}
			}
			
			case 'C': {

				if( equal( szFirstArg, "@CT" ) ) {
					
					get_players( iPlayers, iPlayersNum, "ceh", "CT" );
					if( iPlayersNum == 0 ) {

						client_cmd( id, "echo Nu se afla niciun jucator in aceasta echipa!" );
						return 1;
					}

					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserPoints[ iPlayers[ i ] ] += iPoints;
						
					ColorChat( 0, TEAM_COLOR, "^x01[%s^x01] Adminul^x03 %s^x01 le-a dat^x03 %i punct(e)^x01 jucatorilor din echipa^x03 CT^x01", g_szTag, get_name( id ), iPoints );
					return 1;
				}
			}
		}
	}
		
	new iPlayer = cmd_target( id, szFirstArg, 8 );
	if( !iPlayer ) {

		client_cmd( id, "echo Jucatorul %s nu a fost gasit!", szFirstArg );
		return 1;
	}
	
	g_iUserPoints[ iPlayer ] += iPoints;
	
	new szName[ 32 ];
	get_user_name( iPlayer, szName, sizeof ( szName ) -1 );
	
	if( is_user_connected(id) )
	{
		ColorChat( iPlayer, TEAM_COLOR, "^x01[^%s^x01] Adminul^x03 %s^x01 ti-a dat^x03 %i punct(e)^x01", g_szTag, get_name( id ), iPoints);
		ColorChat( id, TEAM_COLOR, "^x01[^%s^x01] I-ai dat^x03 %i punct(e)^x01 lui^x03 %s^x01", g_szTag, iPoints, szName );
	}
	
	return 1;
}

public ClCmdTakePoints( id ) {

	if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) {

		client_cmd( id, "echo Nu ai acces la aceasta comanda!" );
		return 1;
	}
	
	new szFirstArg[ 32 ], szSecondArg[ 10 ];
	
	read_argv( 1, szFirstArg, sizeof ( szFirstArg ) -1 );
	read_argv( 2, szSecondArg, sizeof ( szSecondArg ) -1 );
	
	if( equal( szFirstArg, "" ) || equal( szSecondArg, "" ) ) {

		client_cmd( id, "echo amx_take_points <nume> <puncte>" );
		return 1;
	}
	
	new iPoints = str_to_num( szSecondArg );
	if( iPoints <= 0 ) {

		client_cmd( id, "echo Numarul de puncte trebuie sa fie mai mare decat 0!" );
		return 1;
	}
			
	new iPlayer = cmd_target( id, szFirstArg, 8 );
	if( !iPlayer ) {

		client_cmd( id, "echo Jucatorul %s nu a fost gasit!", szFirstArg );
		return 1;
	}
	
	if( g_iUserPoints[ iPlayer ] < iPoints ) {

		client_cmd( id, "echo Jucatorul %s are doar %i puncte.", szFirstArg, g_iUserPoints[ iPlayer ] );
		return 1;
	}
	
	g_iUserPoints[ iPlayer ] -= iPoints;
	
	new szName[ 32 ];
	get_user_name( iPlayer, szName, sizeof( szName ) -1 );
	if( is_user_connected(id) )
	{
		ColorChat( iPlayer, TEAM_COLOR, "^x01[^%s^x01] Adminul^x03 %s^x01 ti-a luat^x03 %i punct(e)^x01", g_szTag, get_name( id ), iPoints);
		ColorChat( id, TEAM_COLOR, "^x01[^%s^x01] I-ai luat^x03 %i puncte^x01 lui^x03 %s^x01", g_szTag, iPoints, szName );
	}
	return 1;
}

public ClCmdResetPoints( id, level, cid ) {
	if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) {

		client_cmd( id, "echo Nu ai acces la aceasta comanda!" );
		return 1;
	}
	
	if( !cmd_access( id, level, cid, 2 ) ) {

		return PLUGIN_HANDLED; 
	}
	
	new szArgument[ 32 ];
   	read_argv( 1, szArgument, charsmax( szArgument ) );
	
	new iPlayer[ 32 ], iPlayersNum, all;
	get_players( iPlayer, iPlayersNum, "c" );

	if( equal( szArgument, "@ALL" ) ) {

		for( new i; i < iPlayersNum; i++ ) {

			all = iPlayer[ i ];
			
			g_iUserPoints[ all ] = 0;
			
			
		}
		ColorChat( 0, TEAM_COLOR, "^x01[^%s^x01] Adminul^x03 %s^x01 a resetat punctele tuturor jucatorilor", g_szTag, get_name( id ) );
	}
			
	else {

		new player = cmd_target( id, szArgument, 10 );

		if( !player )  {

  			 return PLUGIN_HANDLED;
		}
	
		//new iPlayer = cmd_target( id, szFirstArg, 8 );
		new TargetName[ 32 char ];
		get_user_name( player, TargetName, charsmax( TargetName ) );
		
		g_iUserPoints[ player ] = 0;
		ColorChat( player, TEAM_COLOR, "^x01[^%s^x01] Adminul^x03 %s^x01 ti-a resetat punctele", g_szTag, get_name( id ));
		ColorChat( id, TEAM_COLOR, "^x01[^%s^x01] I-ai resetat punctele lui^x03 %s^x01", g_szTag, TargetName );
	}

	return PLUGIN_HANDLED;
}

public SaveUserPoints( id ) {

	new szVaultKey[ 64 ], szVaultData[ 256 ];

	format( szVaultKey, 63, "%s", get_name( id ) );
	format( szVaultData, 255, "%i#", g_iUserPoints[ id ] );

	nvault_set( g_Vault, szVaultKey, szVaultData );

	return 1;
}

public LoadUserPoints( id ) {

 	new szVaultKey[ 64 ], szVaultData[ 256 ];

	format( szVaultKey, 63, "%s", get_name( id ) );
	format( szVaultData, 255, "%i#", g_iUserPoints[ id ] );

 	nvault_get( g_Vault, szVaultKey, szVaultData, 255 );

 	replace_all( szVaultData, 255, "#", " " );

 	new Arg1[ 32 ];
 	parse( szVaultData, Arg1, 31 );

 	g_iUserPoints[ id ] = str_to_num( Arg1 );

 	return 1;
}

stock get_name( id ) {

	new szName[ 32 ];
	get_user_name( id, szName, sizeof ( szName ) -1 );
	return szName;
}

stock bool:is_user_vip( id ) {

	if( get_user_flags( id ) & read_flags( "h" )  )
		return true;
	
	return false;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/

Code: Select all

register_concmd( "amx_give_points" ,"ClCmdGivePoints", ADMIN_ACCESS, "< nume / @ALL / @T / @CT > < Puncte >" );
	register_concmd( "amx_take_points", "ClCmdTakePoints", ADMIN_ACCESS, "< nume > < Puncte >" );
	register_concmd( "amx_reset_points", "ClCmdResetPoints", ADMIN_ACCESS, "< nume / @ALL >" );
,,Mai bine taci și accepți prostia altora, de cât să fii mai nimic decât ei."
lexz
Membru, skill +1
Membru, skill +1
Posts: 249
Joined: 02 Nov 2020, 01:57
Detinator Steam: Da
SteamID: profiles/76561198070
Fond eXtream: 0
Discord: lexzor#0630
Has thanked: 15 times
Been thanked: 28 times

09 May 2022, 22:17

incearca asa

Code: Select all

/*===========================================================================================================================

				        *********************************************************
				         *********** [ Advanced Points System 1.1 ] ************
				        *********************************************************

		-------------------------
		   ---- * Description * ----
		-------------------------

			- Acest plugin este un sistem de puncte ! Ce inseamna asta? Cand faci un frag vei primi X puncte si de asemenea
		mai faci puncte si pe alte obiective !

		-------------------------
		   --- * Configuration * ---
		-------------------------

			points_show_info "0 / 1"			- 0: Afiseaza datele in HUD sub radar | 1: Afiseaza datele deasupra vietii
			points_bombevents_rewards "0 / 1"		- 0: Dezactivat | 1: Activat -> Puncte obtinute pe plantarea/dezamorsarea/explodearea bombei
			points_costonepoint	"MONEY"			- Cat sa coste un punct atunci cand il cumperi prin comanda "/buypoint"
			points_per_headshot "PUNCTE"		- Cate puncte sa primesti pe HeadShot !
			points_bomb_planted "X"			- Cate puncte sa primesti pe plantarea bombei
			points_bomb_exploded "Y"			- Cate puncte sa primesti pe explodarea bombei
			points_bomb_defused "Z"			- Cate puncte sa primesti pe dezamorsarea bombei
			points_gamename "Adv. Points System v1.1"	- Schimbi numele default( Counter-Strike ) cu altul
			points_add_newround "PUNCTE"		- Cate puncte sa primesti la fiecare runda !
			points_enable_respawn "0 / 1"		- Activeaza / Dezactiveaza respawn-ul cand victima moare doar daca are X PUNCTE
			points_for_respawn "PUNCTE"		- Cate puncte sa aiba victima ca sa poata reinvia atunci cand este omorata
			points_respawn_chance "SANSE"		- De cate sanse are nevoie victima ca sa invie atunci cand are X PUNCTE

		-------------------------
		   ----- * Modules * -----
		-------------------------

				- Hamsandwich;
			- Fakemeta;
		- Cstrike;

		-------------------------
		      --- * Credits * ---
		-------------------------

			- sDs|Aragon* - sistemul avansat de salvare al punctelor;

		-------------------------
		    --- * Changelog * ---
		-------------------------

			* v1.0:
			   - Initial release | Private | ( 15th Oct 2013 ) :D

			* v1.1:
			   - Public Source ( 13th Dec 2013 )

		-------------------------
		    --- * Update * ---
		-------------------------

				        *********************************************************
				         *********** [ Advanced Points System 1.1 ] ************
				        *********************************************************

===========================================================================================================================*/

#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < hamsandwich >
#include <ColorChat>
#include < csx >
#include < cstrike >
#include < nvault >

#pragma semicolon 1

#define ADMIN_ACCESS ADMIN_RCON
#define is_user_player(%1) ( 1 <= %1 <= g_MaxPlayers )

#define PLUGIN_NAME 	"Advanced Points System"
#define PLUGIN_VERSION 	"1.1"
#define PLUGIN_AUTHOR 	"YONTU"

new const g_szTag[  ] = "Sistem puncte";
new g_Vault;

// Make files?
new const szWriteCvarsPoints[  ] = "addons/amxmodx/configs/points/points.cfg";
new const szLocationPoints[  ] = "addons/amxmodx/configs/points";

const PEV_SPEC_TARGET = pev_iuser2;

new g_iUserPoints[ 33 ];

new SyncHudMessage, g_MaxPlayers;

enum _:iCvars {

	EnableBombEvents,
	ShowType,
	CostOnePoint,
	PointsPerHS,
	PointsBombPlanted,
	PointsBombExploded,
	PointsBombDefused,
	AddPointsNewRound,
	EnableRespawn,
	PointsForRespawn,
	PointsForRespawnChance
}
;
new g_iCvar[ iCvars ];

public plugin_init( ) {

	register_plugin( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR );
	
	register_event( "DeathMsg", "event_DeathMsg", "a" );

	register_forward( FM_GetGameDescription, "GameDesc" ); 
	register_forward( FM_PlayerPreThink, "fwd_PlayerPreThink" );

	RegisterHam( Ham_Spawn, "player", "Ham_PlayerSpawned_Post", 1 );
	RegisterHam( Ham_Killed, "player", "Ham_PlayerKilled", 1 );
	
	register_clcmd( "say /cumparapuncte", "ClCmdSayBuyPoint" );
	register_clcmd( "say_team /cumparapuncte", "ClCmdSayBuyPoint" );

	register_clcmd( "say /ptop", "ClCmdSayShowAllPoints" );
	register_clcmd( "say_team /ptop", "ClCmdSayShowAllPoints" );

	register_clcmd( "say /puncte", "ClCmdSayPoints" );
	register_clcmd( "say_team /puncte", "ClCmdSayPoints" );

	register_concmd( "amx_give_points" ,"ClCmdGivePoints", ADMIN_ACCESS, "< nume / @ALL / @T / @CT > < Puncte >" );
	register_concmd( "amx_take_points", "ClCmdTakePoints", ADMIN_ACCESS, "< nume > < Puncte >" );
	register_concmd( "amx_reset_points", "ClCmdResetPoints", ADMIN_ACCESS, "< nume / @ALL >" );
	
	g_iCvar[ ShowType ] = register_cvar( "points_show_info", "0" );
	g_iCvar[ EnableBombEvents ] = register_cvar( "points_bombevents_rewards", "1" );
	g_iCvar[ CostOnePoint ] = register_cvar( "points_costonepoint", "16000" );
	g_iCvar[ PointsPerHS ] = register_cvar( "points_per_headshot", "3" );
	g_iCvar[ PointsBombPlanted ] = register_cvar( "points_bomb_planted", "1" );
	g_iCvar[ PointsBombExploded ] = register_cvar( "points_bomb_exploded", "2" );
	g_iCvar[ PointsBombDefused ] = register_cvar( "points_bomb_defused", "2" );
	g_iCvar[ PointsForRespawn ] = register_cvar( "points_for_respawn", "10000" );
	g_iCvar[ PointsForRespawnChance ] = register_cvar( "points_respawn_chance", "70" );
	g_iCvar[ EnableRespawn ] = register_cvar( "points_enable_respawn", "0" );

	SyncHudMessage = CreateHudSyncObj(  );
	g_MaxPlayers = global_get( glb_maxClients );

	g_Vault = nvault_open( "AdvPointsSystem" );
}

public plugin_precache(  ) {

	server_cmd( "exec %s", szWriteCvarsPoints );
       
	if( !dir_exists( szLocationPoints ) )
		mkdir( szLocationPoints );

	if( !file_exists( szWriteCvarsPoints ) ) {

		write_file( szWriteCvarsPoints, "// In acest fisier se afla cvar-urile legate despre puncte:");
		write_file( szWriteCvarsPoints, " ");
		write_file( szWriteCvarsPoints, "points_show_info ^"0^" // 0: Afiseaza datele in HUD sub radar | 1: Afiseaza datele deasupra vietii" );
		write_file( szWriteCvarsPoints, "points_bombevents_rewards ^"1^" // 0: Dezactivat | 1: Activat -> Puncte obtinute pe plantarea/dezamorsarea/explodearea bombei" );
		write_file( szWriteCvarsPoints, "points_costonepoint ^"16000^" // Cat sa coste un punct atunci cand il cumperi prin comanda /buypoint" );
		write_file( szWriteCvarsPoints, "points_per_headshot ^"3^" // Cate puncte sa primesti pe HeadShot !" );
		write_file( szWriteCvarsPoints, "points_bomb_planted ^"1^" // Cate puncte sa primesti pe plantarea bombei" );
		write_file( szWriteCvarsPoints, "points_bomb_exploded ^"2^" // Cate puncte sa primesti pe explodarea bombei" );
		write_file( szWriteCvarsPoints, "points_bomb_defused ^"2^" // Cate puncte sa primesti pe dezamorsarea bombei" );
		write_file( szWriteCvarsPoints, "points_enable_respawn ^"0^" // Activeaza / Dezactiveaza respawn-ul cand victima moare doar daca are X PUNCTE" );
		write_file( szWriteCvarsPoints, "points_for_respawn ^"10000^" // Cate puncte sa aiba victima ca sa poata reinvia atunci cand este omorata" );
		write_file( szWriteCvarsPoints, "points_respawn_chance ^"40^" // Cate sanse sa aiba victima ca sa poata reinvia" );
	}
}

public plugin_natives( ) {

	register_native( "get_user_points", "native_get_user_points", 1 );
	register_native( "set_user_points", "native_set_user_points", 1 );
}

public native_get_user_points( id ) {

	return g_iUserPoints[ id ];
}

public native_set_user_points( id, points ) {

	g_iUserPoints[ id ] = points;
}

public client_putinserver( id ) {

	LoadUserPoints( id );
}

public client_disconnected( id ) {

	SaveUserPoints( id );
}

public fwdPlayerPreThink( id ) {
	
	if( is_user_alive( id ) ) {
		
		new target, body; 
		get_user_aiming( id, target, body, 9999 );
		
		new CsTeams:team = cs_get_user_team( id );
		
		if( is_user_alive( target ) ) {

			if( is_user_player( target ) ) {
			
				new CsTeams:targetTeam = cs_get_user_team( target );
				
				new szName[ 32 ];
				get_user_name( target,  szName, sizeof( szName ) -1 );
							
				new sMessage[ 160 ];
				if( targetTeam == team ) {

					formatex( sMessage, sizeof( sMessage ) -1, "%s: %s^nHP: %i | Puncte: %i", is_user_vip( target ) ? "VIP" : "Friend", szName, get_user_health( target ), g_iUserPoints[ target ] );
				}

				else if( targetTeam != team && team != CS_TEAM_CT ) {

					formatex( sMessage, sizeof( sMessage ) -1, "%s: %s^nHP: %i | Puncte: %i", is_user_vip( target ) ? "VIP" : "Enemy", szName, get_user_health( target ), g_iUserPoints[ target ] );
				}
					
				if( targetTeam == CS_TEAM_CT ) {

					set_hudmessage( 0, 255, 0, -1.0, 0.6, 0, 0.0, 0.1, 0.0, 0.0, -1 );
				}

				else if( targetTeam == CS_TEAM_T ) {

					set_hudmessage( 127, 0, 0, -1.0, 0.6, 0, 0.0, 0.1, 0.0, 0.0, -1 );
				}	
				
				show_hudmessage( id, "%s",  sMessage );
			}
		}
	}
	
	return FMRES_IGNORED;
}

public event_DeathMsg( ) {

	new iKiller = read_data( 1 );
	new iVictim = read_data( 2 );
	new iHeadshot = read_data( 3 );
	
	if( !is_user_connected( iKiller ) || !is_user_connected( iVictim ) ) {

		return;
	}
	
	if( iKiller == iVictim ) {

		return;
	}
	
	if( iHeadshot ) {

		g_iUserPoints[ iKiller ] += get_pcvar_num( g_iCvar[ PointsPerHS ] );
		set_hudmessage( 0, 255, 0, 0.6, 0.7, 1, 6.0, 7.0 );
		show_hudmessage( iKiller, "+%i points", get_pcvar_num( g_iCvar[ PointsPerHS ] ) );
	}

	else {

		g_iUserPoints[ iKiller ]++;
		set_hudmessage( 0, 255, 0, 0.6, 0.7, 0, 6.0, 7.0 );
		show_hudmessage( iKiller, "+1 point" );
	}
}

public Ham_PlayerSpawned_Post( id ) {

	if( is_user_connected( id ) && is_user_alive( id ) ) {

		set_task( 1.0, "ShowHud", id, _, _, "b" );
	}
}

public Ham_PlayerKilled( iVictim, iAttacker, iShouldgib ) {

	if( get_pcvar_num( g_iCvar[ EnableRespawn ] ) == 0 || !is_user_connected( iVictim ) )
		return PLUGIN_CONTINUE;

	new iPoints = get_pcvar_num( g_iCvar[ PointsForRespawn ] );
	new iChance = random_num( 1, 100 );
	new iAccepted = get_pcvar_num( g_iCvar[ PointsForRespawnChance ] );

	if( g_iUserPoints[ iVictim ] == iPoints ) {

		if( iChance <= iAccepted ) {

			ExecuteHamB( Ham_CS_RoundRespawn, iVictim );
			ColorChat( 0, TEAM_COLOR, "^x04%s^x01 Tocmai ai fost inviat pentru ca ai avut^x03 %i^x01 sanse !", g_szTag, iChance );
		}

		if( iChance >= iAccepted ) {

			ColorChat( 0, TEAM_COLOR, "^x04%s^x01 Poate runda viitoare vei avea^x03 %i^x01 sanse pentru a putea reinvia !", g_szTag, iChance );
		}
	}

	return PLUGIN_CONTINUE;
}

public ShowHud( id ) {

	switch( get_pcvar_num( g_iCvar[ ShowType ] ) ) {

		case 0: {
	
			if( is_user_connected( id ) && is_user_alive( id ) && ( get_user_team( id ) == 1 || get_user_team( id ) == 2 ) ) {

				set_hudmessage( 0, 255, 0, 0.01, 0.23, 0, 0.5, 15.0, 2.0, 2.0, -1 );
				ShowSyncHudMsg( id, SyncHudMessage, "Puncte: %d", g_iUserPoints[ id ] );
			}

			else {

				new idSpec;
				new iPlayerName[ 32 ];

				idSpec = pev( id, PEV_SPEC_TARGET );
				get_user_name( idSpec, iPlayerName, 31 );

				set_hudmessage( 0, 255, 0, 0.01, 0.22, 0, 0.5, 15.0, 2.0, 2.0, -1 );
				ShowSyncHudMsg( id, SyncHudMessage, "Jucator: %s^nHP: %d^nPuncte: %d", iPlayerName, get_user_health( idSpec ), g_iUserPoints[ idSpec ] );
			}
		}

		case 1: {
	
			if( is_user_connected( id ) && is_user_alive( id ) && ( get_user_team( id ) == 1 || get_user_team( id ) == 2 ) ) {

				set_hudmessage( 0, 0, 254, 0.01, 0.91, 0, 0.5, 15.0, 2.0, 2.0, -1 );
				ShowSyncHudMsg( id, SyncHudMessage, "HP: %d | AP: %d | Puncte: %d", get_user_health( id ), get_user_armor( id ), g_iUserPoints[ id ] );
			}

			else {

				new idSpec;
				new iPlayerName[ 32 ];

				idSpec = pev( id, PEV_SPEC_TARGET );
				get_user_name( idSpec, iPlayerName, 31 );

				set_hudmessage( 0, 255, 0, -1.0, 0.7, 0, 0.5, 15.0, 2.0, 2.0, -1 );
				ShowSyncHudMsg( id, SyncHudMessage, "Jucator: %s^nHP: %d^nPuncte: %d", iPlayerName, get_user_health( idSpec ), g_iUserPoints[ idSpec ] );
			}
		}
	}
}

public ClCmdSayBuyPoint( id ) {

	if( is_user_connected( id ) )
	{
		new g_iUserMoney = cs_get_user_money( id );
		new iNeededMoney = get_pcvar_num( g_iCvar[ CostOnePoint ] );
 
		if( g_iUserMoney < iNeededMoney )
 
		ColorChat( id, TEAM_COLOR, "^x01[%s^x01] Mai ai nevoie de^x03 %d $^x01 pentru a cumpara^x03 10 puncte^x01", g_szTag, iNeededMoney - g_iUserMoney );
 
		else {
 
			g_iUserPoints[ id ] += 10;
			cs_set_user_money( id, g_iUserMoney - iNeededMoney );
			ColorChat( id, TEAM_COLOR, "^x01[^%s^x01] Tocmai ai cumparat^x03 10 puncte^x01 pentru^x03 $%d", g_szTag, iNeededMoney );
		}
	}
}

public ClCmdSayShowAllPoints( id ) {

	new iPlayers[ 32 ], iPlayersNum, szName[ 40 ], szMotd[ 1024 ], len;
	len = formatex( szMotd, charsmax( szMotd ), "<html><table style='font-family: Courier New; font-size: 12px; background-color: black; color: yellow; border: 1px solid yellow; padding: 2px; width: 300px'><tr colspan='2'><td>Puncte jucatori online</td></tr><tr><td>Nume</td><td>Puncte</td></tr>");
	get_players( iPlayers, iPlayersNum );

	for( new i = 0 ; i < iPlayersNum ; i++ ) {

		get_user_name( iPlayers[ i ], szName, charsmax( szName ) );
		len += formatex( szMotd[ len ], charsmax( szMotd ) - len, "<tr><td>%s</td><td>%i</td></tr>", szName, g_iUserPoints[ iPlayers[ i ] ] );
	}

	formatex( szMotd[ len ], charsmax( szMotd ) - len, "</table></html>" );
	show_motd( id, szMotd );	
}

public ClCmdSayPoints( id ) {

	set_hudmessage( 127, 42, 255, 0.03, 0.86, 2, 6.0, 10.0 );
	show_hudmessage( id, "[^x04Sistem puncte^x01] Ai %i puncte", g_iUserPoints[ id ] );
	
	ColorChat( id, TEAM_COLOR, "^x01[^%s^x01] Ai^x03 %i^x01 puncte", g_szTag, g_iUserPoints[ id ] );
	
	return PLUGIN_CONTINUE;
}

public bomb_planted( iPlanter ) {

	if( get_pcvar_num( g_iCvar[ EnableBombEvents ] ) == 0 || !is_user_connected( iPlanter ) )
		return PLUGIN_CONTINUE;
		
	g_iUserPoints[ iPlanter ] += get_pcvar_num( g_iCvar[ PointsBombPlanted ] );
	//show_hudmessage(iPlanter, "[^x04Sistem puncte^x01] Ai primit^x03 1 punct^x01 pentru plantarea bombei", g_szTag);
	ColorChat( iPlanter, TEAM_COLOR, "^x01[%s^x01] Ai primit^x03 1 punct^x01 pentru plantarea bombei", g_szTag);
	return PLUGIN_CONTINUE;
}

public bomb_explode( iExploder ) {
	
	if( get_pcvar_num( g_iCvar[ EnableBombEvents ] ) == 0 || !is_user_connected( iExploder ) )
		return PLUGIN_CONTINUE;
		
	g_iUserPoints[ iExploder ] += get_pcvar_num( g_iCvar[ PointsBombExploded ] );
	//show_hudmessage(iExploder, "[^x04Sistem puncte^x01] Ai primit^x03 2 puncte^x01 pentru ca bomba a explodat", g_szTag);
	ColorChat( iExploder, TEAM_COLOR, "^x01[%s^x01] Ai primit^x03 2 puncte^x01 pentru ca bomba a explodat", g_szTag);
	return PLUGIN_CONTINUE;
}

public bomb_defused( iDefuser ) {

	if( get_pcvar_num( g_iCvar[ EnableBombEvents ] ) == 0 || !is_user_connected( iDefuser ) )
		return PLUGIN_CONTINUE;
		
	g_iUserPoints[ iDefuser ] += get_pcvar_num( g_iCvar[ PointsBombDefused ] );
	//show_hudmessage(iDefuser, "[^x04Sistem puncte^x01] Ai primit ^x03 2 puncte^x01 pentru dezamorsarea bombei", g_szTag);
	ColorChat( iDefuser, TEAM_COLOR, "^x01[%s^x01] Ai primit^x03 2 puncte^x01 pentru dezamorsarea bombei", g_szTag);
	return PLUGIN_CONTINUE;
}

public ClCmdGivePoints( id ) {

	if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) {

		client_cmd( id, "echo Nu ai acces la aceasta comanda!" );
		return 1;
	}
	
	new szFirstArg[ 32 ], szSecondArg[ 10 ];
	
	read_argv( 1, szFirstArg, sizeof ( szFirstArg ) -1 );
	read_argv( 2, szSecondArg, sizeof ( szSecondArg ) -1 );
	
	if( equal( szFirstArg, "" ) || equal( szSecondArg, "" ) ) {

		client_cmd( id, "echo amx_give_points < nume / @ALL / @T / @CT > <puncte>" );
		return 1;
	}
	
	new iPlayers[ 32 ];
	new iPlayersNum;
	
	new iPoints = str_to_num( szSecondArg );
	if( iPoints <= 0 ) {

		client_cmd( id, "echo Numarul de puncte trebuie sa fie mai mare decat 0!" );
		return 1;
	}
	
	if( szFirstArg[ 0 ] == '@' ) {

		switch ( szFirstArg[ 1 ] ) {

			case 'A': {

				if( equal( szFirstArg, "@ALL" ) ) {
					
					get_players( iPlayers, iPlayersNum, "ch" );
					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserPoints[ iPlayers[ i ] ] += iPoints;
						
					ColorChat( 0, TEAM_COLOR, "^x01[%s^x01] Adminul^x03 %s^x01 le-a dat^x03 %i punct(e)^x01 tuturor jucatorilor", g_szTag, get_name( id ), iPoints );
					return 1;
				}
			}
			
			case 'T': {

				if( equal( szFirstArg, "@T" ) ) {
					
					get_players( iPlayers, iPlayersNum, "ceh", "TERRORIST" );
					if( iPlayersNum == 0 ) {

						client_cmd( id, "echo Nu se afla nici un jucator in aceasta echipa!" );
						return 1;
					}

					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserPoints[ iPlayers[ i ] ] += iPoints;
						
					ColorChat( 0, TEAM_COLOR, "^x01[%s^x01] Adminul^x03 %s^x01 le-a dat^x03 %i punct(e)^x01 jucatorilor din echipa^x03 T^x01", g_szTag, get_name( id ), iPoints );
					return 1;
				}
			}
			
			case 'C': {

				if( equal( szFirstArg, "@CT" ) ) {
					
					get_players( iPlayers, iPlayersNum, "ceh", "CT" );
					if( iPlayersNum == 0 ) {

						client_cmd( id, "echo Nu se afla niciun jucator in aceasta echipa!" );
						return 1;
					}

					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserPoints[ iPlayers[ i ] ] += iPoints;
						
					ColorChat( 0, TEAM_COLOR, "^x01[%s^x01] Adminul^x03 %s^x01 le-a dat^x03 %i punct(e)^x01 jucatorilor din echipa^x03 CT^x01", g_szTag, get_name( id ), iPoints );
					return 1;
				}
			}
		}
	}
		
	new iPlayer = cmd_target( id, szFirstArg, 8 );
	if( !iPlayer ) {

		client_cmd( id, "echo Jucatorul %s nu a fost gasit!", szFirstArg );
		return 1;
	}
	
	g_iUserPoints[ iPlayer ] += iPoints;
	
	new szName[ 32 ];
	get_user_name( iPlayer, szName, sizeof ( szName ) -1 );
	
	if( is_user_connected(id) )
	{
		ColorChat( iPlayer, TEAM_COLOR, "^x01[^%s^x01] Adminul^x03 %s^x01 ti-a dat^x03 %i punct(e)^x01", g_szTag, get_name( id ), iPoints);
		ColorChat( id, TEAM_COLOR, "^x01[^%s^x01] I-ai dat^x03 %i punct(e)^x01 lui^x03 %s^x01", g_szTag, iPoints, szName );
	}
	
	return 1;
}

public ClCmdTakePoints( id ) {

	if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) {

		client_cmd( id, "echo Nu ai acces la aceasta comanda!" );
		return 1;
	}
	
	new szFirstArg[ 32 ], szSecondArg[ 10 ];
	
	read_argv( 1, szFirstArg, sizeof ( szFirstArg ) -1 );
	read_argv( 2, szSecondArg, sizeof ( szSecondArg ) -1 );
	
	if( equal( szFirstArg, "" ) || equal( szSecondArg, "" ) ) {

		client_cmd( id, "echo amx_take_points <nume> <puncte>" );
		return 1;
	}
	
	new iPoints = str_to_num( szSecondArg );
	if( iPoints <= 0 ) {

		client_cmd( id, "echo Numarul de puncte trebuie sa fie mai mare decat 0!" );
		return 1;
	}
			
	new iPlayer = cmd_target( id, szFirstArg, 8 );
	if( !iPlayer ) {

		client_cmd( id, "echo Jucatorul %s nu a fost gasit!", szFirstArg );
		return 1;
	}
	
	if( g_iUserPoints[ iPlayer ] < iPoints ) {

		client_cmd( id, "echo Jucatorul %s are doar %i puncte.", szFirstArg, g_iUserPoints[ iPlayer ] );
		return 1;
	}
	
	g_iUserPoints[ iPlayer ] -= iPoints;
	
	new szName[ 32 ];
	get_user_name( iPlayer, szName, sizeof( szName ) -1 );
	if( is_user_connected(id) )
	{
		ColorChat( iPlayer, TEAM_COLOR, "^x01[^%s^x01] Adminul^x03 %s^x01 ti-a luat^x03 %i punct(e)^x01", g_szTag, get_name( id ), iPoints);
		ColorChat( id, TEAM_COLOR, "^x01[^%s^x01] I-ai luat^x03 %i puncte^x01 lui^x03 %s^x01", g_szTag, iPoints, szName );
	}
	return 1;
}

public ClCmdResetPoints( id, level, cid ) {
	if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) {

		client_cmd( id, "echo Nu ai acces la aceasta comanda!" );
		return 1;
	}
	
	if( !cmd_access( id, level, cid, 2 ) ) {

		return PLUGIN_HANDLED; 
	}
	
	new szArgument[ 32 ];
   	read_argv( 1, szArgument, charsmax( szArgument ) );
	
	new iPlayer[ 32 ], iPlayersNum, all;
	get_players( iPlayer, iPlayersNum, "c" );

	if( equal( szArgument, "@ALL" ) ) {

		for( new i; i < iPlayersNum; i++ ) {

			all = iPlayer[ i ];
			
			g_iUserPoints[ all ] = 0;
			
			
		}
		ColorChat( 0, TEAM_COLOR, "^x01[^%s^x01] Adminul^x03 %s^x01 a resetat punctele tuturor jucatorilor", g_szTag, get_name( id ) );
	}
			
	else {

		new player = cmd_target( id, szArgument, 10 );

		if( !player )  {

  			 return PLUGIN_HANDLED;
		}
	
		//new iPlayer = cmd_target( id, szFirstArg, 8 );
		new TargetName[ 32 char ];
		get_user_name( player, TargetName, charsmax( TargetName ) );
		
		g_iUserPoints[ player ] = 0;
		ColorChat( player, TEAM_COLOR, "^x01[^%s^x01] Adminul^x03 %s^x01 ti-a resetat punctele", g_szTag, get_name( id ));
		ColorChat( id, TEAM_COLOR, "^x01[^%s^x01] I-ai resetat punctele lui^x03 %s^x01", g_szTag, TargetName );
	}

	return PLUGIN_HANDLED;
}

public SaveUserPoints( id ) {

	new szVaultData[ 20 ];

	formatex( szVaultData, charsmax(szVaultData), "%i", g_iUserPoints[ id ] );

	nvault_set( g_Vault, get_name(id), szVaultData );
}

public LoadUserPoints( id ) {

	new iTs, szVaultData[20];
	if(nvault_lookup(g_Vault, get_name(id), szVaultData, charsmax(szVaultData), iTs))
	{
		g_iUserPoints[ id ] = str_to_num( szVaultData );
	}
 	return 1;
}

stock get_name( id ) {

	new szName[ 32 ];
	get_user_name( id, szName, sizeof ( szName ) -1 );
	return szName;
}

stock bool:is_user_vip( id ) {

	if( get_user_flags( id ) & read_flags( "h" )  )
		return true;
	
	return false;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Post Reply

Return to “Modificari pluginuri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests