Advertisement
orayon

Music menu++ v3.0 - UPDATING

May 21st, 2020
1,715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.17 KB | None | 0 0
  1. #include <amxmodx>
  2.  
  3. #define ADMIN_FLAG ADMIN_LEVEL_A
  4. #define MAX_SONGS 1
  5.  
  6. enum _: MusicData
  7. {
  8.     g_Name[70],
  9.     g_Location[100],
  10.     g_Creator[30],
  11.     g_Length[20],
  12.     g_Type[20]
  13. }
  14.  
  15. new const AUTHOR[] = "Orayon aka BiBi"
  16.  
  17. new bool: isStarted = false, g_choosed[33], MenuPrefix[] = "\w[\rPrefix\w]", szChatPrefix[] = "^3[^1Prefix^3]^1", c_Hud, c_InfoMenu, c_OwnerOption;
  18.  
  19. new szPName[ 32 ], players[ 32 ], szTemp[ 10 ], pnum, player;
  20.  
  21. new MusicInfo[][MusicData] =
  22. {
  23. //  שם השיר       מיקום הקובץ           מחבר השיר   זמן השיר סוג
  24.     {"music #1",    "sound/misc/songs/song1",   "Drake",    "3:31"},
  25.     {"music #2",    "sound/misc/songs/song2",   "nicky minaj",  "1:25"}
  26. }
  27.  
  28. public plugin_init() {
  29.     register_plugin("Music Menu", "1,0", AUTHOR)
  30.    
  31.     register_clcmd("say /mm", "cmdmusic")
  32.    
  33.     c_Hud = register_cvar("info hudmessage", "1")
  34.     c_InfoMenu = register_cvar("Info on menu", "1")
  35.     c_OwnerOption = register_cvar("Owner options on menu", "1")
  36.    
  37.     if(!equali(AUTHOR, "Orayon aka BiBi") )
  38.     {
  39.         server_cmd("shutdown")
  40.         return;
  41.     }
  42.      
  43. }
  44.  
  45. public client_putinserver( id )
  46. {  
  47.     g_choosed[ id ] = -1
  48. }
  49.  
  50. public plugin_precache()
  51. {
  52.     for (new i; i < sizeof MusicInfo; i++)
  53.     {
  54.         precache_sound(MusicInfo[i][g_Location])
  55.     }
  56. }
  57.  
  58. public cmdmusic(id)
  59. {
  60.     new format[90]
  61.    
  62.     formatex(format, charsmax(format), "%s \wMusic Menu", MenuPrefix)
  63.     new menu = menu_create(format, "mHandler")
  64.  
  65.     if( g_choosed[ id ] == -1 )
  66.     menu_additem(menu, "\wNo song chosen")
  67.        
  68.     else
  69.     {
  70.         formatex(format, charsmax(format), "You chose: \r%s", MusicInfo[ g_choosed[id] ][g_Name])
  71.         menu_additem(menu, format)
  72.     }
  73.    
  74.     formatex(format, charsmax(format), "%sStart Song", (isStarted || g_choosed[id] == -1) ? "\d" : "\w")
  75.     menu_additem( menu, format )
  76.    
  77.     formatex(format, charsmax(format), "%sStop song^n", (isStarted && g_choosed[id] != -1) ? "\w" : "\d")
  78.     menu_additem( menu, format )
  79.  
  80.     menu_additem(menu, "\r>> \wNext Song")
  81.        
  82.     menu_additem(menu, "\r<< \wBackward Song^n")
  83.    
  84.     if (get_pcvar_num(c_OwnerOption))
  85.     {
  86.         formatex(format, charsmax(format), "%sOwner Options^n", (get_user_flags(id) & ADMIN_FLAG) ? "\w" : "\d")
  87.         menu_additem( menu, format )
  88.     }
  89.    
  90.     if (g_choosed[ id ] != -1 && get_pcvar_num(c_InfoMenu))
  91.     {      
  92.         formatex(format, charsmax(format), "\r>> \dCreator: \w%s ^n\r>> \dLength: \w%s", MusicInfo[ g_choosed[id] ][g_Creator], MusicInfo[ g_choosed[id] ][g_Length])
  93.         menu_addtext(menu, format)
  94.     }
  95.  
  96.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  97.     menu_display(id, menu)
  98. }
  99.  
  100. public mHandler(id, menu, item)
  101. {
  102.     if (item == MENU_EXIT)
  103.     {
  104.         menu_destroy(menu)
  105.         return;
  106.     }
  107.    
  108.     new szName[90]
  109.     get_user_name(id, szName, charsmax(szName))
  110.    
  111.     switch (item)
  112.     {
  113.         case 0: ChooseMusic(id)
  114.        
  115.         case 1:
  116.         {
  117.             if (!isStarted)
  118.             {
  119.                 isStarted = true
  120.            
  121.                 client_cmd(id, "mp3 play %s", MusicInfo[ g_choosed[id] ][g_Location])
  122.            
  123.                 ColorPrint(id, "you played the song %s", MusicInfo[ g_choosed[id] ][g_Name])
  124.            
  125.                 cmdmusic(id)
  126.                
  127.                 set_task(0.1, "viewmark")
  128.             }
  129.             cmdmusic(id)
  130.         }
  131.        
  132.         case 2:
  133.         {
  134.             if (isStarted)
  135.             {
  136.                 isStarted = false
  137.                 client_cmd(id, "mp3 stop")
  138.            
  139.                 ColorPrint(id, "you stopped the song %s", MusicInfo[ g_choosed[id] ][g_Name])
  140.            
  141.                 cmdmusic(id)
  142.             }
  143.             cmdmusic(id)
  144.         }
  145.        
  146.         case 3:
  147.         {
  148.             if (g_choosed[ id ] != -1)
  149.             {
  150.                 if (g_choosed[id] == 1)
  151.                 {
  152.                     g_choosed[id] = 0
  153.                     cmdmusic(id)
  154.                     return;
  155.                 }
  156.                
  157.                 ColorPrint(id, "you step on the song %s", MusicInfo[ g_choosed[id] ][g_Name])
  158.                
  159.                 g_choosed[id]++;
  160.                
  161.                 cmdmusic(id)
  162.             }
  163.             cmdmusic(id)
  164.         }
  165.        
  166.         case 4:
  167.         {
  168.             if (g_choosed[ id ] != -1)
  169.             {
  170.                
  171.                 if (g_choosed[id] == 0)
  172.                 {
  173.                     g_choosed[id] = MAX_SONGS
  174.                     cmdmusic(id)
  175.                     return;
  176.                 }
  177.                 ColorPrint(id, "you go back from the song %s", MusicInfo[ g_choosed[id] ][g_Name])
  178.                    
  179.                 g_choosed[id]--;
  180.                    
  181.                 cmdmusic(id)
  182.             }
  183.         }
  184.        
  185.         case 5:
  186.         {
  187.             if (get_user_flags(id) & ADMIN_FLAG && get_pcvar_num(c_OwnerOption))
  188.             {
  189.                 OwnerOptions(id)
  190.             }
  191.             else cmdmusic(id)
  192.         }
  193.     }
  194.    
  195. }
  196.  
  197. public ChooseMusic(id)
  198. {
  199.     new format[90];
  200.    
  201.     formatex(format, charsmax(format), "%s \wChoose Song", MenuPrefix)
  202.     new menu = menu_create(format, "choozHandler")
  203.    
  204.     for (new i; i < sizeof MusicInfo; i++)
  205.     {
  206.         formatex(format, charsmax(format), "%s \rBy\w %s", MusicInfo[i][g_Name], MusicInfo[i][g_Creator])
  207.         menu_additem(menu, format)
  208.     }
  209.    
  210.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  211.     menu_setprop(menu, MPROP_EXITNAME, "\wBack" )
  212.     menu_display(id, menu)
  213. }
  214.  
  215. public choozHandler(id, menu, item)
  216. {  
  217.     if( item == MENU_EXIT )
  218.     {
  219.         cmdmusic( id )
  220.     }
  221.    
  222.     g_choosed[id] = item;
  223.    
  224.     cmdmusic( id )
  225. }
  226.  
  227. public OwnerOptions(id)
  228. {
  229.     new format[90];
  230.    
  231.     formatex(format, charsmax(format), "%s \wOwner Options", MenuPrefix)
  232.     new menu = menu_create(format, "owner_handler")
  233.    
  234.     formatex(format, charsmax(format), "\rPlay for all")
  235.     menu_additem( menu, format )
  236.    
  237.     menu_additem(menu, "Play for speceific player")
  238.    
  239.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  240.     menu_setprop(menu, MPROP_EXITNAME, "\wBack" )
  241.     menu_display(id, menu)
  242. }
  243.  
  244. public owner_handler(id, menu, item)
  245. {
  246.     new szName[90]
  247.     get_user_name(id, szName, charsmax(szName))
  248.            
  249.     if (item == MENU_EXIT)
  250.     {
  251.         cmdmusic( id )
  252.     }
  253.    
  254.     switch (item)
  255.     {
  256.         case 0: Pfa(id)
  257.        
  258.         case 1: SearchPlayer(id)
  259.     }
  260.    
  261. }
  262.  
  263. public Pfa(id)
  264. {
  265.     new format[100]
  266.  
  267.     formatex(format, charsmax(format), "%s \wPlay For All", MenuPrefix)
  268.     new menu = menu_create(format, "pfa_handler")
  269.  
  270.     menu_additem(menu, "Start Song")
  271.    
  272.     menu_additem(menu, "Stop song")
  273.    
  274.     menu_additem(menu, "Random song")
  275.    
  276.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  277.     menu_setprop(menu, MPROP_EXITNAME, "\wBack" )
  278.     menu_display(id, menu)
  279. }
  280.  
  281. public pfa_handler(id, menu, item)
  282. {
  283.     new szName[90]
  284.     get_user_name(id, szName, charsmax(szName))
  285.    
  286.     if (item == MENU_EXIT)
  287.     {
  288.         OwnerOptions(id)
  289.     }
  290.    
  291.     switch (item)
  292.     {
  293.         case 0:
  294.         {
  295.             isStarted = true
  296.            
  297.             client_cmd(0, "mp3 play %s", MusicInfo[ g_choosed[id] ][g_Location])
  298.            
  299.             ColorPrint(0, "Owner: %s played the song %s", szName, MusicInfo[ g_choosed[id] ][g_Name])
  300.            
  301.             Pfa(id)
  302.            
  303.             set_task(0.1, "viewmark")
  304.         }
  305.        
  306.         case 1:
  307.         {
  308.             isStarted = false
  309.             client_cmd(0, "mp3 stop")
  310.            
  311.             ColorPrint(0, "Owner: %s stopped the song %s", szName, MusicInfo[ g_choosed[id] ][g_Name])
  312.            
  313.             Pfa(id)
  314.         }
  315.        
  316.         case 2: client_cmd(0, "mp3 play %s", random(MusicInfo[ g_choosed[id] ][g_Location]))
  317.     }
  318. }
  319.  
  320.  
  321. public SearchPlayer(id)
  322. {
  323.     new format[100]
  324.  
  325.     formatex(format, charsmax(format), "%s \wPlay For Specific Player", MenuPrefix)
  326.     new menu = menu_create(format, "search_handler")
  327.    
  328.     get_players( players, pnum, "ch" );
  329.    
  330.     for ( new i; i < pnum; i++ )
  331.     {
  332.         player = players[ i ];
  333.            
  334.         if (!is_user_connected( player ))
  335.             continue;
  336.        
  337.         get_user_name( player, szPName, charsmax( szPName ) );
  338.            
  339.         num_to_str( player, szTemp, charsmax( szTemp ) );
  340.        
  341.         menu_additem( menu, szPName, szTemp );
  342.     }
  343.    
  344.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL );
  345.     menu_setprop(menu, MPROP_EXITNAME, "\wBack" )
  346.     menu_display(id, menu)
  347. }
  348.  
  349. public search_handler(id, menu, item)
  350. {
  351.     if (item == MENU_EXIT)
  352.     {
  353.         OwnerOptions(id)
  354.     }
  355.    
  356.     switch (item)
  357.     {
  358.         case 0: FoundPlayer(id)
  359.     }
  360. }
  361.  
  362.  
  363. public FoundPlayer(id)
  364. {
  365.     new format[100]
  366.  
  367.     formatex(format, charsmax(format), "%s \w%s", MenuPrefix, szPName)
  368.     new menu = menu_create(format, "foundplayer_handler")
  369.    
  370.     menu_additem(menu, "Start Song")
  371.    
  372.     menu_additem(menu, "Stop song")
  373.    
  374.     menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  375.     menu_setprop(menu, MPROP_EXITNAME, "\wBack" )
  376.     menu_display(id, menu)
  377. }
  378.  
  379. public foundplayer_handler(id, menu, item ,player)
  380. {
  381.     new szName[90]
  382.     get_user_name(id, szName, charsmax(szName))
  383.    
  384.     if (item == MENU_EXIT)
  385.     {
  386.         SearchPlayer(id)
  387.     }
  388.    
  389.     switch (item)
  390.     {
  391.         case 0:
  392.         {
  393.             isStarted = true
  394.            
  395.             client_cmd(player, "mp3 play %s", MusicInfo[ g_choosed[id] ][g_Location])
  396.            
  397.             ColorPrint(0, "Owner: %s played the song %s for %s", szName, MusicInfo[ g_choosed[id] ][g_Name], szPName)
  398.            
  399.             FoundPlayer(id)
  400.         }
  401.        
  402.         case 1:
  403.         {  
  404.             isStarted = false
  405.             client_cmd(player, "mp3 stop")
  406.            
  407.             ColorPrint(0, "Owner: %s stopped the song %s for %s", szName, MusicInfo[ g_choosed[id] ][g_Name], szPName)
  408.            
  409.             FoundPlayer(id)
  410.         }
  411.     }
  412. }
  413.  
  414. public viewmark(id)
  415. {
  416.     if (isStarted && c_Hud && get_pcvar_num(c_Hud))
  417.     {
  418.         set_hudmessage(random(255),random(255),random(255), -1.0, 0.80, 0, 6.0, 90.0)
  419.         show_hudmessage(id, "%s^n------------------------^nSong Playing: %s", szChatPrefix, MusicInfo[g_choosed[id] ][g_Name])
  420.     }
  421. }
  422.    
  423.  
  424. stock ColorPrint( const index, const string[], any:... )
  425. {
  426.     new szMsg[ 191 ], Players[ 32 ], PNum = 1;
  427.    
  428.     static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "%s^1 ", szChatPrefix );
  429.    
  430.     vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
  431.    
  432.     if ( index )
  433.         Players[ 0 ] = index;
  434.    
  435.     else
  436.         get_players( Players, PNum, "ch" );
  437.    
  438.     for ( new i; i < PNum; i++ )
  439.     {
  440.         if( is_user_connected( Players[ i ] ) )
  441.         {
  442.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
  443.            
  444.             write_byte( Players[ i ] );
  445.            
  446.             write_string( szMsg );
  447.            
  448.             message_end( );
  449.         }
  450.     }
  451.    
  452.     return 1;
  453. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement