Achievement Progress on the MOTD

В този раздел можете да подавате всякакви заявки за намиране, изработка или преработка на плъгини/модове.
Аватар
X3.!
Извън линия
Foreigner
Foreigner
Мнения: 31
Регистриран на: 30 Ное 2018, 20:46
Се отблагодари: 1 път

Achievement Progress on the MOTD

Мнение от X3.! » 17 Дек 2018, 13:56

Hi everyone.

So im using Achievements API by Xellaht (HERE https://forums.alliedmods.net/showthread.php?t=166091)
So in Achievement_motd plugin it display a motd with the following informations : Achievement name - Achievement Description - Earned, if its done or not, yes if its done, no if not

So I want to add Achievement progress instead of the (Achievement Earned, the last one) to disaply the achievement progress for example< connect 500 times ( the addict achievement, display how many connects you have made like 235/500 and so on.)
Here is the code of achievement MOTD

Код за потвърждение: Избери целия код

#include < amxmodx >
#include < achievement_api >

const MaxClients = 32;
const MaxSteamIdChars = 35;

public plugin_init( )
{
	register_plugin( "Achievement API: MOTD Info", "0.0.1", "Xellath" );

	register_clcmd( "say /achievements", "ClientCommand_AchievementMenu" );
}

public ClientCommand_AchievementMenu( Client ) 
{ 
	if( is_user_connected( Client ) ) 
	{ 
		ShowAchievementMenu( Client ); 
	} 

	return PLUGIN_HANDLED; 
} 

ShowAchievementMenu( const Client ) 
{ 
	new Title[ 256 ]; 
	formatex( Title, charsmax( Title ),  
		"\r[ \yAchievement API \r]^n\wAchievements Menu^n^nAchievements Earned: \y%i of %i\w^n^n",  
		GetClientAchievementsCompleted( Client ),  
		GetMaxAchievements( )
		); 

	new Menu = menu_create( Title, "AchievementMenuHandler" ); 

	menu_additem( Menu, "List Achievements (MOTD)^n", "*" ); 

	menu_display( Client, Menu ); 
}

public AchievementMenuHandler( Client, Menu, Item )
{
	if( Item == MENU_EXIT )
	{
		menu_destroy( Menu );

		return;
	}
	
	new Info[ 2 ], Access, Callback;
	menu_item_getinfo( Menu, Item, Access, Info, charsmax( Info ), _, _, Callback );
	menu_destroy( Menu );
	
	if( Info[ 0 ] == '*' )
	{
		ListAchievements( Client );
	}
}

ListAchievements( const Client ) 
{ 
	if( !is_user_connected( Client ) ) 
	{ 
		return; 
	} 
	
	new Motd[ 1536 ], Char;
	Char = formatex( Motd, 1535 - Char, "<style>" ); 
	Char += formatex( Motd[ Char ], 1535 - Char, "body{margin:0;padding:0;font-family:Tahoma,Helvetica,Arial,sans-serif;}table,tr,td{align:center;color:#222;background:#fff;margin:1;padding:1;border:solid #eee 1px;}" ); 
	
	Char += formatex( Motd[ Char ], 1535 - Char, "</style><body>" ); 
	Char += formatex( Motd[ Char ], 1535 - Char, "<table width=^"600^">" );
	Char += formatex( Motd[ Char ], 1535 - Char, "<tr><td><b>Achievement Name</b></td><td><b>Description</b></td><td><b>Earned</b></td></tr>" );
	
	new AchievementName[ MaxClients ], AchievementDesc[ 256 ], AchievementSaveName[ MaxClients ], ObjectiveData, SteamId[ MaxSteamIdChars ];
	for( new AchievementIndex = 0; AchievementIndex < GetMaxAchievements( ); AchievementIndex++ )
	{
		get_user_authid( Client, SteamId, charsmax( SteamId ) );
		
		GetAchievementName( AchievementIndex, AchievementName );
		GetAchievementDesc( AchievementIndex, AchievementDesc );
		
		GetAchievementSaveKey( AchievementIndex, AchievementSaveName );
		
		ObjectiveData = GetAchievementData( SteamId, AchievementSaveName );
		
		Char += formatex( Motd[ Char ], 1535 - Char, "<tr><td>%s</td><td>%s</td><td>%s</td></tr>",
			AchievementName,
			AchievementDesc,
			( ( ObjectiveData >= GetAchievementMaxValue( AchievementIndex ) ) ? "Yes" : "No" )
			);
	}
	
	Char += formatex( Motd[ Char ], 1535 - Char, "</table></body>" ); 
	
	show_motd( Client, Motd, "Achievements" ); 
}
And here is the INCLUDE file

Код за потвърждение: Избери целия код

#if defined _achievement_api_included
    #endinput
#endif

#define _achievement_api_included

enum Status
{
	_In_Progress = 0,
	_Unlocked
};

/*
 * Registers an achievement
 * 
 * @param		Name - Achievement name
 * @param		Description - Description of objective to complete achievement
 * @param		SaveName - Save key that is used to set data
 * @param		MaxValue - Max value to complete achievement
 * 
 * @return 		Pointer to achievement
 */
native RegisterAchievement( const Name[ ], const Description[ ], const SaveName[ ], const MaxValue );

/*
 * Sets the current achievement status
 * 
 * @param		Client - Index of player
 * @param		AchievementPointer - Pointer from the registration of the achievement
 * @param		Announce - Whether to announce achievement earned or not (default: true)
 * 
 * @noreturn
 */
native ClientAchievementCompleted( const Client, AchievementPointer, bool:Announce = true );

/*
 * Gets the current achievement status
 * 
 * @param		AchievementPointer - Pointer from the registration of the achievement
 * @param		Objective - Client value to check whether its over max value or not
 * 
 * @return		Returns the current Status of achievement
 *
 * @note		enum Status
 *				{
 *					_In_Progress = 0,
 *					_Unlocked
 *				};
 */
native Status:GetClientAchievementStatus( AchievementPointer, Objective );

/*
 * Returns the name of the achievement
 * 
 * @param		AchievementPointer - Pointer from the registration of the achievement
 * @param		Description - Name passed by reference
 * 
 * @return		Returns the name by reference (2nd param)
 */
native GetAchievementName( AchievementPointer, Name[ ] );

/*
 * Returns the description of the achievement
 * 
 * @param		AchievementPointer - Pointer from the registration of the achievement
 * @param		Description - Description passed by reference
 * 
 * @return		Returns the description by reference (2nd param)
 */
native GetAchievementDesc( AchievementPointer, Description[ ] );

/*
 * Returns the save key that is required to complete achievement
 * 
 * @param		AchievementPointer - Pointer from the registration of the achievement
 * @param		SaveKey - Key passed by reference
 * 
 * @return		Returns the save key by reference (2nd param)
 */
native GetAchievementSaveKey( AchievementPointer, SaveKey[ ] );

/*
 * Returns the max value that is required to complete achievement
 * 
 * @param		AchievementPointer - Pointer from the registration of the achievement
 * 
 * @return		Returns the max value that is required to complete achievement
 */
native GetAchievementMaxValue( AchievementPointer );

/*
 * Returns the total number of achievements client has completed
 * 
 * @param		Client - Index of player
 * 
 * @return		Returns the total number of achievements client has completed
 */
native GetClientAchievementsCompleted( const Client );

/*
 * Returns the total number of achievements
 * 
 * @noparams
 * 
 * @return		Returns the total number of achievements
 */
native GetMaxAchievements( );

/*
 * Assign an integer value to Key in database/vault
 * 
 * @param		Key - Key to where to set data (mainly used as steamid)
 * @param		SaveName - Save name used in the init of an achievement (RegisterAchievement() param 4)
 * @param		Data - Integer value assigned to Key
 * 
 * @noreturn
 */
native SetAchievementData( const Key[ ], const SaveName[ ], Data );

/*
 * Gets an integer value from database/vault
 * 
 * @param		Key - Key to where to look for data (mainly used as steamid)
 * @param		SaveName - Save name used in the init of an achievement (RegisterAchievement() param 4)
 * 
 * @return		Returns the value on success, 0 on failure to get data (and if there is no progress)
 */
native GetAchievementData( const Key[ ], const SaveName[ ] );

/*
 * Called when a player has recently earned an achievement
 * 
 * @param		AchiPointer - Pointer to achievement
 * @param		Client - Index of player
 * 
 * @noreturn
 * 
 */
forward Forward_ClientEarnedAchievement( const AchiPointer, const Client );
I didnt post in scripting help because I have no idea how to do it :3
Последно промяна от OciXCrom на 17 Дек 2018, 20:51, променено общо 1 път.
Причина: Moved to "Plugin Requests".

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Achievement Progress on the MOTD

Мнение от OciXCrom » 17 Дек 2018, 20:53

Код за потвърждение: Избери целия код

#include < amxmodx >
#include < achievement_api >

const MaxClients = 32;
const MaxSteamIdChars = 35;

public plugin_init( )
{
	register_plugin( "Achievement API: MOTD Info", "0.0.1", "Xellath" );

	register_clcmd( "say /achievements", "ClientCommand_AchievementMenu" );
}

public ClientCommand_AchievementMenu( Client ) 
{ 
	if( is_user_connected( Client ) ) 
	{ 
		ShowAchievementMenu( Client ); 
	} 

	return PLUGIN_HANDLED; 
} 

ShowAchievementMenu( const Client ) 
{ 
	new Title[ 256 ]; 
	formatex( Title, charsmax( Title ),  
		"\r[ \yAchievement API \r]^n\wAchievements Menu^n^nAchievements Earned: \y%i of %i\w^n^n",  
		GetClientAchievementsCompleted( Client ),  
		GetMaxAchievements( )
		); 

	new Menu = menu_create( Title, "AchievementMenuHandler" ); 

	menu_additem( Menu, "List Achievements (MOTD)^n", "*" ); 

	menu_display( Client, Menu ); 
}

public AchievementMenuHandler( Client, Menu, Item )
{
	if( Item == MENU_EXIT )
	{
		menu_destroy( Menu );

		return;
	}
	
	new Info[ 2 ], Access, Callback;
	menu_item_getinfo( Menu, Item, Access, Info, charsmax( Info ), _, _, Callback );
	menu_destroy( Menu );
	
	if( Info[ 0 ] == '*' )
	{
		ListAchievements( Client );
	}
}

ListAchievements( const Client ) 
{ 
	if( !is_user_connected( Client ) ) 
	{ 
		return; 
	} 
	
	new Motd[ 1536 ], Char;
	Char = formatex( Motd, 1535 - Char, "<style>" ); 
	Char += formatex( Motd[ Char ], 1535 - Char, "body{margin:0;padding:0;font-family:Tahoma,Helvetica,Arial,sans-serif;}table,tr,td{align:center;color:#222;background:#fff;margin:1;padding:1;border:solid #eee 1px;}" ); 
	
	Char += formatex( Motd[ Char ], 1535 - Char, "</style><body>" ); 
	Char += formatex( Motd[ Char ], 1535 - Char, "<table width=^"600^">" );
	Char += formatex( Motd[ Char ], 1535 - Char, "<tr><td><b>Achievement Name</b></td><td><b>Description</b></td><td><b>Progress</b></td></tr>" );
	
	new AchievementName[ MaxClients ], AchievementDesc[ 256 ], AchievementSaveName[ MaxClients ], ObjectiveData, SteamId[ MaxSteamIdChars ];
	for( new AchievementIndex = 0; AchievementIndex < GetMaxAchievements( ); AchievementIndex++ )
	{
		get_user_authid( Client, SteamId, charsmax( SteamId ) );
		
		GetAchievementName( AchievementIndex, AchievementName );
		GetAchievementDesc( AchievementIndex, AchievementDesc );
		
		GetAchievementSaveKey( AchievementIndex, AchievementSaveName );
		
		ObjectiveData = GetAchievementData( SteamId, AchievementSaveName );
		
		Char += formatex( Motd[ Char ], 1535 - Char, "<tr><td>%s</td><td>%s</td><td>%i/%i</td></tr>",
			AchievementName,
			AchievementDesc,
			ObjectiveData,
			GetAchievementMaxValue( AchievementIndex )
			);
	}
	
	Char += formatex( Motd[ Char ], 1535 - Char, "</table></body>" ); 
	
	show_motd( Client, Motd, "Achievements" ); 
}

Аватар
X3.!
Извън линия
Foreigner
Foreigner
Мнения: 31
Регистриран на: 30 Ное 2018, 20:46
Се отблагодари: 1 път

Achievement Progress on the MOTD

Мнение от X3.! » 21 Дек 2018, 16:15

Thanks.
Tested it, there is a problem that it is counting only 1 time.
It still 1/500. no changes
Like I tried to change it from the nfvault, I edited it to 498. It shows 498, when I connected 2 times after it, I earned the achievment but still 498/500

Аватар
OciXCrom
Извън линия
Администратор
Администратор
Мнения: 7206
Регистриран на: 06 Окт 2016, 19:20
Местоположение: /resetscore
Се отблагодари: 117 пъти
Получена благодарност: 1295 пъти
Обратна връзка:

Achievement Progress on the MOTD

Мнение от OciXCrom » 21 Дек 2018, 16:32

If that's the case, the bug is in the Achievement API itself. There is no error in the code as far as I can tell.

Публикувай отговор
  • Подобни теми
    Отговори
    Преглеждания
     Последно мнение

Обратно към “Заявки за плъгини”

Кой е на линия

Потребители разглеждащи този форум: Semrush [Bot] и 31 госта