Code:
#include < amxmodx >
#include < amxmisc >
#define PLUGIN_NAME "[Tutor Text] Example"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "LondoN eXtream"
enum
{
COLOR_RED = 1,
COLOR_BLUE,
COLOR_YELLOW,
COLOR_GREEN
};
new g_pMessage_Tutor, g_pMessage_TutorClose;
public plugin_init ( )
{
register_plugin ( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR );
g_pMessage_Tutor = get_user_msgid ( "TutorText" );
g_pMessage_TutorClose = get_user_msgid ( "TutorClose" );
register_clcmd ( "say /tutor", "pEntityCommand_ShowTutorMenu" );
}
public pEntityCommand_ShowTutorMenu ( pEntity )
{
new iMenu = menu_create ( "\wCreate Tutor", "TUTOR_HANDLER" );
menu_additem ( iMenu, "\wRed Tutor" );
menu_additem ( iMenu, "\wBlue Tutor" );
menu_additem ( iMenu, "\wYellow Tutor" );
menu_additem ( iMenu, "\wGreen Tutor" );
menu_setprop ( iMenu, MPROP_EXIT, MEXIT_ALL );
menu_display ( pEntity, iMenu, 0 );
return 1;
}
public TUTOR_HANDLER ( pEntity, pMenu, pKey )
{
if ( pKey == MENU_EXIT )
{
menu_destroy ( pMenu );
return 1;
}
new g_szSample [ 128 ];
formatex ( g_szSample, charsmax ( g_szSample ), "This is an example text" );
switch ( pKey )
{
case 0: CreateTutor ( pEntity, g_szSample, COLOR_RED, 3.0 );
case 1: CreateTutor ( pEntity, g_szSample, COLOR_BLUE, 3.0 );
case 2: CreateTutor ( pEntity, g_szSample, COLOR_YELLOW, 3.0 );
case 3: CreateTutor ( pEntity, g_szSample, COLOR_GREEN, 3.0 );
}
return 1;
}
CreateTutor ( pEntity, g_szSample [ ], COLOR_NAME, Float: pTutorTime = 0.0 )
{
message_begin ( MSG_ONE, g_pMessage_Tutor, {0, 0, 0}, pEntity );
write_string ( g_szSample );
write_byte ( 0 );
write_short ( 0 );
write_short ( 0 );
write_short ( 1<<COLOR_NAME );
message_end ( );
if ( pTutorTime != 0.0 )
set_task ( pTutorTime, "RemoveTutor", pEntity );
}
public RemoveTutor ( pEntity )
{
message_begin ( MSG_ONE, g_pMessage_TutorClose, {0, 0, 0}, pEntity );
message_end ( );
}