Advertisement
RanAway

[ Pawn ] Execute menu API

May 27th, 2022 (edited)
1,773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 17.63 KB | None | 0 0
  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", "make him say something", "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^n\
  116.     \rNOTE:\w if the player have \ycl_filterstuffcmd 1\w half of the cmds will not work on him.", Prefix )
  117.     new menu = menu_create( szMenu, "sub_menu" )
  118.    
  119.     /**** target = all players online ****/
  120.     if( cmditem[ id ][ cmdtarget ] == 0 ) formatex( szMenu, charsmax( szMenu ), "target: \r[\w all players online \r]" )
  121.    
  122.     /**** target = team ****/
  123.     else if( cmditem[ id ][ cmdtarget ] == 1 ) formatex( szMenu, charsmax( szMenu ), "target: \r[ \w%s \r]", teamname[ cmditem[ id ][ cmdteam ] ] )
  124.    
  125.     /**** target = specific player ****/
  126.     else if( cmditem[ id ][ cmdtarget ] == 2 )
  127.     {
  128.         if( playerselected[ id ][ id ] == 0 )
  129.             formatex( szMenu, charsmax( szMenu ), "target: \r[\w none \r]" )
  130.         else
  131.             formatex( szMenu, charsmax( szMenu ), "target: \r[ \w%s \r]", szName( playerselected[ id ][ id ] ) )
  132.     }
  133.     menu_additem( menu, szMenu )
  134.    
  135.     /**** command = all the normal commands ****/
  136.     if( sayingmsg[ id ] == 0 && ratenumber[ id ] == 0 && fpsnumber[ id ] == 0 ) formatex( szMenu, charsmax( szMenu ), "command: \r[\w %s \r]^n", commandmenu[ cmditem[ id ][ cmdnameview ] ][ cmdname ] )
  137.    
  138.     /**** command = saying ****/
  139.     else if( sayingmsg[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "saying: \r[ \w%s \r]^n", saymsg[ id ] )
  140.    
  141.     /**** command = rate ****/
  142.     else if( ratenumber[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "rate: \r[ \w%d \r]^n", ratenum[ id ] )
  143.    
  144.     /**** command = fps ****/
  145.     else if( fpsnumber[ id ] == 1 ) formatex( szMenu, charsmax( szMenu ), "fps: \r[ \w%d \r]^n", fpsnum[ id ] )
  146.    
  147.     menu_additem( menu, szMenu )
  148.    
  149.     formatex( szMenu, charsmax( szMenu ), "\w%s^n^n", cmditem[ id ][ cmdblock ] ? "Please fill the lines" : "exec" )
  150.     menu_additem( menu, szMenu, _,_, menu_makecallback( "BlockCmd" ) )
  151.    
  152.     menu_additem( menu, "reset" )
  153.    
  154.     menu_display( id, menu )
  155.     return 1
  156. }
  157.  
  158. /************** Block cmd **************/
  159. public BlockCmd( id, menu, item )
  160. {
  161.     if( cmditem[ id ][ cmdtarget ] == 2 && playerselected[ id ][ id ] == 0 )
  162.         return ITEM_DISABLED
  163.    
  164.     return 1
  165. }
  166.  
  167. public sub_menu( id, menu, item )
  168. {
  169.     if( item == MENU_EXIT ) return menu_destroy( menu )
  170.    
  171.     new _command = cmditem[ id ][ cmdnameview ]
  172.    
  173.     if( item == 0 ) return choosetarget( id )
  174.     if( item == 1 ) return choosecommand( id, MenuPage[ id ] )
  175.     if( item == 2 )
  176.     {
  177.         /**** target = spesific player ****/
  178.         if( cmditem[ id ][ cmdtarget ] == 2 )
  179.         {
  180.             new cid = find_player( "lb", szName( playerselected[ id ][ id ] ) )
  181.            
  182.             if ( !cid ) return PLUGIN_HANDLED
  183.            
  184.             /**** command = saying ****/
  185.             if( cmditem[ id ][ cmdnameview ] == 2 ) client_cmd( cid, "say %s", saymsg[ id ] )
  186.            
  187.             /**** command = rate ****/
  188.             else if( cmditem[ id ][ cmdnameview ] == 3 ) client_cmd( cid, "rate %d", ratenum[ id ] )
  189.            
  190.             /**** command = fps ****/
  191.             else if( cmditem[ id ][ cmdnameview ] == 4 ) client_cmd( cid, "fps_max %d", fpsnum[ id ] )
  192.             else
  193.                 /**** command = all the normal commands ****/
  194.                 client_cmd( cid, "%s" , commandmenu[ _command ][ cmdcommand ] )
  195.         }
  196.        
  197.         if( cmditem[ id ][ cmdtarget ] == 1 )
  198.         {
  199.             /**** team = counter-terrorist ****/
  200.             if( cmditem[ id ][ cmdteam ] == 0 )
  201.             {
  202.                 for( new i; i < get_maxplayers(); i++ )
  203.                 {
  204.                     if( !is_user_connected( i ) || get_user_flags( i ) & ADMIN_ACCESS ) continue
  205.                    
  206.                     if( cs_get_user_team( i ) == CS_TEAM_CT )
  207.                     {
  208.                         /**** command = saying ****/
  209.                         if( cmditem[ id ][ cmdnameview ] == 2 ) client_cmd( i, "say %s" , saymsg[ id ] )
  210.                        
  211.                         /**** command = rate ****/
  212.                         else if( cmditem[ id ][ cmdnameview ] == 3 ) client_cmd( i, "rate %d" , ratenum[ id ] )
  213.                        
  214.                         /**** command = fps ****/
  215.                         else if( cmditem[ id ][ cmdnameview ] == 4 ) client_cmd( i, "fps_max %d", fpsnum[ id ] )
  216.                         else
  217.                             /**** command = all the normal commands ****/
  218.                             client_cmd( i, "%s" , commandmenu[ _command ][ cmdcommand ] )
  219.                     }
  220.                 }
  221.             }
  222.            
  223.             /**** team = terrorist ****/
  224.             if( cmditem[ id ][ cmdteam ] == 1 )
  225.             {
  226.                 for( new i; i < get_maxplayers(); i++ )
  227.                 {
  228.                     if( !is_user_connected( i ) || get_user_flags( i ) & ADMIN_ACCESS ) continue
  229.                    
  230.                     if( cs_get_user_team( i ) == CS_TEAM_T )
  231.                     {
  232.                         /**** command = saying ****/
  233.                         if( cmditem[ id ][ cmdnameview ] == 2 ) client_cmd( i, "say %s" , saymsg[ id ] )
  234.                        
  235.                         /**** command = rate ****/
  236.                         else if( cmditem[ id ][ cmdnameview ] == 3 ) client_cmd( i, "rate %d" , ratenum[ id ] )
  237.                        
  238.                         /**** command = fps ****/
  239.                         else if( cmditem[ id ][ cmdnameview ] == 4 ) client_cmd( i, "fps_max %d", fpsnum[ id ] )
  240.                         else
  241.                             /**** command = all the normal commands ****/
  242.                             client_cmd( i, "%s" , commandmenu[ _command ][ cmdcommand ] )
  243.                     }
  244.                 }
  245.             }
  246.            
  247.             /**** team = spectator ****/
  248.             if( cmditem[ id ][ cmdteam ] == 2 )
  249.             {
  250.                 for( new i; i < get_maxplayers(); i++ )
  251.                 {
  252.                     if( !is_user_connected( i ) || get_user_flags( i ) & ADMIN_ACCESS ) continue
  253.                    
  254.                     if( cs_get_user_team( i ) == CS_TEAM_SPECTATOR )
  255.                     {
  256.                         /**** command = saying ****/
  257.                         if( cmditem[ id ][ cmdnameview ] == 2 ) client_cmd( i, "say %s" , saymsg[ id ] )
  258.                        
  259.                         /**** command = rate ****/
  260.                         else if( cmditem[ id ][ cmdnameview ] == 3 ) client_cmd( i, "rate %d" , ratenum[ id ] )
  261.                        
  262.                         /**** command = fps ****/
  263.                         else if( cmditem[ id ][ cmdnameview ] == 4 ) client_cmd( i, "fps_max %d", fpsnum[ id ] )
  264.                         else
  265.                             /**** command = all the normal commands ****/
  266.                             client_cmd( i, "%s" , commandmenu[ _command ][ cmdcommand ] )
  267.                     }
  268.                 }
  269.             }
  270.         }
  271.        
  272.         /**** target = all players online ****/
  273.         if( cmditem[ id ][ cmdtarget ] == 0 )
  274.         {
  275.             for( new i; i < get_maxplayers(); i++ )
  276.             {
  277.                 if( !is_user_connected( i ) || get_user_flags( i ) & ADMIN_ACCESS ) continue
  278.                
  279.                 /**** command = saying ****/
  280.                 if( cmditem[ id ][ cmdnameview ] == 2 ) client_cmd( i, "say %s" , saymsg[ id ] )
  281.                
  282.                 /**** command = rate ****/
  283.                 else if( cmditem[ id ][ cmdnameview ] == 3 ) client_cmd( i, "rate %d" , ratenum[ id ] )
  284.                
  285.                 /**** command = fps ****/
  286.                 else if( cmditem[ id ][ cmdnameview ] == 4 ) client_cmd( i, "fps_max %d", fpsnum[ id ] )
  287.                 else
  288.                     /**** command = all the normal commands ****/
  289.                     client_cmd( i, "%s" , commandmenu[ _command ][ cmdcommand ] )
  290.             }
  291.         }
  292.     }
  293.    
  294.     if( item == 3 ) reset( id )
  295.    
  296.     return exectionmenu( id )
  297. }
  298.  
  299. /************** Choose target **************/
  300. public choosetarget( id )
  301. {
  302.     new szMenu[ 250 ]
  303.    
  304.     formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Choose target", Prefix )
  305.     new menu = menu_create( szMenu, "sub_target" )
  306.    
  307.     menu_additem( menu, "select player", _,_, menu_makecallback( "NoOneOnline" ) )
  308.     menu_additem( menu, "team" )
  309.     menu_additem( menu, "all players online" )
  310.    
  311.     menu_setprop( menu, MPROP_EXITNAME, "Back")
  312.     menu_display( id, menu )
  313.    
  314.     return 1
  315. }
  316.  
  317. /************** Block select player **************/
  318. public NoOneOnline( id, menu, item )
  319. {
  320.     if( get_playersnum() <= 1 )
  321.         return ITEM_DISABLED
  322.    
  323.     return 1
  324. }
  325.  
  326. public sub_target( id, menu, item )
  327. {
  328.     if( item == MENU_EXIT ) return exectionmenu( id )
  329.     if( item == 0 ) chooseplayer( id )
  330.     if( item == 1 ) chooseteam( id )
  331.     if( item == 2 ) cmditem[ id ][ cmdtarget ] = 0, cmditem[ id ][ cmdblock ] = 0, exectionmenu( id )
  332.    
  333.     return 1
  334. }
  335.  
  336. /************** Choose player **************/
  337. public chooseplayer( id )
  338. {  
  339.     new szMenu[ 250 ], szTempid[ 10 ]
  340.    
  341.     formatex( szMenu, charsmax( szMenu ),  "\r[ \w%s\r ]\w Choose player", Prefix )
  342.     new menu = menu_create( szMenu, "sub_player" )
  343.    
  344.     for( new i; i < get_maxplayers(); i++ )
  345.     {
  346.         if( !is_user_connected( i ) || get_user_flags( i ) & ADMIN_ACCESS ) continue
  347.        
  348.         num_to_str( i, szTempid, charsmax( szTempid ) )
  349.         menu_additem( menu, szName( i ), szTempid )
  350.     }
  351.    
  352.     menu_setprop( menu, MPROP_EXITNAME, "Back")
  353.     menu_display( id, menu )
  354.    
  355.     return 1
  356. }
  357.  
  358. public sub_player( id, menu, item )
  359. {  
  360.     if( item == MENU_EXIT ) return exectionmenu( id )
  361.    
  362.     static mData[ 6 ], Trash, mName[ 32 ]
  363.     menu_item_getinfo( menu, item, Trash, mData, charsmax( mData ), mName, charsmax( mName ), Trash )
  364.    
  365.     new iPlayer = str_to_num( mData )
  366.    
  367.     if( !is_user_connected( iPlayer ) || get_user_flags( iPlayer ) & ADMIN_ACCESS )
  368.         return chooseplayer( id )
  369.    
  370.     cmditem[ id ][ cmdblock ] = 0
  371.     cmditem[ id ][ cmdtarget ] = 2
  372.    
  373.     playerselected[ id ][ id ] = str_to_num( mData )
  374.     mName = szName( playerselected[ id ][ id ] )
  375.    
  376.     return exectionmenu( id )
  377. }
  378.  
  379. /************** Choose team **************/
  380. public chooseteam( id )
  381. {
  382.     new szMenu[ 250 ]
  383.    
  384.     formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Choose team", Prefix )
  385.     new menu = menu_create( szMenu, "sub_team" )
  386.    
  387.     for( new i; i < sizeof teamname; i++ )
  388.     {
  389.         formatex( szMenu, charsmax( szMenu ), "%s", teamname[ i ] )
  390.         menu_additem( menu, szMenu )
  391.     }
  392.    
  393.     menu_setprop( menu, MPROP_EXITNAME, "Back")
  394.     menu_display( id, menu )
  395.    
  396.     return 1
  397. }
  398.  
  399. public sub_team( id, menu, item )
  400. {
  401.     if( item == MENU_EXIT ) return choosetarget( id )
  402.     if( item == 0 ) cmditem[ id ][ cmdteam ] = 0
  403.     if( item == 1 ) cmditem[ id ][ cmdteam ] = 1
  404.     if( item == 2 ) cmditem[ id ][ cmdteam ] = 2
  405.    
  406.     cmditem[ id ][ cmdtarget ] = 1
  407.     cmditem[ id ][ cmdblock ] = 0
  408.    
  409.     return exectionmenu( id )
  410. }
  411.  
  412. /************** Choose command **************/
  413. public choosecommand( id, page )
  414. {
  415.     new szMenu[ 250 ]
  416.    
  417.     formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Choose command", Prefix )
  418.     new menu = menu_create( szMenu, "sub_choose" )
  419.    
  420.     for( new i; i < sizeof commandmenu; i++ )
  421.     {
  422.         formatex( szMenu, charsmax( szMenu ), "\w%s \r- \w%s", commandmenu[ i ][ cmdname ], commandmenu[ i ][ cmdinfo ] )
  423.         menu_additem( menu, szMenu )
  424.     }
  425.    
  426.     menu_setprop( menu, MPROP_EXITNAME, "Back" )
  427.     menu_display( id, menu, page )
  428.    
  429.     return 1
  430. }
  431.  
  432. public sub_choose( id, menu, item )
  433. {
  434.     player_menu_info( id, menu, menu, MenuPage[ id ] )
  435.    
  436.     if( item == MENU_EXIT ) return exectionmenu( id )
  437.    
  438.     cmditem[ id ][ cmdnameview ] = item
  439.    
  440.     sayingmsg[ id ] = 0
  441.     ratenumber[ id ] = 0
  442.     fpsnumber[ id ] = 0
  443.    
  444.     if( cmditem[ id ][ cmdnameview ] == 2 )
  445.     {
  446.         sayingmsg[ id ] = 1
  447.        
  448.         client_cmd( id, "messagemode _say" )
  449.         return 1
  450.     }
  451.    
  452.     if( cmditem[ id ][ cmdnameview ] == 3 )
  453.     {
  454.         ratenumber[ id ] = 1
  455.        
  456.         client_cmd( id, "messagemode _rate" )
  457.         return 1
  458.     }
  459.    
  460.     if( cmditem[ id ][ cmdnameview ] == 4 )
  461.     {
  462.         fpsnumber[ id ] = 1
  463.        
  464.         client_cmd( id, "messagemode _fps" )
  465.         return 1
  466.     }
  467.    
  468.     return exectionmenu( id )
  469. }
  470.  
  471. /************** saying **************/
  472. public saying( id )
  473. {
  474.     sayingmsg[ id ] = 1
  475.    
  476.     read_argv( 1, saymsg[ id ], charsmax( saymsg ) )
  477.    
  478.     new letters = strlen( saymsg[ id ] )
  479.     if( letters < 1 )
  480.     {
  481.         sayingmsg[ id ] = 0
  482.         cmditem[ id ][ cmdnameview ] = 0
  483.        
  484.         formatex( saymsg[ id ], charsmax( saymsg[ ] ), "hey" )
  485.        
  486.         client_cmd( id, "messagemode _say" )
  487.         return ColorChat( id, "the ^3msg^1 must to be longer" )
  488.     }
  489.    
  490.     return exectionmenu( id )
  491. }
  492.  
  493. /************** rating **************/
  494. public rating( id )
  495. {
  496.     ratenumber[ id ] = 1
  497.    
  498.     static szArgs[ 128 ], amount[ 21 ]
  499.    
  500.     read_args( szArgs, charsmax( szArgs ) )
  501.     remove_quotes( szArgs )
  502.     read_argv( 1, amount, charsmax( amount ) )
  503.    
  504.     new pointnum = str_to_num( amount )
  505.     ratenum[ id ] = pointnum
  506.    
  507.     if( !is_str_num( szArgs ) )
  508.     {
  509.         ratenumber[ id ] = 0
  510.         cmditem[ id ][ cmdnameview ] = 0
  511.        
  512.         client_cmd( id, "messagemode _rate" )
  513.         return ColorChat( id, "you must used ^3numbers^1." )
  514.     }
  515.    
  516.     if( pointnum == 0 || pointnum > 30000 )
  517.     {
  518.         ratenumber[ id ] = 0
  519.         cmditem[ id ][ cmdnameview ] = 0
  520.        
  521.         client_cmd( id, "messagemode _rate" )
  522.         return ColorChat( id, "you can only use^3 1 - 25000 ^1rate." )
  523.     }
  524.    
  525.     return exectionmenu( id )
  526. }
  527.  
  528. /************** fpsmax **************/
  529. public fpsmax( id )
  530. {
  531.     fpsnumber[ id ] = 1
  532.    
  533.     static szArgs[ 128 ], amount[ 21 ]
  534.    
  535.     read_args( szArgs, charsmax( szArgs ) )
  536.     remove_quotes( szArgs )
  537.     read_argv( 1, amount, charsmax( amount ) )
  538.    
  539.     new pointnum = str_to_num( amount )
  540.     fpsnum[ id ] = pointnum
  541.    
  542.     if( !is_str_num( szArgs ) )
  543.     {
  544.         fpsnumber[ id ] = 0
  545.         cmditem[ id ][ cmdnameview ] = 0
  546.        
  547.         client_cmd( id, "messagemode _fps" )
  548.         return ColorChat( id, "you must used ^3numbers^1." )
  549.     }
  550.    
  551.     if( pointnum < 20 || pointnum > 1000 )
  552.     {
  553.         fpsnumber[ id ] = 0
  554.         cmditem[ id ][ cmdnameview ] = 0
  555.        
  556.         client_cmd( id, "messagemode _fps" )
  557.         return ColorChat( id, "you can only use^3 20 - 1000 ^1fps." )
  558.     }
  559.    
  560.     return exectionmenu( id )
  561. }
  562.  
  563. /************** reset **************/
  564. public reset( id )
  565. {
  566.     sayingmsg[ id ] = 0
  567.     ratenumber[ id ] = 0
  568.     fpsnumber[ id ] = 0
  569.     playerselected[ id ][ id ] = 0
  570.     cmditem[ id ][ cmdnameview ] = 0
  571.     cmditem[ id ][ cmdtarget ] = 2
  572.     cmditem[ id ][ cmdteam ] = 0
  573.     cmditem[ id ][ cmdblock ] = 1
  574.    
  575.     MenuPage[ id ] = 0
  576.    
  577.     return 1
  578. }
  579.  
  580. /************** console commands **************/
  581. public amx_exec( id )
  582. {
  583.     if( !( get_user_flags( id ) & ADMIN_ACCESS ) ) return 0
  584.    
  585.     new cmd[ 32 ]
  586.     read_argv( 0, cmd, charsmax( cmd ) )
  587.    
  588.     replace( cmd, 32, "amx_exec", "" )
  589.    
  590.     /**** target = all ****/
  591.     if( equal( cmd, "all" ) )
  592.     {
  593.         new toexec[ 32 ]
  594.         read_args( toexec, charsmax( toexec ) )
  595.         client_cmd( 0, toexec )
  596.     }
  597.    
  598.     /**** target = spezific player ****/
  599.     else if( equal( cmd, "client" ) )
  600.     {
  601.         new text[ 64 ], name[ 32 ]
  602.         read_args( text, charsmax( text ) )
  603.         parse( text, name, charsmax( name ) )
  604.        
  605.         new cid = find_player( "lb" ,name )
  606.         if( !cid )
  607.         {
  608.             id ? client_print( id, print_console, "Client with that part of name not found" ) : server_print( "Client with that part of name not found" )
  609.             return 1
  610.         }
  611.        
  612.         new length = strlen( name )
  613.         new message[ 64 ]
  614.         read_args( message, charsmax( message ) )
  615.         client_cmd( cid, message[ length ] )
  616.     }
  617.    
  618.     /**** target = team ****/
  619.     else if( equal( cmd, "team" ) )
  620.     {
  621.         new text[ 64 ], tname[ 32 ]
  622.         read_args( text, charsmax( text ) )
  623.         parse( text, tname, charsmax( tname ) )
  624.        
  625.         new players[ 32 ], pNum
  626.         get_players( players, pNum, "e", tname )
  627.        
  628.         new length = strlen( tname )
  629.         new message[ 64 ]
  630.         read_args( message, charsmax( message ) )
  631.        
  632.         for( new i; i < pNum; i++ ) client_cmd( players[ i ], message[ length ] )
  633.     }
  634.    
  635.     return PLUGIN_HANDLED
  636. }
  637.  
  638. /************** Stocks **************/
  639. stock szName( id )
  640. {
  641.     new name[ 32 ]
  642.     get_user_name( id, name, charsmax( name ) )
  643.     return name
  644. }
  645.  
  646. stock ColorChat( const client, const string[ ], { Float, Sql, Resul,_ }:... )
  647. {
  648.     new msg[ 191 ], players[ 32 ], count = 1
  649.    
  650.     static len; len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
  651.     vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
  652.    
  653.     if( client )
  654.         players[ 0 ] = client
  655.     else
  656.         get_players( players, count, "ch" )
  657.    
  658.     for( new i; i < count; i++ )
  659.     {
  660.         if( is_user_connected( players[ i ] ) )
  661.         {
  662.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] )
  663.             write_byte( players[ i ] )
  664.             write_string( msg )
  665.             message_end()
  666.         }
  667.     }
  668.     return 1
  669. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement