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" );
}
Код за потвърждение: Избери целия код
#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 );