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

OciXCrom's Rank System [XP|Levels|Ranks]


Post New Thread Reply   
 
Thread Tools Display Modes
Alankizziixx
Member
Join Date: Jun 2019
Old 06-27-2019 , 03:13   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #281

This is plugin of credits
sma
Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fakemeta >
#include < hamsandwich >
#include < nvault >
//#include < CC_ColorChat >

#pragma semicolon 1


#define PLUGIN "Furien Credits System"
#define VERSION "1.4.6" // Sper sa nu mai fie buguri.

#define	ONE_DAY_IN_SECONDS	86400

// |-- CC_ColorChat --|

enum Color
{
	NORMAL = 1, 		// Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
	GREEN, 			// Culoare Verde.
	TEAM_COLOR, 		// Culoare Rosu, Albastru, Gri.
	GREY, 			// Culoarea Gri.
	RED, 			// Culoarea Rosu.
	BLUE, 			// Culoarea Albastru.
};

new TeamName[  ][  ] = 
{
	"",
	"TERRORIST",
	"CT",
	"SPECTATOR"
};

// |-- CC_ColorChat --|

new const g_szTag[ ] = "[Furien Credits]";

new const g_szGiveCreditsFlag[ ] = "a";

new g_szName[ 33 ][ 32 ];
new g_iUserCredits[ 33 ];
new g_iUserRetired[ 33 ];

new g_iCvarPruneDays;
new g_iCvarEntry;
new g_iCvarRetire;
new iVault;

public plugin_init( )
{
	register_plugin( PLUGIN, VERSION, "Askhanar" );
	register_cvar( "fcs_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY ); 

	g_iCvarPruneDays = register_cvar( "fcs_prunedays", "0" );
	g_iCvarEntry = register_cvar( "fcs_entry_credits", "300" );
	g_iCvarRetire = register_cvar( "fcs_maxretrieve", "0" );
	
	register_clcmd( "say", "ClCmdSay" );
	register_clcmd( "say_team", "ClCmdSay" );
	
	register_clcmd( "say /depozit", "ClCmdSayDepozit" );
	register_clcmd( "say /deposit", "ClCmdSayDepozit" );
	register_clcmd( "say_team /depozit", "ClCmdSayDepozit" );
	register_clcmd( "say_team /deposit", "ClCmdSayDepozit" );
	
	register_clcmd( "say /retrage", "ClCmdSayRetrage" );
	register_clcmd( "say /withdraw", "ClCmdSayRetrage" );
	register_clcmd( "say_team /retrage", "ClCmdSayRetrage" );
	register_clcmd( "say_team /withdraw", "ClCmdSayRetrage" );
	
	register_clcmd( "fcs_credite", "ClCmdCredits" );
	register_clcmd( "fcs_credits", "ClCmdCredits" );
	
	register_clcmd( "amx_give_credits", "ClCmdGiveCredits" );
	register_clcmd( "amx_take_credits", "ClCmdTakeCredits" );
	
	RegisterHam( Ham_Spawn, "player", "ham_SpawnPlayerPost", true );
	register_forward( FM_ClientUserInfoChanged, "Fwd_ClientUserInfoChanged" );

}

public plugin_natives()
{
	
	register_library( "fcs" );
	register_native( "fcs_get_user_credits", "_fcs_get_user_credits" );
	register_native( "fcs_set_user_credits", "_fcs_set_user_credits" );
	
}

public _fcs_get_user_credits( iPlugin, iParams )
{
	return g_iUserCredits[  get_param( 1 )  ];
}

public _fcs_set_user_credits(  iPlugin, iParams  )
{
	new id = get_param( 1 );
	g_iUserCredits[ id ] = max( 0, get_param( 2 ) );
	SaveCredits( id );
	return g_iUserCredits[ id ];
}

public client_authorized( id )
{
	if( is_user_bot( id ) )
		return PLUGIN_CONTINUE;
	
	g_iUserRetired[ id ] = 0;
	get_user_name( id, g_szName[ id ], sizeof ( g_szName[] ) -1 );
	LoadCredits( id );
	
	return PLUGIN_CONTINUE;
	
}

public client_disconnect( id )
{
	if( is_user_bot( id ) )
		return PLUGIN_CONTINUE;
		
	g_iUserRetired[ id ] = 0;
	SaveCredits( id );
	
	return PLUGIN_CONTINUE;
	
}

public ClCmdSay( id )
{
	static szArgs[192];
	read_args( szArgs, sizeof ( szArgs ) -1 );
	
	if( !szArgs[ 0 ] )
		return PLUGIN_CONTINUE;
	
	new szCommand[ 15 ];
	remove_quotes( szArgs );
	
	if( equal( szArgs, "/credite", strlen( "/credite" ) )
		|| equal( szArgs, "/credits", strlen( "/credits" ) ) )
	{
		replace( szArgs, sizeof ( szArgs ) -1, "/", "" );
		formatex( szCommand, sizeof ( szCommand ) -1, "fcs_%s", szArgs );
		client_cmd( id, szCommand );
		return PLUGIN_HANDLED;
	}
	
	return PLUGIN_CONTINUE;
}

public ClCmdCredits( id )
{
	if( !is_user_connected( id ) )
		return PLUGIN_HANDLED;
		
	new szArg[ 32 ];
    	read_argv( 1, szArg, sizeof ( szArg ) -1 );

	if( equal( szArg, "" ) ) 
	{
		
		ColorChat( id, RED, "^x04%s^x01 Ai^x03 %i^x01 credite.", g_szTag, g_iUserCredits[ id ] );
		return PLUGIN_HANDLED;
	}
	
    	new iPlayer = cmd_target( id, szArg, 8 );
    	if( !iPlayer || !is_user_connected( iPlayer ) )
	{
		ColorChat( id, RED,"^x04%s^x01 Jucatorul specificat nu a fost gasit!", g_szTag, szArg );
		return PLUGIN_HANDLED;
	}

	new szName[ 32 ];
	get_user_name( iPlayer, szName, sizeof ( szName ) -1 );
	ColorChat( id, RED,"^x04%s^x01 Jucatorul^x03 %s^x01 are^x03 %i^x01 credit%s", g_szTag, szName, g_iUserCredits[ iPlayer ], g_iUserCredits[ iPlayer ] == 1 ? "." : "e." );
	
	return PLUGIN_HANDLED;
	
}

public ClCmdSayDepozit( id)
{
	
	if( !is_user_connected( id ) )
		return PLUGIN_HANDLED;
		
	new CsTeams:iTeam = cs_get_user_team( id );
	
	if( CS_TEAM_T <= iTeam <= CS_TEAM_CT )
	{
		new iMoney = cs_get_user_money( id );
		if( iMoney >= 16000 )
		{
			
			ColorChat( id, RED, "^x04%s^x01 Ai depozitat^x03 16000$^x01 si ai primit^x03 1^x01 credit.", g_szTag );
			cs_set_user_money( id, 0 );
			g_iUserCredits[ id ] += 1;
			
			SaveCredits( id );
			return PLUGIN_HANDLED;
		}
		else
		{
			ColorChat( id, RED, "^x04%s^x01 Iti trebuie^x03 16000$^x01 pentru a putea depozita.", g_szTag );
			return PLUGIN_HANDLED;
		}
	}
	
	return PLUGIN_HANDLED;

}

public ClCmdSayRetrage( id)
{
	
	new CsTeams:iTeam = cs_get_user_team( id );
	
	if( CS_TEAM_T <= iTeam <= CS_TEAM_CT )
	{
		
		if( g_iUserCredits[ id ] > 0 )
		{
			new iMaxRetrieve = get_pcvar_num( g_iCvarRetire );
			if( iMaxRetrieve > 0 )
			{
				if( g_iUserRetired[ id ] >= iMaxRetrieve )
				{
					ColorChat( id, RED, "^x04%s^x01 Ai retras deja^x03 %i^x01 credit%s runda asta^x01.", g_szTag, iMaxRetrieve, iMaxRetrieve == 1 ? "" : "e" );
					return PLUGIN_HANDLED;
				}
			}
			
			new iMoney = cs_get_user_money( id );
			
			ColorChat( id, RED, "^x04%s^x01 Ai retras^x03 1^x01 credit si, ai primi^x03 16000$^x01.", g_szTag );
			cs_set_user_money( id, iMoney + 16000 );
			
			g_iUserCredits[ id ] -=1;
			g_iUserRetired[ id ]++;
			
			SaveCredits( id );
			
			if( ( iMoney + 16000 ) > 16000 )
			{
				ColorChat( id, RED, "^x04%s^x03 ATENTIE^x01, ai^x03 %i$^x01 !", g_szTag, iMoney + 16000 );
				ColorChat( id, RED, "^x04%s^x01 La spawn, vei pierde tot ce depaseste suma de^x03 16000$^x01.", g_szTag );
				return PLUGIN_HANDLED;
			}
		}
		else
		{
			ColorChat(id, RED, "^x04%s^x03 NU^x01 ai ce sa retragi, ai^x03 0^x01 credite.", g_szTag );
			return PLUGIN_HANDLED;
		}
		
	}
	
	return PLUGIN_HANDLED;

}

public ClCmdGiveCredits( id )
{
	
	if( !( get_user_flags( id ) & read_flags( g_szGiveCreditsFlag ) ) )
	{
		client_cmd( id, "echo NU ai acces la aceasta comanda!" );
		return PLUGIN_HANDLED;
	}
	
	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_credits < nume/ @ALL/ @T/ @CT > < credite >" );
		return PLUGIN_HANDLED;
	}
	
	new iPlayers[ 32 ];
	new iPlayersNum;
	
	new iCredits = str_to_num( szSecondArg );
	if( iCredits <= 0 )
	{
		client_cmd( id, "echo Valoare creditelor trebuie sa fie mai mare decat 0!" );
		return PLUGIN_HANDLED;
	}
	
	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_iUserCredits[ iPlayers[ i ] ] += iCredits;
						
					new szName[ 32 ];
					get_user_name( id, szName, sizeof ( szName ) -1 );
					ColorChat( 0, RED, "^x04^%s^x01 Adminul^x03 %s^x01 le-a dat^x03 %i^x01 credite tuturor jucatorilor!", g_szTag, szName, iCredits );
					return PLUGIN_HANDLED;
				}
			}
			
			case 'T':
			{
				if( equal( szFirstArg, "@T" ) )
				{
					
					get_players( iPlayers, iPlayersNum, "ceh", "TERRORIST" );
					if( iPlayersNum == 0 )
					{
						client_cmd( id, "echo NU se afla niciun jucator in aceasta echipa!" );
						return PLUGIN_HANDLED;
					}
					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserCredits[ iPlayers[ i ] ] += iCredits;
						
					new szName[ 32 ];
					get_user_name( id, szName, sizeof ( szName ) -1 );
					ColorChat( 0, RED, "^x04^%s^x01 Adminul^x03 %s^x01 le-a dat^x03 %i^x01 credite jucatorilor de la^x03 TERO^x01!", g_szTag, szName, iCredits );
					return PLUGIN_HANDLED;
				}
			}
			
			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 PLUGIN_HANDLED;
					}
					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserCredits[ iPlayers[ i ] ] += iCredits;
						
					new szName[ 32 ];
					get_user_name( id, szName, sizeof ( szName ) -1 );
					ColorChat( 0, RED, "^x04^%s^x01 Adminul^x03 %s^x01 le-a dat^x03 %i^x01 credite jucatorilor de la^x03 CT^x01!", g_szTag, szName, iCredits );
					return PLUGIN_HANDLED;
				}
			}
		}
	}
		
	new iPlayer = cmd_target( id, szFirstArg, 8 );
	if( !iPlayer )
	{
		client_cmd( id, "echo Jucatorul %s nu a fost gasit!", szFirstArg );
		return PLUGIN_HANDLED;
	}
	
	g_iUserCredits[ iPlayer ] += iCredits;
	
	new szName[ 32 ], _szName[ 32 ];
	get_user_name( id, szName, sizeof ( szName ) -1 );
	get_user_name( iPlayer, _szName, sizeof ( _szName ) -1 );
	
	ColorChat( 0, RED, "^x04%s^x01 Adminul^x03 %s^x01 i-a dat^x03 %i^x01 credite lui^x03 %s^x01.", g_szTag, szName, iCredits, _szName );
	
	return PLUGIN_HANDLED;
	
	
}

public ClCmdTakeCredits( id )
{
	
	if( !( get_user_flags( id ) & read_flags( g_szGiveCreditsFlag ) ) )
	{
		client_cmd( id, "echo NU ai acces la aceasta comanda!" );
		return PLUGIN_HANDLED;
	}
	
	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_credits < nume > < credite >" );
		return PLUGIN_HANDLED;
	}
	
	new iCredits = str_to_num( szSecondArg );
	if( iCredits <= 0 )
	{
		client_cmd( id, "echo Valoarea creditelor trebuie sa fie mai mare decat 0!" );
		return PLUGIN_HANDLED;
	}
			
	new iPlayer = cmd_target( id, szFirstArg, 8 );
	if( !iPlayer )
	{
		client_cmd( id, "echo Jucatorul %s nu a fost gasit!", szFirstArg );
		return PLUGIN_HANDLED;
	}
	
	if( g_iUserCredits[ iPlayer ] < iCredits )
	{
		client_cmd( id, "echo Jucatorul %s nu are atatea credite!Are doar %i", szFirstArg, g_iUserCredits[ iPlayer ] );
		return PLUGIN_HANDLED;
	}
	
	g_iUserCredits[ iPlayer ] -= iCredits;
	
	new szName[ 32 ], _szName[ 32 ];
	get_user_name( id, szName, sizeof ( szName ) -1 );
  	get_user_name( iPlayer, _szName, sizeof ( _szName ) -1 );
	
	ColorChat( 0, RED, "^x04%s^x01 Adminul^x03 %s^x01 i-a sters^x03 %i^x01 credite lui^x03 %s^x01.", g_szTag, szName, iCredits, _szName );
	
	return PLUGIN_HANDLED;
	
	
}

public ham_SpawnPlayerPost( id )
{
	if( !is_user_alive( id ) )
		return;
		
	g_iUserRetired[ id ] = 0;
}

public Fwd_ClientUserInfoChanged( id, szBuffer )
{
	if ( !is_user_connected( id ) ) 
		return FMRES_IGNORED;
	
	static szNewName[ 32 ];
	
	engfunc( EngFunc_InfoKeyValue, szBuffer, "name", szNewName, sizeof ( szNewName ) -1 );
	
	if ( equal( szNewName, g_szName[ id ] ) )
		return FMRES_IGNORED;
	
	SaveCredits(  id  );
	
	ColorChat( id, RED, "^x04%s^x01 Tocmai ti-ai schimbat numele din^x03 %s^x01 in^x03 %s^x01 !", g_szTag, g_szName[ id ], szNewName );
	ColorChat( id, RED, "^x04%s^x01 Am salvat^x03 %i^x01 credite pe numele^x03 %s^x01 !", g_szTag, g_iUserCredits[ id ], g_szName[ id ] );
	
	copy( g_szName[ id ], sizeof ( g_szName[] ) -1, szNewName );
	LoadCredits( id );
	
	ColorChat( id, RED, "^x04%s^x01 Am incarcat^x03 %i^x01 credite de pe noul nume (^x03 %s^x01 ) !", g_szTag, g_iUserCredits[ id ], g_szName[ id ] );
	
	return FMRES_IGNORED;
}


public LoadCredits( id )
{
	iVault  =  nvault_open(  "FurienCreditsSystem"  );
	
	if(  iVault  ==  INVALID_HANDLE  )
	{
		set_fail_state(  "nValut returned invalid handle!"  );
	}
	
	static szData[ 256 ],  iTimestamp;
	
	if(  nvault_lookup( iVault, g_szName[ id ], szData, sizeof ( szData ) -1, iTimestamp ) )
	{
		static szCredits[ 15 ];
		parse( szData, szCredits, sizeof ( szCredits ) -1 );
		g_iUserCredits[ id ] = str_to_num( szCredits );
		return;
	}
	else
	{
		g_iUserCredits[ id ] = get_pcvar_num( g_iCvarEntry );
	}
	
	nvault_close( iVault );
	
}


public SaveCredits(  id  )
{
	iVault  =  nvault_open(  "FurienCreditsSystem"  );
	
	if(  iVault  ==  INVALID_HANDLE  )
	{
		set_fail_state(  "nValut returned invalid handle!"  );
	}
	
	static szData[ 256 ];
	formatex( szData, sizeof ( szData ) -1, "%i", g_iUserCredits[ id ] );
	
	nvault_set( iVault, g_szName[ id ], szData );
	nvault_close( iVault );
}

public plugin_end( )
{
	iVault  =  nvault_open(  "FurienCreditsSystem"  );
	
	if(  iVault  ==  INVALID_HANDLE  )
	{
		set_fail_state(  "nValut returned invalid handle!"  );
	}
	
	new iDays = get_pcvar_num( g_iCvarPruneDays );
	if( iDays > 0 )
	{
		nvault_prune( iVault, 0, get_systime( ) - ( iDays * ONE_DAY_IN_SECONDS ) );
	}
	
	nvault_close( iVault );
}

// |-- CC_ColorChat --|

ColorChat(  id, Color:iType, const msg[  ], { Float, Sql, Result, _}:...  )
{
	
	// Daca nu se afla nici un jucator pe server oprim TOT. Altfel dam de erori..
	if( !get_playersnum( ) ) return;
	
	new szMessage[ 256 ];

	switch( iType )
	{
		 // Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
		case NORMAL:	szMessage[ 0 ] = 0x01;
		
		// Culoare Verde.
		case GREEN:	szMessage[ 0 ] = 0x04;
		
		// Alb, Rosu, Albastru.
		default: 	szMessage[ 0 ] = 0x03;
	}

	vformat(  szMessage[ 1 ], 251, msg, 4  );

	// Ne asiguram ca mesajul nu este mai lung de 192 de caractere.Altfel pica server-ul.
	szMessage[ 192 ] = '^0';
	

	new iTeam, iColorChange, iPlayerIndex, MSG_Type;
	
	if( id )
	{
		MSG_Type  =  MSG_ONE_UNRELIABLE;
		iPlayerIndex  =  id;
	}
	else
	{
		iPlayerIndex  =  CC_FindPlayer(  );
		MSG_Type = MSG_ALL;
	}
	
	iTeam  =  get_user_team( iPlayerIndex );
	iColorChange  =  CC_ColorSelection(  iPlayerIndex,  MSG_Type, iType);

	CC_ShowColorMessage(  iPlayerIndex, MSG_Type, szMessage  );
		
	if(  iColorChange  )	CC_Team_Info(  iPlayerIndex, MSG_Type,  TeamName[ iTeam ]  );

}

CC_ShowColorMessage(  id, const iType, const szMessage[  ]  )
{
	
	static bool:bSayTextUsed;
	static iMsgSayText;
	
	if(  !bSayTextUsed  )
	{
		iMsgSayText  =  get_user_msgid( "SayText" );
		bSayTextUsed  =  true;
	}
	
	message_begin( iType, iMsgSayText, _, id  );
	write_byte(  id  );		
	write_string(  szMessage  );
	message_end(  );
}

CC_Team_Info( id, const iType, const szTeam[  ] )
{
	static bool:bTeamInfoUsed;
	static iMsgTeamInfo;
	if(  !bTeamInfoUsed  )
	{
		iMsgTeamInfo  =  get_user_msgid( "TeamInfo" );
		bTeamInfoUsed  =  true;
	}
	
	message_begin( iType, iMsgTeamInfo, _, id  );
	write_byte(  id  );
	write_string(  szTeam  );
	message_end(  );

	return PLUGIN_HANDLED;
}

CC_ColorSelection(  id, const iType, Color:iColorType)
{
	switch(  iColorType  )
	{
		
		case RED:	return CC_Team_Info(  id, iType, TeamName[ 1 ]  );
		case BLUE:	return CC_Team_Info(  id, iType, TeamName[ 2 ]  );
		case GREY:	return CC_Team_Info(  id, iType, TeamName[ 0 ]  );

	}

	return PLUGIN_CONTINUE;
}

CC_FindPlayer(  )
{
	new iMaxPlayers  =  get_maxplayers(  );
	
	for( new i = 1; i <= iMaxPlayers; i++ )
		if(  is_user_connected( i )  )
			return i;
	
	return -1;
}

// |-- CC_ColorChat --|
Alankizziixx is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-27-2019 , 07:17   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #282

Here.

Modify the number of credits for each level from the new const g_iCredits[][Reward] part of the code:

PHP Code:
{
    { 
levelcredits },
    { 
levelcredits },
    { 
levelcredits }

You will receive the set amount of credits when reaching each of the specified levels.

PHP Code:
#include <amxmodx>
#include <cromchat>
#include <crxranks>
#include <fcs>

enum _:Reward LevelCredits }

new const 
g_iCredits[][Reward] =
{
    { 
330 },
    { 
555 },
    { 
10250 },
    { 
201000 },
    { 
302500 }
}

new 
Trie:g_tCredits
new Trie:g_tRankNames

public plugin_init()
{
    
register_plugin("CRXRanks: FCS Credits""1.0""OciXCrom")

    
g_tCredits TrieCreate()
    
g_tRankNames TrieCreate()

    for(new 
szLevel[CRXRANKS_MAX_XP_LENGTH], szRank[CRXRANKS_MAX_RANK_LENGTH], isizeof(g_iCredits); i++)
    {
        
num_to_str(g_iCredits[i][Level], szLevelcharsmax(szLevel))
        
TrieSetCell(g_tCreditsszLevelg_iCredits[i][Credits])
        
crxranks_get_rank_by_level(g_iCredits[i][Level], szRankcharsmax(szRank))
        
TrieSetString(g_tRankNamesszLevelszRank)
    }
}

public 
plugin_end()
{
    
TrieDestroy(g_tCredits)
    
TrieDestroy(g_tRankNames)
}

public 
crxranks_user_level_updated(idiLevelbool:bLevelUp)
{
    if(!
bLevelUp)
    {
        return
    }

    new 
szLevel[CRXRANKS_MAX_XP_LENGTH]
    
num_to_str(iLevelszLevelcharsmax(szLevel))

    if(
TrieKeyExists(g_tCreditsszLevel))
    {
        new 
szRank[CRXRANKS_MAX_RANK_LENGTH], iCredits
        TrieGetCell
(g_tCreditsszLeveliCredits)
        
TrieGetString(g_tRankNamesszLevelszRankcharsmax(szRank))
        
fcs_add_user_credits(idiCredits)
        
CC_SendMessage(id"You have advanced to &x03%s &x01and received &x04%i credits&x01."szRankiCredits)
    }

__________________

Last edited by OciXCrom; 06-27-2019 at 17:45.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Alankizziixx
Member
Join Date: Jun 2019
Old 06-27-2019 , 13:46   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #283

You can help me to show up a chat message for example:
You have advanced to silver 2 and received 50 credits?
Alankizziixx is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-27-2019 , 17:44   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #284

Quote:
Originally Posted by Alankizziixx View Post
You can help me to show up a chat message for example:
You have advanced to silver 2 and received 50 credits?
I edited the code above.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Alankizziixx
Member
Join Date: Jun 2019
Old 06-28-2019 , 06:34   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #285

THANKS!
Alankizziixx is offline
HishamGamer
Junior Member
Join Date: Dec 2018
Location: Black hole.
Old 07-21-2019 , 09:50   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #286

Best rank plugin ever.
__________________
The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart.
-Helen Keller

Always do your best. What you plant now, you will harvest later.
-Og Mandino


Last edited by HishamGamer; 07-21-2019 at 10:01.
HishamGamer is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-22-2019 , 12:35   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #287

I was avoiding this since it's quite a big plugin, but here we go.

1.#define USE_CSTRIKE could be replaced. You could use get_modname to automatically determine if the game is cstrike or not. You will have to unconditionally include csx and chromchat, but that's not terrible and the user would not need to edit anything. Any thoughts?

2.

PHP Code:
#if !defined client_disconnected
    #define client_disconnected client_disconnect
#endif

#if !defined replace_string
    #define replace_string replace_all
#endif

#if !defined MAX_NAME_LENGTH
const MAX_NAME_LENGTH 32
#endif

#if !defined MAX_PLAYERS
const MAX_PLAYERS 32
#endif 
You could move the defines inside the amxx version check with a bit of refactoring as they were introduced in 1.8.3. This wouldn't catch older 1.8.3 builds without this functions/forwards, but you don't have to support every possible build out there. It's fine to assume/require the latest build, but if you want to work more and support everyone, all power to you since we are kinda in a grey area, with 1.8.2 still being stable and people still using different 1.8.3 and 1.9 builds.

3.
https://htmlpreview.github.io/?https..._keywords.html
Are you sure this link is still up to date? It doesn't work for me.

4.goto should be avoided in general. People tend to go crazy with it and potentially use it instead if/while/for/break. If you ever wrote assembly code where goto is the only flow control instruction you'll understand why this makes code much harder to understand and more prone to errors. However, what you did is pretty clean I'd say so feel free to keep it like that.
Just don't go crazy with gotos please.

5.Inside ReadFile:

PHP Code:
szData[0] = ' '
szData[iSize 1] = ' '
trim(szData
could simply be
PHP Code:
replace(szDatacharsmax(szData), "-"""
as it appears you want to strip leading and trailing "-".

You could check if the sound file exists before precaching and throw an error to inform the user in case it doesn't. For model/sprites this also has the advantage to prevent a crash.

PHP Code:
ArrayPushCell(g_aLevelsg_iMaxLevels == clamp(str_to_num(szValue), 0)) 
What is your intention with the clamp? To prevent negative values? Then you should use max instead of clamp.

6.save_or_load:

Any reason for static(szQuery, szPlayer, szPlayer, iData, ...)? Static should be used only when you want to preserve the value of the variable. I'm not going to point out all places where static should be new, but unless you are inside of a loop or you want to save the value between function calls use new.

Spoiler


aaaand I got bored. For now at least.
__________________
HamletEagle is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-22-2019 , 14:05   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #288

Quote:
#define USE_CSTRIKE could be replaced. You could use get_modname to automatically determine if the game is cstrike or not. You will have to unconditionally include csx and chromchat, but that's not terrible and the user would not need to edit anything. Any thoughts?
I guess you're right. I only did that to avoid including unnecessary files. I changed it now.

Quote:
You could move the defines inside the amxx version check with a bit of refactoring as they were introduced in 1.8.3. This wouldn't catch older 1.8.3 builds without this functions/forwards, but you don't have to support every possible build out there. It's fine to assume/require the latest build, but if you want to work more and support everyone, all power to you since we are kinda in a grey area, with 1.8.2 still being stable and people still using different 1.8.3 and 1.9 builds.
I ended up doing the checks in that manner because there were some users who were experiencing issues, mainly because they use older 1.8.3 dev-builds, at least in the earlier days.

I agree with you that only the latest dev-build should be supported + 1.8.2 for the moment, I even tell users that all the time, but for the time being, I'll keep them like that to avoid any problems until 1.9 is officially released.

Quote:
https://htmlpreview.github.io/?https..._keywords.html
Are you sure this link is still up to date? It doesn't work for me.
It's working fine for me - https://i.imgur.com/YLHEjUP.png . Tested it on my phone as well I send this to people all the time, it's probably a problem from your side.

Quote:
goto should be avoided in general. People tend to go crazy with it and potentially use it instead if/while/for/break. If you ever wrote assembly code where goto is the only flow control instruction you'll understand why this makes code much harder to understand and more prone to errors. However, what you did is pretty clean I'd say so feel free to keep it like that.
Just don't go crazy with gotos please.
Got it. I attempt to avoid using it whenever possible, but sometimes I find myself trapped with all the different settings I make for my plugins, so "goto" seems like the easiest way out.

Quote:
Inside ReadFile:

PHP Code:
szData[0] = ' '
szData[iSize 1] = ' '
trim(szData
could simply be

PHP Code:
replace(szDatacharsmax(szData), "-"""
as it appears you want to strip leading and trailing "-".
I only want to strip the first and last "-", but keep every other one. I use this as a "container" for a map name, e.g. "- de_dust2 -", but map names can also contain "-", so I can't replace all of those symbols.

Quote:
You could check if the sound file exists before precaching and throw an error to inform the user in case it doesn't. For model/sprites this also has the advantage to prevent a crash.
I added an error check for precaching the sounds.

Quote:
What is your intention with the clamp? To prevent negative values? Then you should use max instead of clamp.
Yes, my intention is to prevent negative values. I' changed it to "max".

Quote:
Any reason for static(szQuery, szPlayer, szPlayer, iData, ...)? Static should be used only when you want to preserve the value of the variable. I'm not going to point out all places where static should be new, but unless you are inside of a loop or you want to save the value between function calls use new.
Shouldn't it also be used when dealing with large arrays? I don't know what is exactly considered "large", but I found 256 bigger than usual, especially since the function can be called up to 32 times at once. I changed "iData" though.

Quote:
Why not go for the full 32 bits? 0x00000000. Don't see the point for hex here, 0 is too old for 2019?
Styling was probably in my mind then. It keeps it in line with the two other "write_short"s above it.

Quote:
aaaand I got bored. For now at least.
No worries. I feel your pain.

//Edit: Github is having some trouble at the moment and doesn't want to upload new files. Here's the updated code if you decide to continue reviewing before I manage to upload it.
__________________

Last edited by OciXCrom; 07-22-2019 at 14:05.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Old 07-22-2019, 15:23
HamletEagle
This message has been deleted by HamletEagle.
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 07-22-2019 , 15:49   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #289

The link its dead here too

Error: Cannot load https..._keywords.html: 404 Invalid host
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-22-2019 , 18:48   Re: OciXCrom's Rank System [XP|Levels|Ranks]
Reply With Quote #290

Not sure why it isn't working for you. You can use the raw link to view the html file - https://github.com/OciXCrom/RankSyst..._keywords.html

I just used htmlpreview.github.io to render it as a webpage.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply


Thread Tools
Display Modes

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 06:40.


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