Advertisement
RanAway

[ Pawn ] Execute menu API

May 27th, 2022
758
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /************** Include **************/
  2. #include < amxmodx >
  3. #include < cstrike >
  4.  
  5. /************** Define **************/
  6. #define Prefix          "AMXX"
  7. #define ADMIN_ACCESS        ADMIN_IMMUNITY
  8.  
  9. /************** Commands **************/
  10. enum _: command
  11. {
  12.     cmdname[ 37 ],
  13.     cmdinfo[ 37 ],
  14.     cmdcommand[ 37 ]
  15. }
  16.  
  17. new const commandmenu[][ command ] =
  18. {
  19.     // { "Command view in menu", "info about command", "the command itself" }
  20.    
  21.     { "cd eject", "open drive", "cd eject" },
  22.     { "cd close", "close drive", "cd close" },
  23.     { "saying", "say instead", "say" },
  24.     { "rate", "control rate", "rate" },
  25.     { "fps_max", "change fps", "fps_max" },
  26.    
  27.     { "disconnect", "disconnect player", "disconnect" },
  28.     { "clear", "clear console", "clear" },
  29.    
  30.     { "+ voicerecord", "open mic", "+voicerecord" },
  31.     { "- voicerecord", "close mic", "-voicerecord" },
  32.    
  33.     { "+ lookup", "look up", "+lookup" },
  34.     { "- lookup", "stop look up", "-lookup" },
  35.    
  36.     { "+ attack", "attack", "+attack" },
  37.     { "- attack", "stop attack", "-attack" },
  38.    
  39.     { "+ attack2", "attack2", "+attack2" },
  40.     { "- attack2", "stop attack2", "-attack2" },
  41.    
  42.     { "+ reload", "reload", "+reload" },
  43.     { "- reload", "stop reload", "-reload" },
  44.    
  45.     { "+ duck", "duck", "+duck" },
  46.     { "- duck", "stop duck", "-duck" }
  47. }
  48.  
  49. /************** Team command **************/
  50. new const teamname[][] =
  51. {
  52.     "counter-terrorist",
  53.     "terrorist",
  54.     "spectators"
  55. }
  56.  
  57. /************** Sub commands **************/
  58. enum _: commandview
  59. {
  60.     cmdnameview,
  61.     cmdtarget,
  62.     cmdteam,
  63.     cmdblock
  64. }
  65.  
  66. new cmditem[ 33 ][ commandview ]
  67.  
  68. /************** Saying **************/
  69. new saymsg[ 33 ][ 30 ], sayingmsg[ 33 ]
  70.  
  71. /************** Rate **************/
  72. new ratenum[ 33 ], ratenumber[ 33 ]
  73.  
  74. /************** Fps **************/
  75. new fpsnum[ 33 ], fpsnumber[ 33 ]
  76.  
  77. /************** News **************/
  78. new playerselected[ 30 ][ 30 ]
  79. new MenuPage[ 33 ]
  80.  
  81. /************** Plugin_init **************/
  82. public plugin_init()
  83. {
  84.     register_plugin( "Execute menu API", "v1.0", "RanAway`" )
  85.    
  86.     /******** Command ********/
  87.     register_clcmd( "say !exec", "exectionmenu" )
  88.    
  89.     /******** messagemode ********/
  90.     register_clcmd( "_say", "saying" )
  91.     register_clcmd( "_rate", "rating" )
  92.     register_clcmd( "_fps", "fpsmax" )
  93.    
  94.     /******** console commands ********/
  95.     register_clcmd( "amx_execall","amx_exec" )
  96.     register_clcmd( "amx_execteam","amx_exec" )
  97.     register_clcmd( "amx_execclient","amx_exec" )
  98.    
  99.     /******** server commands ********/
  100.     register_srvcmd( "amx_execall","amx_exec" )
  101.     register_srvcmd( "amx_execteam","amx_exec" )
  102.     register_srvcmd( "amx_execclient","amx_exec" )
  103. }
  104.  
  105. /************** Connect **************/
  106. public client_connect( id ) reset( id )
  107.  
  108. /************** Exec menu **************/
  109. public exectionmenu( id )
  110. {
  111.     if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) return 0
  112.    
  113.     new szMenu[ 250 ]
  114.    
  115.     formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Execute menu", Prefix )
  116.     new menu = menu_create( szMenu, "sub_menu" )
  117.    
  118.     /**** target = all players online ****/
  119.     if( cmditem[ id ][ cmdtarget ] == 0 ) formatex( szMenu, charsmax( szMenu ), "target: \yall players online" )
  120.    
  121.     /**** target = team ****/
  122.     else if( cmditem[ id ][ cmdtarget ] == 1 ) formatex( szMenu, charsmax( szMenu ), "target: \y%s", teamname[ cmditem[ id ][ cmdteam ] ] )
  123.    
  124.     /**** target = specific player ****/
  125.     else if( cmditem[ id ][ cmdtarget ] == 2 )
  126.     {
  127.         if( playerselected[ id ] [ id ] == 0 )
  128.             formatex( szMenu, charsmax( szMenu ), "target: \rno one selected" )
  129.         else
  130.             formatex( szMenu, charsmax( szMenu ), "target: \y%s", szName( playerselected[ id ][ id ] ) )
  131.     }
  132.     menu_additem( menu, szMenu )
  133.    
  134.     /**** command = all the normal commands ****/
  135.     if( sayingmsg[ id ] == 0 && ratenumber[ id ] == 0 && fpsnumber[ id ] == 0 ) formatex( szMenu, charsmax( szMenu ), "command: \y%s^n", commandmenu[ cmditem[ id ][ cmdnameview ] ][ cmdname ] )
  136.    
  137.     /**** command = saying ****/
  138.     else if( sayingmsg[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "saying: \r%s^n", saymsg[ id ] )
  139.    
  140.     /**** command = rate ****/
  141.     else if( ratenumber[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "rate: \r%d^n", ratenum[ id ] )
  142.    
  143.     /**** command = fps ****/
  144.     else if( fpsnumber[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "fps: \r%d^n", fpsnum[ id ] )
  145.    
  146.     menu_additem( menu, szMenu )
  147.    
  148.     formatex( szMenu, charsmax( szMenu ), "\w%s^n^n", cmditem[ id ][ cmdblock ] ? "Please fill the lines" : "exec")
  149.     menu_additem( menu, szMenu, _,_, menu_makecallback( "BlockCmd" ) )
  150.    
  151.     menu_additem( menu, "reset" )
  152.    
  153.     menu_display( id, menu )
  154.     return 1
  155. }
  156.  
  157. /************** Block cmd **************/
  158. public BlockCmd( id, menu, item )
  159. {
  160.     if( cmditem[ id ][ cmdtarget ] == 2 && playerselected[ id ][ id ] == 0 )
  161.         return ITEM_DISABLED
  162.    
  163.     return 1
  164. }
  165.  
  166. public sub_menu( id, menu, item )
  167. {
  168.     if( item == MENU_EXIT ) return menu_destroy( menu )
  169.    
  170.     new _command = cmditem[ id ][ cmdnameview ]
  171.    
  172.     if( item == 0 ) return choosetarget( id )
  173.     if( item == 1 ) return choosecommand( id, MenuPage[ id ] )
  174.     if( item == 2 )
  175.     {
  176.         /**** target = spesific player ****/
  177.         if( cmditem[ id ][ cmdtarget ] == 2 )
  178.         {
  179.             new cid = find_player( "lb", szName( playerselected[ id ][ id ] ) )
  180.            
  181.             if ( !cid ) return PLUGIN_HANDLED
  182.            
  183.             /**** command = saying ****/
  184.             if( cmditem[ id ][ cmdnameview ] == 2 ) client_cmd( cid, "say %s", saymsg[ id ] )
  185.            
  186.             /**** command = rate ****/
  187.             else if( cmditem[ id ][ cmdnameview ] == 3 ) client_cmd( cid, "rate %d", ratenum[ id ] )
  188.            
  189.             /**** command = fps ****/
  190.             else if( cmditem[ id ][ cmdnameview ] == 4 ) client_cmd( cid, "fps_max %d", fpsnum[ id ] )
  191.             else
  192.                 /**** command = all the normal commands ****/
  193.                 client_cmd( cid, "%s" , commandmenu[ _command ][ cmdcommand ] )
  194.         }
  195.        
  196.         if( cmditem[ id ][ cmdtarget ] == 1 )
  197.         {
  198.             /**** team = counter-terrorist ****/
  199.             if( cmditem[ id ][ cmdteam ] == 0 )
  200.             {
  201.                 for( new i; i < get_maxplayers(); i++ )
  202.                 {
  203.                     if( !is_user_connected( i ) || get_user_flags( i ) & ADMIN_ACCESS ) continue
  204.                    
  205.                     if( cs_get_user_team( i ) == CS_TEAM_CT )
  206.                     {
  207.                         /**** command = saying ****/
  208.                         if( cmditem[ id ][ cmdnameview ] == 2 ) client_cmd( i, "say %s" , saymsg[ id ] )
  209.                        
  210.                         /**** command = rate ****/
  211.                         else if( cmditem[ id ][ cmdnameview ] == 3 ) client_cmd( i, "rate %d" , ratenum[ id ] )
  212.                        
  213.                         /**** command = fps ****/
  214.                         else if( cmditem[ id ][ cmdnameview ] == 4 ) client_cmd( i, "fps_max %d", fpsnum[ id ] )
  215.                         else
  216.                             /**** command = all the normal commands ****/
  217.                             client_cmd( i, "%s" , commandmenu[ _command ][ cmdcommand ] )
  218.                     }
  219.                 }
  220.             }
  221.            
  222.             /**** team = terrorist ****/
  223.             if( cmditem[ id ][ cmdteam ] == 1 )
  224.             {
  225.                 for( new i; i < get_maxplayers(); i++ )
  226.                 {
  227.                     if( !is_user_connected( i ) || get_user_flags( i ) & ADMIN_ACCESS ) continue
  228.                    
  229.                     if( cs_get_user_team( i ) == CS_TEAM_T )
  230.                     {
  231.                         /**** command = saying ****/
  232.                         if( cmditem[ id ][ cmdnameview ] == 2 ) client_cmd( i, "say %s" , saymsg[ id ] )
  233.                        
  234.                         /**** command = rate ****/
  235.                         else if( cmditem[ id ][ cmdnameview ] == 3 ) client_cmd( i, "rate %d" , ratenum[ id ] )
  236.                        
  237.                         /**** command = fps ****/
  238.                         else if( cmditem[ id ][ cmdnameview ] == 4 ) client_cmd( i, "fps_max %d", fpsnum[ id ] )
  239.                         else
  240.                             /**** command = all the normal commands ****/
  241.                             client_cmd( i, "%s" , commandmenu[ _command ][ cmdcommand ] )
  242.                     }
  243.                 }
  244.             }
  245.            
  246.             /**** team = spectator ****/
  247.             if( cmditem[ id ][ cmdteam ] == 2 )
  248.             {
  249.                 for( new i; i < get_maxplayers(); i++ )
  250.                 {
  251.                     if( !is_user_connected( i ) || get_user_flags( i ) & ADMIN_ACCESS ) continue
  252.                    
  253.                     if( cs_get_user_team( i ) == CS_TEAM_SPECTATOR )
  254.                     {
  255.                         /**** command = saying ****/
  256.                         if( cmditem[ id ][ cmdnameview ] == 2 ) client_cmd( i, "say %s" , saymsg[ id ] )
  257.                        
  258.                         /**** command = rate ****/
  259.                         else if( cmditem[ id ][ cmdnameview ] == 3 ) client_cmd( i, "rate %d" , ratenum[ id ] )
  260.                        
  261.                         /**** command = fps ****/
  262.                         else if( cmditem[ id ][ cmdnameview ] == 4 ) client_cmd( i, "fps_max %d", fpsnum[ id ] )
  263.                         else
  264.                             /**** command = all the normal commands ****/
  265.                             client_cmd( i, "%s" , commandmenu[ _command ][ cmdcommand ] )
  266.                     }
  267.                 }
  268.             }
  269.         }
  270.        
  271.         /**** target = all players online ****/
  272.         if( cmditem[ id ][ cmdtarget ] == 0 )
  273.         {
  274.             for( new i; i < get_maxplayers(); i++ )
  275.             {
  276.                 if( !is_user_connected( i ) || get_user_flags( i ) & ADMIN_ACCESS ) continue
  277.                
  278.                 /**** command = saying ****/
  279.                 if( cmditem[ id ][ cmdnameview ] == 2 ) client_cmd( i, "say %s" , saymsg[ id ] )
  280.                
  281.                 /**** command = rate ****/
  282.                 else if( cmditem[ id ][ cmdnameview ] == 3 ) client_cmd( i, "rate %d" , ratenum[ id ] )
  283.                
  284.                 /**** command = fps ****/
  285.                 else if( cmditem[ id ][ cmdnameview ] == 4 ) client_cmd( i, "fps_max %d", fpsnum[ id ] )
  286.                 else
  287.                     /**** command = all the normal commands ****/
  288.                     client_cmd( i, "%s" , commandmenu[ _command ][ cmdcommand ] )
  289.             }
  290.         }
  291.     }
  292.    
  293.     if( item == 3 ) reset( id )
  294.    
  295.     return exectionmenu( id )
  296. }
  297.  
  298. /************** Choose target **************/
  299. public choosetarget( id )
  300. {
  301.     new szMenu[ 250 ]
  302.    
  303.     formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Choose target", Prefix )
  304.     new menu = menu_create( szMenu, "sub_target" )
  305.    
  306.     menu_additem( menu, "select player" )
  307.     menu_additem( menu, "team" )
  308.     menu_additem( menu, "all players online" )
  309.    
  310.     menu_setprop( menu, MPROP_EXITNAME, "Back")
  311.     menu_display( id, menu )
  312.    
  313.     return 1
  314. }
  315.  
  316. public sub_target( id, menu, item )
  317. {
  318.     if( item == MENU_EXIT ) return exectionmenu( id )
  319.     if( item == 0 ) chooseplayer( id )
  320.     if( item == 1 ) chooseteam( id )
  321.     if( item == 2 ) cmditem[ id ][ cmdtarget ] = 0, cmditem[ id ][ cmdblock ] = 0, exectionmenu( id )
  322.    
  323.     return 1
  324. }
  325.  
  326. /************** Choose player **************/
  327. public chooseplayer( id )
  328. {  
  329.     new szMenu[ 250 ], szTempid[ 10 ]
  330.    
  331.     formatex( szMenu, charsmax( szMenu ),  "\r[ \w%s\r ]\w Choose player", Prefix )
  332.     new menu = menu_create( szMenu, "sub_player" )
  333.    
  334.     for( new i; i < get_maxplayers(); i++ )
  335.     {
  336.         if( !is_user_connected( i ) || get_user_flags( i ) & ADMIN_ACCESS ) continue
  337.        
  338.         num_to_str( i, szTempid, charsmax( szTempid ) )
  339.         menu_additem( menu, szName( i ), szTempid )
  340.     }
  341.    
  342.     menu_setprop( menu, MPROP_EXITNAME, "Back")
  343.     menu_display( id, menu )
  344.    
  345.     return 1
  346. }
  347.  
  348. public sub_player( id, menu, item )
  349. {  
  350.     if( item == MENU_EXIT ) return exectionmenu( id )
  351.    
  352.     static mData[ 6 ], Trash, mName[ 32 ]
  353.     menu_item_getinfo( menu, item, Trash, mData, charsmax( mData ), mName, charsmax( mName ), Trash )
  354.    
  355.     new iPlayer = str_to_num( mData )
  356.    
  357.     if( !is_user_connected( iPlayer ) || get_user_flags( iPlayer ) & ADMIN_ACCESS )
  358.         return chooseplayer( id )
  359.    
  360.     cmditem[ id ][ cmdblock ] = 0
  361.     cmditem[ id ][ cmdtarget ] = 2
  362.    
  363.     playerselected[ id ] [ id ] = str_to_num( mData )
  364.     mName = szName( playerselected[ id ] [ id ] )
  365.    
  366.     return exectionmenu( id )
  367. }
  368.  
  369. /************** Choose team **************/
  370. public chooseteam( id )
  371. {
  372.     new szMenu[ 250 ]
  373.    
  374.     formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Choose team", Prefix )
  375.     new menu = menu_create( szMenu, "sub_team" )
  376.    
  377.     for( new i; i < sizeof teamname; i++ )
  378.     {
  379.         formatex( szMenu, charsmax( szMenu ), "%s", teamname[ i ] )
  380.         menu_additem( menu, szMenu )
  381.     }
  382.    
  383.     menu_setprop( menu, MPROP_EXITNAME, "Back")
  384.     menu_display( id, menu )
  385.    
  386.     return 1
  387. }
  388.  
  389. public sub_team( id, menu, item )
  390. {
  391.     if( item == MENU_EXIT ) return choosetarget( id )
  392.     if( item == 0 ) cmditem[ id ][ cmdteam ] = 0
  393.     if( item == 1 ) cmditem[ id ][ cmdteam ] = 1
  394.     if( item == 2 ) cmditem[ id ][ cmdteam ] = 2
  395.    
  396.     cmditem[ id ][ cmdtarget ] = 1
  397.     cmditem[ id ][ cmdblock ] = 0
  398.    
  399.     return exectionmenu( id )
  400. }
  401.  
  402. /************** Choose command **************/
  403. public choosecommand( id, page )
  404. {
  405.     new szMenu[ 250 ]
  406.    
  407.     formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Choose command", Prefix )
  408.     new menu = menu_create( szMenu, "sub_choose" )
  409.    
  410.     for( new i; i < sizeof commandmenu; i++ )
  411.     {
  412.         formatex( szMenu, charsmax( szMenu ), "\w%s \r- \w%s", commandmenu[ i ][ cmdname ], commandmenu[ i ][ cmdinfo ] )
  413.         menu_additem( menu, szMenu )
  414.     }
  415.    
  416.     menu_setprop( menu, MPROP_EXITNAME, "Back" )
  417.     menu_display( id, menu, page )
  418.    
  419.     return 1
  420. }
  421.  
  422. public sub_choose( id, menu, item )
  423. {
  424.     player_menu_info( id, menu, menu, MenuPage[ id ] )
  425.    
  426.     if( item == MENU_EXIT ) return exectionmenu( id )
  427.    
  428.     cmditem[ id ][ cmdnameview ] = item
  429.    
  430.     sayingmsg[ id ] = 0
  431.     ratenumber[ id ] = 0
  432.     fpsnumber[ id ] = 0
  433.    
  434.     if( cmditem[ id ][ cmdnameview ] == 2 )
  435.     {
  436.         sayingmsg[ id ] = 1
  437.        
  438.         client_cmd( id, "messagemode _say" )
  439.         return 1
  440.     }
  441.    
  442.     if( cmditem[ id ][ cmdnameview ] == 3 )
  443.     {
  444.         ratenumber[ id ] = 1
  445.        
  446.         client_cmd( id, "messagemode _rate" )
  447.         return 1
  448.     }
  449.    
  450.     if( cmditem[ id ][ cmdnameview ] == 4 )
  451.     {
  452.         fpsnumber[ id ] = 1
  453.        
  454.         client_cmd( id, "messagemode _fps" )
  455.         return 1
  456.     }
  457.    
  458.     return exectionmenu( id )
  459. }
  460.  
  461. /************** saying **************/
  462. public saying( id )
  463. {
  464.     sayingmsg[ id ] = 1
  465.    
  466.     read_argv( 1, saymsg[ id ], charsmax( saymsg ) )
  467.    
  468.     new letters = strlen( saymsg[ id ] )
  469.     if( letters < 1 )
  470.     {
  471.         sayingmsg[ id ] = 0
  472.         cmditem[ id ][ cmdnameview ] = 0
  473.        
  474.         formatex( saymsg[ id ], charsmax( saymsg[ ] ), "hey" )
  475.        
  476.         client_cmd( id, "messagemode _say" )
  477.         return ColorChat( id, "the ^3msg^1 must to be longer" )
  478.     }
  479.    
  480.     return exectionmenu( id )
  481. }
  482.  
  483. /************** rating **************/
  484. public rating( id )
  485. {
  486.     ratenumber[ id ] = 1
  487.    
  488.     static szArgs[ 128 ], amount[ 21 ]
  489.    
  490.     read_args( szArgs, charsmax( szArgs ) )
  491.     remove_quotes( szArgs )
  492.     read_argv( 1, amount, charsmax( amount ) )
  493.    
  494.     new pointnum = str_to_num( amount )
  495.     ratenum[ id ] = pointnum
  496.    
  497.     if( !is_str_num( szArgs ) )
  498.     {
  499.         ratenumber[ id ] = 0
  500.         cmditem[ id ][ cmdnameview ] = 0
  501.        
  502.         client_cmd( id, "messagemode _rate" )
  503.         return ColorChat( id, "you must used ^3numbers^1." )
  504.     }
  505.    
  506.     if( pointnum == 0 || pointnum > 30000 )
  507.     {
  508.         ratenumber[ id ] = 0
  509.         cmditem[ id ][ cmdnameview ] = 0
  510.        
  511.         client_cmd( id, "messagemode _rate" )
  512.         return ColorChat( id, "you can only use^3 1 - 25000 ^1rate." )
  513.     }
  514.    
  515.     return exectionmenu( id )
  516. }
  517.  
  518. /************** fpsmax **************/
  519. public fpsmax( id )
  520. {
  521.     fpsnumber[ id ] = 1
  522.    
  523.     static szArgs[ 128 ], amount[ 21 ]
  524.    
  525.     read_args( szArgs, charsmax( szArgs ) )
  526.     remove_quotes( szArgs )
  527.     read_argv( 1, amount, charsmax( amount ) )
  528.    
  529.     new pointnum = str_to_num( amount )
  530.     fpsnum[ id ] = pointnum
  531.    
  532.     if( !is_str_num( szArgs ) )
  533.     {
  534.         fpsnumber[ id ] = 0
  535.         cmditem[ id ][ cmdnameview ] = 0
  536.        
  537.         client_cmd( id, "messagemode _fps" )
  538.         return ColorChat( id, "you must used ^3numbers^1." )
  539.     }
  540.    
  541.     if( pointnum < 20 || pointnum > 1000 )
  542.     {
  543.         fpsnumber[ id ] = 0
  544.         cmditem[ id ][ cmdnameview ] = 0
  545.        
  546.         client_cmd( id, "messagemode _fps" )
  547.         return ColorChat( id, "you can only use^3 20 - 1000 ^1fps." )
  548.     }
  549.    
  550.     return exectionmenu( id )
  551. }
  552.  
  553. /************** reset **************/
  554. public reset( id )
  555. {
  556.     sayingmsg[ id ] = 0
  557.     ratenumber[ id ] = 0
  558.     fpsnumber[ id ] = 0
  559.     playerselected[ id ][ id ] = 0
  560.     cmditem[ id ][ cmdnameview ] = 0
  561.     cmditem[ id ][ cmdtarget ] = 2
  562.     cmditem[ id ][ cmdteam ] = 0
  563.     cmditem[ id ][ cmdblock ] = 1
  564.    
  565.     MenuPage[ id ] = 0
  566.    
  567.     return 1
  568. }
  569.  
  570. /************** console commands **************/
  571. public amx_exec( id )
  572. {
  573.     if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) return 0
  574.    
  575.     new cmd[ 32 ]
  576.     read_argv( 0, cmd, charsmax( cmd ) )
  577.    
  578.     replace( cmd, 32, "amx_exec", "" )
  579.    
  580.     /**** target = all ****/
  581.     if( equal( cmd, "all" ) )
  582.     {
  583.         new toexec[ 32 ]
  584.         read_args( toexec, charsmax( toexec ) )
  585.         client_cmd( 0, toexec )
  586.     }
  587.    
  588.     /**** target = spezific player ****/
  589.     else if( equal( cmd, "client" ) )
  590.     {
  591.         new text[ 64 ], name[ 32 ]
  592.         read_args( text, charsmax( text ) )
  593.         parse( text, name, charsmax( name ) )
  594.        
  595.         new cid = find_player( "lb" ,name )
  596.         if( !cid )
  597.         {
  598.             id ? client_print( id, print_console, "Client with that part of name not found" ) : server_print( "Client with that part of name not found" )
  599.             return 1
  600.         }
  601.        
  602.         new length = strlen( name )
  603.         new message[ 64 ]
  604.         read_args( message, charsmax( message ) )
  605.         client_cmd( cid, message[ length ] )
  606.     }
  607.    
  608.     /**** target = team ****/
  609.     else if( equal( cmd, "team" ) )
  610.     {
  611.         new text[ 64 ], tname[ 32 ]
  612.         read_args( text, charsmax( text ) )
  613.         parse( text, tname, charsmax( tname ) )
  614.        
  615.         new players[ 32 ], pNum
  616.         get_players( players, pNum, "e", tname )
  617.        
  618.         new length = strlen( tname )
  619.         new message[ 64 ]
  620.         read_args( message, charsmax( message ) )
  621.        
  622.         for( new i; i < pNum; i++ ) client_cmd( players[ i ], message[ length ] )
  623.     }
  624.    
  625.     return PLUGIN_HANDLED
  626. }
  627.  
  628. /************** Stocks **************/
  629. stock szName( id )
  630. {
  631.     new name[ 32 ]
  632.     get_user_name( id, name, charsmax( name ) )
  633.     return name
  634. }
  635.  
  636. stock ColorChat( const client, const string[ ], { Float, Sql, Resul,_ }:... )
  637. {
  638.     new msg[ 191 ], players[ 32 ], count = 1
  639.    
  640.     static len; len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
  641.     vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
  642.    
  643.     if( client )
  644.         players[ 0 ] = client
  645.     else
  646.         get_players( players, count, "ch" )
  647.    
  648.     for( new i; i < count; i++ )
  649.     {
  650.         if( is_user_connected( players[ i ] ) )
  651.         {
  652.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] )
  653.             write_byte( players[ i ] )
  654.             write_string( msg )
  655.             message_end()
  656.         }
  657.     }
  658.     return 1
  659. }
Advertisement
RAW Paste Data Copied
Advertisement