Advertisement
RanAway

[ Pawn ] Votemap

May 28th, 2022
1,892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 32.73 KB | None | 0 0
  1. /*****************************************
  2. ---------------- Credits -----------------
  3. ------- Niko - The win system of map -----
  4. ------- Shelby - Added rtv and nom -------
  5. *****************************************/
  6.  
  7. /*********** Includes **************/
  8. #include < amxmodx >
  9. #include < amxmisc >
  10. #include < unixtime >
  11.  
  12. /*********** Files **************/
  13. #define VotemapFolder       "addons/amxmodx/configs/votemap"
  14. #define PlayedFile      "addons/amxmodx/configs/votemap/PlayedMaps.ini"
  15. #define RecentFile      "addons/amxmodx/configs/votemap/RecentMaps.ini"
  16.  
  17. /*********** Defines **************/
  18. #define Prefix          "AMXX"      // The prefix of the server
  19. #define ADMIN_ACCESS        ADMIN_MAP   // The access for use the admin commands
  20. #define MapsInMenu      4       // The amount of maps to appear in the menu ( dont count the extend )
  21.  
  22. /*********** Timers **************/
  23. #define DefaultTime     600     // The time has set when the vote has stopped
  24. #define ExtendTime      600     // The time has set when extended the map
  25. #define VoteCountdown       4       // The time has left to countdown for the vote menu to appear
  26. #define MenuCountdown       16      // The time has left to the menu to countdown to 0
  27. #define NextmapTimeleft     60      // The time has left to the next map to change
  28. #define Countdownrtv        0       // The time has set as countdown for rtv
  29.  
  30. new Timeleft = DefaultTime
  31. new Countdown = VoteCountdown
  32. new MenuTimer = MenuCountdown
  33. new Timeleftnextmap = NextmapTimeleft
  34. new Mapcountdown = Countdownrtv
  35. new Maptime
  36.  
  37. /*********** Vote stuff **************/
  38. enum VoteStatus
  39. {
  40.     Vote_NotRunning,
  41.     Vote_Starting,
  42.     Vote_Running,
  43.     Vote_Nextmap
  44. }
  45.  
  46. new VoteStatus: VoteMsg = Vote_NotRunning
  47.  
  48. new ShowHud                 // Change the text between admin or default starting of the vote ( 0 is the server / 1 is the admin )
  49. new Allvotes                    // Count every vote
  50. new Nextmap[ 35 ]               // Save the winner map
  51. new DontShowMenu[ 33 ]              // Dont show the menu ( Button )
  52. new Revote[ 33 ], StopRevote[ 33 ]      // Revote system
  53. new MapVote[ 33 ]               // Show maps votes
  54. new bool: MyVote[ 33 ]              // Show my vote status
  55.  
  56. new MyChoose[ 33 ][ 33 ], MyMap[ 33 ]
  57.  
  58. /*********** Rtv stuff **************/
  59. new iRtv[ 33 ], Rtv
  60.  
  61. /*********** Nominate stuff **************/
  62. new iNom[ 33 ], MyNom[ 33 ][ 33 ]//, bool: search[ 33 ], sortby[ 33 ]
  63.  
  64. /*********** Played maps *****************/
  65. new Played[ 200 ][ 32 ]
  66.  
  67. /*********** Recent maps *****************/
  68. new RecentMaps[ 16 ][ 32 ], RecentMap
  69.  
  70. /*********** Load maps **************/
  71. new Array:g_aMaps, Array:g_nMaps, Array:g_sMaps, size
  72.  
  73. /*********** News *****************/
  74. new currentmap[ 35 ], mapname[ 35 ]
  75.  
  76. /*********** Plugin init **************/
  77. public plugin_init()
  78. {
  79.     register_plugin( "VoteMap", "v1.0", "RanAway" )
  80.    
  81.     /*********** Commands **************/
  82.     register_clcmd( "say", "CmdSay" )
  83.    
  84.     /*********** Timer **************/
  85.     set_task( 1.0, "Timetovote", 0, _, _, "b" )
  86.     set_task( 1.0, "MapTime", 111, _, _, "b" )
  87.    
  88.     /*********** Current map **********/
  89.     get_mapname( currentmap, charsmax( currentmap ) )
  90.    
  91.     /*********** Load maps **************/
  92.     g_aMaps = ArrayCreate( 100 )
  93.     g_nMaps = ArrayCreate( 100 )
  94.     g_sMaps = ArrayCreate( 100 )
  95.    
  96.     LoadMaps()
  97.    
  98.     /*********** Create the votemap folder **************/
  99.     if( !dir_exists( VotemapFolder ) )
  100.         mkdir( VotemapFolder )
  101.    
  102.     /*********** Load played maps **************/
  103.     LoadPlayed()
  104.     LoadPlayedMaps()
  105.    
  106.     /*********** Load recent maps **************/
  107.     LoadRecentMaps()
  108.     WriteRecentList()
  109. }
  110.  
  111. /*********** Plugin end **************/
  112. public plugin_end( )
  113. {
  114.     /****** The whole maps ********/
  115.     ArrayDestroy( g_aMaps )
  116.    
  117.     /****** Maps nominated ********/
  118.     ArrayDestroy( g_nMaps )
  119.    
  120.     /****** Maps has not nominated ******/
  121.     ArrayDestroy( g_sMaps )
  122. }
  123.  
  124. /*********** Disconnecting **************/
  125. public client_disconnect( id )
  126. {
  127.     if( iNom[ id ] ) iNom[ id ] = false
  128.    
  129.     if( VoteMsg == Vote_NotRunning && iRtv[ id ] )
  130.     {
  131.         Rtv--
  132.         iRtv[ id ] = false
  133.         ColorChat( 0, "^3%s ^1has diconnected, ^3%i ^1players have left.", GetName( id ), ( get_playersnum()/2 ) - Rtv + 1 )
  134.     }
  135. }
  136.  
  137. /*********** Map time **************/
  138. public MapTime() Maptime++
  139.  
  140. /*********** Time to vote **************/
  141. public Timetovote()
  142. {
  143.     Timeleft--
  144.     if( Timeleft == 0 )
  145.     {
  146.         ShowHud = 0
  147.         ColorChat( 0, "The ^3votemap^1 has started." )
  148.        
  149.         remove_task( 0 )
  150.         StartVote()
  151.     }
  152.    
  153.     return 1
  154. }
  155.  
  156. /*********** Time to change **************/
  157. public Timetochange()
  158. {
  159.     Timeleftnextmap--
  160.     if( Timeleftnextmap == 0 )
  161.     {
  162.         remove_task( 400 )
  163.         server_cmd( "changelevel %s", Nextmap )
  164.        
  165.         return 1
  166.     }
  167.    
  168.     if( Timeleftnextmap == 1 ) ColorChat( 0, "The ^3map^1 will be change to ^3%s^1.", Nextmap )
  169.     if( Timeleftnextmap <= 10 )
  170.     {
  171.         new Spk[ 10 ]
  172.         num_to_word( Timeleftnextmap, Spk, charsmax( Spk ) )
  173.         client_cmd( 0, "spk vox/%s", Spk )
  174.        
  175.         set_hudmessage( 255, 0, 0, -1.0, 0.10, 0, 6.0, 1.0 )
  176.         show_hudmessage( 0, " Changing map to %s^n------------------^nThe map will be change in %d second%s", Nextmap, Timeleftnextmap, Timeleftnextmap == 1 ? "" : "s" )
  177.     }
  178.    
  179.     return 1
  180. }
  181.  
  182. /*********** CmdSay **************/
  183. public CmdSay( id )
  184. {
  185.     new szMsg[ 192 ], szArgs[ 3 ][ 33 ], randommap[ 35 ]
  186.    
  187.     read_argv( 1, szMsg, charsmax( szMsg ) )
  188.    
  189.     parse( szMsg, szArgs[ 0 ], 32, szArgs[ 1 ], 32 , szArgs[ 2 ], 32 )
  190.    
  191.     /********* Un / Rock the vote *********/
  192.     if( equal( szMsg, "/rtv" ) || equali( szMsg, "/rockthevote" ) || equali( szMsg, "rtv" ) || equali( szMsg, "rockthevote" ) ) return RockTheVote( id )
  193.     if( equali( szMsg, "/unrtv" ) || equali( szMsg, "/unrockthevote" ) || equali( szMsg, "unrtv" ) || equali( szMsg, "unrockthevote" ) ) return UnRockTheVote( id )
  194.    
  195.     /********* Played maps *********/
  196.     if( equali( szMsg, "/playedmaps" ) || equali( szMsg, "playedmaps" ) || equali( szMsg, "/pm" ) ) return PlayedMaps( id, 0 )
  197.    
  198.     /********* Show the current map *********/
  199.     if( equali( szMsg, "/currentmap" ) || equali( szMsg, "/cm" ) || equali( szMsg, "currentmap" ) || equali( szMsg, "cm" )
  200.     || equali( szMsg, "/maptime" ) || equali( szMsg, "/mt" ) || equali( szMsg, "maptime" ) || equali( szMsg, "mt" ) )
  201.         return ColorChat( id, "Current map: ^3%s^1. Map time: ^3%s%i^1:^3%s%i^1.", currentmap, Maptime/60 < 10 ? "0" : "", Maptime/60, Maptime%60 < 10 ? "0" : "", Maptime%60 )
  202.    
  203.     /********* Show the time *********/
  204.     if( equali( szMsg, "/thetime" ) || equali( szMsg, "/tt" ) || equali( szMsg, "thetime" ) || equali( szMsg, "tt" ) )
  205.     {
  206.         new Year, Month, Day, Hour, Minute, Second
  207.         UnixToTime( get_systime(), Year, Month, Day, Hour, Minute, Second, UT_TIMEZONE_SERVER )
  208.        
  209.         /****************** This is because the timezone in my server is broke... *****************
  210.         Hour += 3
  211.         if( Hour == 24 )
  212.         {
  213.             Hour = 0
  214.             Day += 1
  215.         }
  216.         if( Hour == 25 ) Hour = 1
  217.         if( Hour == 26 ) Hour = 2
  218.         *****************************************************************************************/
  219.        
  220.         return ColorChat( id, "Time: ^3%02d^1:^3%02d^1:^3%02d^1 | Date: ^3%02d^1.^3%02d^1.^3%d^1", Hour, Minute, Second, Day, Month, Year )
  221.     }
  222.    
  223.     /********* Show when the votemap will start *********/
  224.     if( equali( szMsg, "/timeleft" ) || equali( szMsg, "/tl" ) || equali( szMsg, "/nextmap" ) || equali( szMsg, "/nm" )
  225.     || equali( szMsg, "timeleft" ) || equali( szMsg, "tl" ) || equali( szMsg, "nextmap" ) || equali( szMsg, "nm" ) )
  226.     {
  227.         if( VoteMsg == Vote_Running ) return ColorChat( id, "The vote is already ^3running." )
  228.         if( VoteMsg == Vote_Starting ) return ColorChat( id, "The vote is ^3starting^1 now." )
  229.         if( VoteMsg == Vote_Nextmap ) return ColorChat( id, "The ^3map^1 will be change to ^3%s^1 in ^3%02d:%02d^1 minute%s.",
  230.         Nextmap, Timeleftnextmap/60, Timeleftnextmap%60, Timeleftnextmap/60 > 1 ? "s" : "" )
  231.        
  232.         return ColorChat( id, "The ^3votemap^1 will be start in ^3%02d:%02d^1 minute%s.", Timeleft/60, Timeleft%60, Timeleft/60 > 1 ? "s" : "" )
  233.     }
  234.    
  235.     /********** Show noms ***********/
  236.     if( equali( szMsg, "/noms" ) || equali( szMsg, "/nominations" ) || equali( szMsg, "nominations" ) || equali( szMsg, "/nominate" ) )
  237.     {
  238.         if( ArraySize( g_nMaps ) == 0 ) return ColorChat( id, "There is no ^3nominations^1 yet" )
  239.        
  240.         new msg[ 500 ], noms
  241.         for( new i; i < ArraySize( g_nMaps ); i++ )
  242.         {
  243.             ArrayGetString( g_nMaps, i, mapname, charsmax( mapname ) )
  244.             noms += formatex( msg[ noms ], charsmax( msg ) -noms, ", %s", mapname )
  245.         }
  246.        
  247.         return ColorChat( id, "^4%i^1 Maps nominated: ^3%s.", ArraySize( g_nMaps ), msg[ 2 ] )
  248.     }
  249.    
  250.     /********** Recent maps ***********/
  251.     if( equali( szMsg, "/recentmaps" ) || equali( szMsg, "/rm" ) )
  252.     {
  253.         if( RecentMap <= 1 ) return ColorChat( id, "There is no ^3recentmaps^1 yet" )
  254.        
  255.         new msg[ 500 ], recents = 0
  256.         for( new i; i < RecentMap; i++ )
  257.         {
  258.             if( equali( RecentMaps[ i ], currentmap ) || equali( RecentMaps[ i ], RecentMaps[ i + 1 ] ) )
  259.                 continue
  260.            
  261.             recents += formatex( msg[ recents ], charsmax( msg ) -recents, "^1, ^3%s", RecentMaps[ i ] )
  262.         }
  263.        
  264.         return ColorChat( id, "Recent Maps:^3%s^1.", msg[ 2 ] )
  265.     }
  266.    
  267.     /********** List maps ***********/
  268.     if( equali( szArgs[ 0 ], "/maps" ) )
  269.     {
  270.         /*if( equali( szArgs[ 1 ], "" ) )
  271.             search[ id ] = false
  272.         else
  273.         {
  274.             search[ id ] = true
  275.             formatex( sortby[ id ], 32, szArgs[ 1 ] )
  276.             ColorChat( id, "searching by maps that start with ^3[^1 %s ^3]", sortby[ id ] )
  277.         }*/
  278.        
  279.         return MapsMenu( id )
  280.     }
  281.    
  282.     /********** Start votemap ***********/
  283.     if( ( equali( szMsg, "!startvote" ) || equali( szMsg, "/startvote" ) ) && get_user_flags( id ) & ADMIN_ACCESS )
  284.     {
  285.         if( VoteMsg == Vote_Running ) return ColorChat( id, "The vote is already ^3running." )
  286.         if( VoteMsg == Vote_Starting ) return ColorChat( id, "The vote is ^3starting^1 now." )
  287.         if( VoteMsg == Vote_Nextmap ) return ColorChat( id, "The vote is already over." )
  288.        
  289.         ShowHud = 1
  290.         StartVote()
  291.         remove_task( 0 )
  292.        
  293.         return ColorChat( 0, "Admin: ^3%s^1 has started the votemap.", GetName( id ) )
  294.     }
  295.    
  296.     /********** Stop votemap ***********/
  297.     if( ( equali( szMsg, "!stopvote" ) || equali( szMsg, "/stopvote" ) ) && get_user_flags( id ) & ADMIN_ACCESS )
  298.     {
  299.         if( VoteMsg == Vote_NotRunning ) return ColorChat( id, "There is no vote ^3running." )
  300.         //if( VoteMsg == Vote_Nextmap ) return ColorChat( id, "The vote is already ^3over^1." )
  301.        
  302.         Timeleft = DefaultTime
  303.         VoteMsg = Vote_NotRunning
  304.        
  305.         for( new i; i < get_maxplayers(); i++ ) iNom[ i ] = false
  306.        
  307.         Orders()
  308.        
  309.         show_menu( 0, 0, "^n", 1 )
  310.         remove_task( 50 )
  311.         remove_task( 100 )
  312.         remove_task( 400 )
  313.         set_task( 1.0, "Timetovote", 0, _, _, "b" )
  314.        
  315.         return ColorChat( 0, "Admin: ^3%s^1 has stopped the votemap.", GetName( id ) )
  316.     }
  317.    
  318.     /********** Random map ***********/
  319.     if( ( equali( szMsg, "!rm" ) || equali( szMsg, "!randommap" ) ) && get_user_flags( id ) & ADMIN_ACCESS )
  320.     {
  321.         ArrayGetString( g_aMaps, random( ArraySize( g_aMaps ) ), randommap, charsmax( randommap ) )
  322.        
  323.         set_task( 1.0, "RandomMap", 0, randommap, sizeof randommap )
  324.        
  325.         return ColorChat( 0, "^3%s^1 has random map ^3[^1 %s ^3]", GetName( id ), randommap )
  326.     }
  327.    
  328.     /********** Extend the map ***********/
  329.     if( ( equali( szArgs[ 0 ], "!extend" ) || equali( szArgs[ 0 ], "/extend" ) ) && get_user_flags( id ) & ADMIN_ACCESS )
  330.     {
  331.         if( VoteMsg == Vote_Running ) return ColorChat( id, "The vote is already ^3running." )
  332.         if( VoteMsg == Vote_Starting ) return ColorChat( id, "The vote is ^3starting^1 now." )
  333.        
  334.         new Amount = str_to_num( szArgs[ 1 ] )
  335.        
  336.         /******** If the nextmap is active ***********/
  337.         if( VoteMsg == Vote_Nextmap )
  338.         {
  339.             /********* If only + wrote in the time it will add the ExtedTime **********/
  340.             if( equali( szArgs[ 1 ], "+" ) )
  341.             {
  342.                 Timeleftnextmap += ExtendTime
  343.                 return ColorChat( 0, "Admin: ^3%s^1 has extended the map to ^3%i ^1minutes", GetName( id ), ExtendTime/60 )
  344.             }
  345.            
  346.             /********* If nothing wrote in the time it will add automatic ExtendTime **********/
  347.             if( equali( szArgs[ 1 ], "" ) )
  348.             {
  349.                 Timeleftnextmap = ExtendTime
  350.                 return ColorChat( 0, "Admin: ^3%s^1 has extended the map to ^3%i ^1minutes", GetName( id ), ExtendTime/60 )
  351.             }
  352.            
  353.             /********* If the number is not valid **********/
  354.             if( Amount <= 0 )
  355.                 return ColorChat( id, "You must type a number." )
  356.            
  357.             /********* If the number start with + then it will add time **********/
  358.             if( containi( szArgs[ 1 ], "+" ) != -1 )
  359.             {
  360.                 Timeleftnextmap += Amount
  361.                 return ColorChat( 0, "Admin: ^3%s^1 has extended the map by ^3%i ^1minute%s ^3%i ^1second%s.", GetName( id ), Amount/60, Amount/60 > 1 ? "s" : "", Amount%60, Amount%60 > 1 ? "s" : "" )
  362.             }
  363.            
  364.             /********* The amount of time you wrote **********/
  365.             Timeleftnextmap = Amount
  366.             return ColorChat( 0, "Admin: ^3%s^1 has extended the map to ^3%i ^1minute%s ^3%i ^1second%s.", GetName( id ), Amount/60, Amount/60 > 1 ? "s" : "", Amount%60, Amount%60 > 1 ? "s" : "" )
  367.         }
  368.        
  369.         /********* If only + wrote in the time it will add the ExtedTime **********/
  370.         if( equali( szArgs[ 1 ], "+" ) )
  371.         {
  372.             Timeleft += ExtendTime
  373.             return ColorChat( 0, "Admin: ^3%s^1 has extended the map by ^3%i ^1minutes", GetName( id ), ExtendTime/60 )
  374.         }
  375.        
  376.         /********* If nothing wrote in the time it will add automatic ExtendTime **********/
  377.         if( equali( szArgs[ 1 ], "" ) )
  378.         {
  379.             Timeleft = ExtendTime
  380.             return ColorChat( 0, "Admin: ^3%s^1 has extended the map to ^3%i ^1minutes", GetName( id ), ExtendTime/60 )
  381.         }
  382.        
  383.         /********* If the number is not valid **********/
  384.         if( Amount <= 0 )
  385.             return ColorChat( id, "You must type a number." )
  386.        
  387.         /********* If the number start with + then it will add time **********/
  388.         if( containi( szArgs[ 1 ], "+" ) != -1 )
  389.         {
  390.             Timeleft += Amount
  391.             return ColorChat( 0, "Admin: ^3%s^1 has extended the map by ^3%i ^1minute%s ^3%i ^1second%s.", GetName( id ), Amount/60, Amount/60 > 1 ? "s" : "", Amount%60, Amount%60 > 1 ? "s" : "" )
  392.         }
  393.        
  394.         /********* The amount of time you wrote **********/
  395.         Timeleft = Amount
  396.         return ColorChat( 0, "Admin: ^3%s^1 has extended the map to ^3%i ^1minute%s ^3%i ^1second%s.", GetName( id ), Amount/60, Amount/60 > 1 ? "s" : "", Amount%60, Amount%60 > 1 ? "s" : "" )
  397.     }
  398.    
  399.     return 0
  400. }
  401.  
  402. /*********** Rock the vote **************/
  403. public RockTheVote( id )
  404. {
  405.     if( VoteMsg == Vote_Running ) return ColorChat( id, "The vote is already ^3running." )
  406.     if( VoteMsg == Vote_Starting ) return ColorChat( id, "The vote is ^3starting^1 now." )
  407.     if( VoteMsg == Vote_Nextmap ) return ColorChat( id, "The ^3map^1 will be change to ^3%s^1 in ^3%02d:%02d^1 minute%s.",
  408.     Nextmap, Timeleftnextmap/60, Timeleftnextmap%60, Timeleftnextmap/60 > 1 ? "s" : "" )
  409.    
  410.     if( Maptime < Mapcountdown ) return ColorChat( id, "You have to wait ^3%i ^1seconds for rock the vote.", Mapcountdown-Maptime )
  411.    
  412.     if( iRtv[ id ] ) return ColorChat( id, "You have already rocked the vote. ^3[^1 %i ^3]^1 players left",  ( get_playersnum()/2 ) - Rtv + 1 )
  413.    
  414.     if( get_playersnum()/2 <= Rtv )
  415.     {
  416.         ShowHud = 0
  417.         StartVote()
  418.         return ColorChat( 0, "^3%s ^1has rocked the vote, votemap has started.", GetName( id ) )
  419.     }
  420.    
  421.     Rtv++
  422.     iRtv[ id ] = true
  423.     return ColorChat( 0, "^3%s ^1has rocked the vote, ^3%i ^1players have left.", GetName( id ),  ( get_playersnum()/2 ) - Rtv + 1 )
  424. }
  425.  
  426. public UnRockTheVote( id )
  427. {
  428.     if( VoteMsg == Vote_Running ) return ColorChat( id, "The vote is already ^3running." )
  429.     if( VoteMsg == Vote_Starting ) return ColorChat( id, "The vote is ^3starting^1 now." )
  430.     if( VoteMsg == Vote_Nextmap ) return ColorChat( id, "The ^3map^1 will be change to ^3%s^1 in ^3%02d:%02d^1 minute%s.",
  431.     Nextmap, Timeleftnextmap/60, Timeleftnextmap%60, Timeleftnextmap/60 > 1 ? "s" : "")
  432.    
  433.     if( !iRtv[ id ] ) return ColorChat( id, "You have not rocked the vote." )
  434.    
  435.     Rtv--
  436.     iRtv[ id ] = false
  437.     return ColorChat( 0, "^3%s ^1has unrocked the vote, ^3%i ^1players have left.", GetName( id ), ( get_playersnum()/2 ) - Rtv + 1 )
  438. }
  439.  
  440. /*********** Random map **************/
  441. public RandomMap( map[] ) server_cmd( "changelevel %s", map )
  442.  
  443. /*********** Start vote **************/
  444. public StartVote()
  445. {
  446.     Countdown = VoteCountdown
  447.     VoteMsg = Vote_Starting
  448.     Allvotes = 0
  449.     Rtv = 0
  450.     set_task( 1.0, "Countdowntovote", 50, _, _, "b" )
  451.    
  452.     return 1
  453. }
  454.  
  455. /*********** Countdown for vote **************/
  456. public Countdowntovote()
  457. {
  458.     Countdown--
  459.     if( Countdown == 0 )
  460.     {
  461.         ArrayClear( g_sMaps )
  462.        
  463.         if( ArraySize( g_nMaps ) )
  464.         {
  465.             for( new i; i < ArraySize( g_nMaps ); i++ )
  466.             {
  467.                 ArrayGetString( g_nMaps, i, mapname, charsmax( mapname ) )
  468.                 ArrayPushString( g_sMaps, mapname )
  469.             }
  470.         }
  471.        
  472.         MenuTimer = MenuCountdown
  473.         VoteMsg = Vote_Running
  474.        
  475.         ArraySort( g_aMaps, "SortMaps" )
  476.        
  477.         if( ArraySize( g_aMaps ) )
  478.         {
  479.             for( new i; i < ArraySize( g_aMaps ); i++ )
  480.             {
  481.                 ArrayGetString( g_aMaps, i, mapname, charsmax( mapname ) )
  482.                 ArrayPushString( g_sMaps, mapname )
  483.             }
  484.         }
  485.        
  486.         Orders()
  487.         set_task( 0.1, "MenuTime" )
  488.         set_task( 1.0, "MenuTime", 100, _, _, "b" )
  489.         remove_task( 50 )
  490.        
  491.         return 1
  492.     }
  493.    
  494.     new Spk[ 10 ]
  495.     num_to_word( Countdown, Spk, charsmax( Spk ) )
  496.     client_cmd( 0, "spk vox/%s", Spk )
  497.    
  498.     set_hudmessage( random( 255 ), random( 255 ), random( 255 ), -1.0, 0.10, 0, 6.0, 1.0 )
  499.     show_hudmessage( 0, "%sVote will be start in %d second%s", ShowHud ? "Admin vote^n-------------------^n" : "", Countdown, Countdown == 1 ? "" : "s" )
  500.    
  501.     return 1
  502. }
  503.  
  504. /*********** Menu timer **************/
  505. public MenuTime()
  506. {
  507.     MenuTimer--
  508.     if( MenuTimer == 0 )
  509.     {
  510.         remove_task( 100 )
  511.         show_menu( 0, 0, "^n", 1 )
  512.        
  513.         return CheckResults()
  514.     }
  515.    
  516.     for( new i; i < get_maxplayers(); i++ )
  517.         if( is_user_connected( i ) && !DontShowMenu[ i ] )
  518.             ShowVote( i )
  519.    
  520.     return 1
  521. }
  522.  
  523. /*********** Show vote **************/
  524. public ShowVote( id )
  525. {
  526.     new szMenu[ 1000 ], Precent[ 32 ]
  527.    
  528.     formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Choose the map you would like to play \d[ All votes \r%d\w/\r%d \d]^n\d|\y!\d| \w%sYou can only revote once",
  529.     Prefix, Allvotes, get_playersnum(), StopRevote[ id ] ? "\r" : "\w" )
  530.    
  531.     new menu = menu_create( szMenu, "sub_vote" )
  532.    
  533.     size = min( MapsInMenu, ArraySize( g_sMaps ) )
  534.    
  535.     for( new i; i < size; i++ )
  536.     {
  537.         ArrayGetString( g_sMaps, i, mapname, charsmax( mapname ) )
  538.        
  539.         if( MapVote[ i ] > 0 )
  540.             Precent[ i ] = ( ( MapVote[ i ] * 100 ) / ( Allvotes ) )
  541.        
  542.         if( !MyVote[ id ] )
  543.         {
  544.             formatex( szMenu, charsmax( szMenu ), "%s \d[\w votes: \y%d \d][\y %d%% \d]%s", mapname, MapVote[ i ], Precent[ i ], i == size - 1 ? "^n" : "" )
  545.             menu_additem( menu, szMenu )
  546.         }
  547.         else if( i == MyMap[ id ] && !StopRevote[ id ] )
  548.         {
  549.             formatex( szMenu, charsmax( szMenu ), "\y%s \d[\w votes: \y%d \d][\y %d%% \d]%s", mapname, MapVote[ i ], Precent[ i ], i == size - 1 ? "^n" : "" )
  550.             menu_additem( menu, szMenu )
  551.         }
  552.         else
  553.         {
  554.             formatex( szMenu, charsmax( szMenu ), "\d%s \d[\w votes: \y%d \d][\y %d%% \d]%s", mapname, MapVote[ i ], Precent[ i ], i == size - 1 ? "^n" : "" )
  555.             menu_additem( menu, szMenu, .callback = menu_makecallback( "blockpress" ) )
  556.         }
  557.     }
  558.    
  559.     if( MapVote[ size ] > 0 )
  560.         Precent[ size ] = ( ( MapVote[ size ] * 100 ) / ( Allvotes ) )
  561.    
  562.     if( !MyVote[ id ] )
  563.     {
  564.         formatex( szMenu, charsmax( szMenu ), "%s \r( Current map ) \d[\w votes: \y%d \d][\y %d%% \d]^n", currentmap, MapVote[ size ], Precent[ size ] )
  565.         menu_additem( menu, szMenu )
  566.     }
  567.     else if( size == MyMap[ id ] && !StopRevote[ id ] )
  568.     {
  569.         formatex( szMenu, charsmax( szMenu ), "\y%s \r( Current map ) \d[\w votes: \y%d \d][\y %d%% \d]^n", currentmap, MapVote[ size ], Precent[ size ] )
  570.         menu_additem( menu, szMenu )
  571.     }
  572.     else
  573.     {
  574.         formatex( szMenu, charsmax( szMenu ), "%s \r( Current map ) \d[\w votes: \y%d \d][\y %d%% \d]^n", currentmap, MapVote[ size ], Precent[ size ] )
  575.         menu_additem( menu, szMenu, .callback = menu_makecallback( "blockpress" ) )
  576.     }
  577.    
  578.     menu_additem( menu, "Dont show me the menu^n" )
  579.    
  580.     formatex( szMenu, charsmax( szMenu ), "\r[\w \d%d\w second%s left \r]", MenuTimer, MenuTimer == 1 ? "" : "s" )
  581.     menu_addtext( menu, szMenu )
  582.    
  583.     menu_setprop( menu, MPROP_EXIT, MEXIT_NEVER )
  584.     menu_display( id, menu )
  585.    
  586.     return 1
  587. }
  588.  
  589. public blockpress( id, menu, item )
  590. {
  591.     if( MyVote[ id ] || StopRevote[ id ] )
  592.         return ITEM_DISABLED
  593.    
  594.     return 1
  595. }
  596.  
  597. public sub_vote( id, menu, item )
  598. {
  599.     if( item == MENU_EXIT || MenuTimer <= 0 || VoteMsg == Vote_NotRunning ) return 1
  600.     if( item == MapsInMenu + 1 ) return DontShowMenu[ id ] = true
  601.    
  602.     if( MyVote[ id ] )
  603.     {
  604.         Allvotes--
  605.         MapVote[ MyMap[ id ] ]--
  606.         MyVote[ id ] = false
  607.         Revote[ id ] = true
  608.         ColorChat( 0, "^3%s ^1has unvoted for ^3%s^1.", GetName( id ), MyChoose[ id ] )
  609.         return ShowVote( id )
  610.     }
  611.    
  612.     if( item == size )
  613.     {
  614.         formatex( MyChoose[ id ], charsmax( MyChoose ), currentmap )
  615.         ColorChat( 0, "^3%s^1 has voted to stay in the current map. ^3[^1 %s ^3]", GetName( id ), currentmap )
  616.     }
  617.     else
  618.     {
  619.         ArrayGetString( g_sMaps, item, mapname, charsmax( mapname ) )
  620.         formatex( MyChoose[ id ], charsmax( MyChoose ), mapname )
  621.         ColorChat( 0, "^3%s ^1has voted for ^3%s^1.", GetName( id ), mapname )
  622.     }
  623.    
  624.     client_cmd( id, "spk sound/buttons/lightswitch2.wav" )
  625.     Allvotes++
  626.     MapVote[ item ]++
  627.     MyVote[ id ] = true
  628.     MyMap[ id ] = item
  629.    
  630.     if( Revote[ id ] )
  631.         StopRevote[ id ] = true
  632.    
  633.     return ShowVote( id )
  634. }
  635.  
  636. /*********** Results **************/
  637. CheckResults()
  638. {
  639.     new winner, winnercount, tienum
  640.     new tie[ 10 ]
  641.    
  642.     for( new i; i < size + 1; i++ )
  643.     {
  644.         if( MapVote[ i ] == winnercount )
  645.             tie[ tienum++ ] = i
  646.        
  647.         else if( MapVote[ i ] > winnercount )
  648.         {
  649.             winner = i
  650.             winnercount = MapVote[ i ]
  651.            
  652.             arrayset( tie, 0, sizeof tie )
  653.             tienum = 0
  654.         }
  655.     }
  656.    
  657.     if( winner == size )
  658.     {
  659.         ColorChat( 0, "The current map ^3[^1 %s ^3]^1 will be extended for ^3%d^1 minutes.", currentmap, ExtendTime/60 )
  660.         Timeleft = ExtendTime
  661.         VoteMsg = Vote_NotRunning
  662.         set_task( 1.0, "Timetovote", 0, _, _, "b" )
  663.        
  664.         Orders()
  665.     }
  666.     else
  667.     {
  668.         if( !winnercount )
  669.         {
  670.             winner = random( size )
  671.             ArrayGetString( g_sMaps, winner, mapname, charsmax( mapname ) )
  672.             ColorChat( 0, "No one has voted. ^3%s^1 was ^3randomly^1 chosen.", mapname )
  673.         }
  674.         else
  675.         {
  676.             if( tienum && MapVote[ tie[ 0 ] ] == winnercount && winnercount )
  677.             {
  678.                 winner = tie[ random( tienum ) ]
  679.                 ColorChat( 0, "^3%d^1 or more maps has the same number of votes. ^3random one^1 will be chosen.", 2 )
  680.                
  681.                 if( winner == size )
  682.                 {
  683.                     Timeleft = ExtendTime
  684.                     VoteMsg = Vote_NotRunning
  685.                     set_task( 1.0, "Timetovote", 0, _, _, "b" )
  686.                    
  687.                     Orders()
  688.                    
  689.                     return ColorChat( 0, "The chosen map is the current map ^3[^1 %s ^3]^1 will be extended for ^3%d^1 minutes.", currentmap, ExtendTime/60 )
  690.                 }
  691.             }
  692.            
  693.             ArrayGetString( g_sMaps, winner, mapname, charsmax( mapname ) )
  694.            
  695.             ColorChat( 0, "The chosen map is ^3%s^1 with ^3%d^1 vote%s. [^3 %.f precent ^1]. %s",
  696.             mapname, MapVote[ winner ], MapVote[ winner ] == 1 ? "" : "s", ( MapVote[ winner ] * 100.0 / Allvotes ), get_playersnum() <= 1 ? "the map will be change in^3 10 ^1seconds" : "the map will be change in^3 1 ^1minute" )
  697.         }
  698.        
  699.         copy( Nextmap, charsmax( Nextmap ), mapname )
  700.         VoteMsg = Vote_Nextmap
  701.         Timeleftnextmap = NextmapTimeleft
  702.        
  703.         if( get_playersnum() <= 1 )
  704.             Timeleftnextmap = 11
  705.        
  706.         set_task( 1.0, "Timetochange", 400, _,_, "b" )
  707.        
  708.         return 1
  709.     }
  710.    
  711.     return LoadMaps()
  712. }
  713.  
  714. /*********** Sort maps **************/
  715. public SortMaps()
  716. {
  717.     switch( random( 3 ) )
  718.     {
  719.         case 0: return 0
  720.         case 1: return 1
  721.         default: return -1
  722.     }
  723.    
  724.     return 0
  725. }
  726.  
  727. /*********** Nominate **************/
  728. public MapsMenu( id )
  729. {
  730.     if( VoteMsg == Vote_Running ) return ColorChat( id, "The vote is already ^3running." )
  731.     if( VoteMsg == Vote_Starting ) return ColorChat( id, "The vote is ^3starting^1 now." )
  732.     if( VoteMsg == Vote_Nextmap ) return ColorChat( id, "You can't nom now. the ^3map^1 will be change to ^3%s^1 in ^3%02d:%02d^1 minute%s.",
  733.     Nextmap, Timeleftnextmap/60, Timeleftnextmap%60, Timeleftnextmap/60 > 1 ? "s" : "")
  734.    
  735.     new szMenu[ 250 ]
  736.    
  737.     formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w maps \r[\w %d/%d \r] [\w Your nominate: \y%s\r ]\w\R",
  738.     Prefix, ArraySize( g_aMaps ), ArraySize( g_aMaps ) + ArraySize( g_nMaps ), !iNom[id] ? "Not chosen yet" : (MyNom[ id ]) )
  739.    
  740.     new menu = menu_create( szMenu, "sub_maps" )
  741.    
  742.     for( new i; i < ArraySize( g_nMaps ); i++ )
  743.     {
  744.         ArrayGetString( g_nMaps, i, mapname, charsmax( mapname ) )
  745.         /*SortCustom2D( mapname, g_nMaps, "sort_stringsi" )
  746.         ArraySort( g_nMaps, "SortMaps" )
  747.        
  748.         if( search[ id ] )
  749.             if( containi( mapname, sortby[ id ] ) ) continue
  750.             if( containi( mapname, sortby[ id ] ) > -1 )
  751.                 formatex( szMenu, charsmax( szMenu ), "\w%s", mapname )
  752.             else
  753.                 formatex( szMenu, charsmax( szMenu ), "\w%s", mapname )
  754.         */
  755.         formatex( szMenu, charsmax( szMenu ), "\d%s %s", mapname, equali( MyNom[ id ], mapname ) ? "\y~\w Your nominated \y~" : "" )
  756.         menu_additem( menu, szMenu, .callback = menu_makecallback( "blockitem" ) )
  757.     }
  758.     for( new i; i < ArraySize( g_aMaps ); i++ )
  759.     {
  760.         ArrayGetString( g_aMaps, i, mapname, charsmax( mapname ) )
  761.         /*SortCustom2D( mapname, g_aMaps, "sort_stringsi" )
  762.         ArraySort( g_aMaps, "SortMaps" )
  763.        
  764.         if( search[ id ] )
  765.             if( containi( mapname, sortby[ id ] ) ) continue
  766.             if( containi( mapname, sortby[ id ] ) > -1 )
  767.                 formatex( szMenu, charsmax( szMenu ), "\w%s", mapname )
  768.             else
  769.                 formatex( szMenu, charsmax( szMenu ), "\w%s", mapname )
  770.         */
  771.         formatex( szMenu, charsmax( szMenu ), "\w%s", mapname )
  772.         menu_additem( menu, szMenu )
  773.     }
  774.    
  775.     menu_setprop( menu, MPROP_BACKNAME, "Previous Page" )
  776.     menu_setprop( menu, MPROP_NEXTNAME, "Next Page" )
  777.     menu_display( id, menu )
  778.     return 1
  779. }
  780.  
  781. /*public sort_stringsi( const elem1[], const elem2[], const array[], data[], data_size )
  782.     //return strcmp( elem1, elem2, 1 )
  783.  
  784. public SortMapsNom( Array:array, elem1, elem2, data[], data_size )
  785. {
  786.     new map1[ 200 ]
  787.     new map2[ 200 ]
  788.    
  789.     ArrayGetString( array, elem1, map1, charsmax( map1 ) );
  790.     ArrayGetString( array, elem2, map2, charsmax( map2 ) );
  791.    
  792.     return strcmp( map1, map2, true );
  793. }*/
  794.  
  795. public blockitem( id, menu, item )
  796. {
  797.     ArrayGetString( g_nMaps, item, mapname, charsmax( mapname ) )
  798.    
  799.     if( !equali( MyNom[ id ], mapname ) )
  800.         return ITEM_DISABLED
  801.    
  802.     return 0
  803. }
  804.  
  805. public sub_maps( id, menu, item )
  806. {
  807.     if( item == MENU_EXIT ) return menu_destroy( menu )
  808.    
  809.     if( VoteMsg == Vote_Running ) return ColorChat( id, "The vote is already ^3running." )
  810.     if( VoteMsg == Vote_Starting ) return ColorChat( id, "The vote is ^3starting^1 now." )
  811.     if( VoteMsg == Vote_Nextmap ) return ColorChat( id, "You can't nom now. the ^3map^1 will be change to ^3%s^1 in ^3%02d:%02d^1 minute%s.",
  812.     Nextmap, Timeleftnextmap/60, Timeleftnextmap%60, Timeleftnextmap/60 > 1 ? "s" : "")
  813.    
  814.     if( item < ArraySize( g_nMaps ) )
  815.     {
  816.         ArrayGetString( g_nMaps, item, mapname, charsmax( mapname ) )
  817.        
  818.         if( equali( MyNom[ id ], mapname ) )
  819.         {
  820.             if( !iNom[ id ] ) return MapsMenu( id )
  821.            
  822.             //ColorChat( 0, "^3%s^1 has denominated^3 %s^1.", GetName( id ), mapname )
  823.             ColorChat( id, "You denominated^3 %s^1.", mapname )
  824.            
  825.             ArrayPushString( g_aMaps, mapname )
  826.             ArrayDeleteItem( g_nMaps, item )
  827.            
  828.             iNom[ id ] = false
  829.         }
  830.         return MapsMenu( id )
  831.     }
  832.    
  833.     if( iNom[ id ] )
  834.     {
  835.         MapsMenu( id )
  836.         return ColorChat( id, "You have already nominated. ^3(^1 %s ^3)^1", MyNom[ id ] )
  837.     }
  838.    
  839.     if( ArraySize( g_nMaps ) ) item -= ArraySize( g_nMaps )
  840.    
  841.     ArrayGetString( g_aMaps, item, mapname, charsmax( mapname ) )
  842.     ArrayPushString( g_nMaps, mapname )
  843.     ArrayDeleteItem( g_aMaps, item )
  844.    
  845.     formatex( MyNom[ id ], charsmax( MyNom ), mapname )
  846.    
  847.     ColorChat( 0, "^3%s^1 has nominated^3 %s^1.", GetName( id ), mapname )
  848.    
  849.     iNom[ id ] = true
  850.    
  851.     return MapsMenu( id )
  852. }
  853.  
  854. /*********** Played maps **************/
  855. public PlayedMaps( id, page )
  856. {
  857.     new szMenu[ 520 ], MapInfo[ 2 ][ 32 ]
  858.    
  859.     formatex( szMenu, charsmax( szMenu ), "\r[\w %s \r]\w Played maps \r[\w maps: \y%d \r]\w\R", Prefix, file_size( PlayedFile, 1 ) - 1 )
  860.     new menu = menu_create( szMenu, "sub_playedmaps" )
  861.    
  862.     for( new i; i < file_size( PlayedFile, 1 ) - 1; i++ )
  863.     {
  864.         parse( Played[ i ], MapInfo[ 0 ], 31, MapInfo[ 1 ], 31 )
  865.         formatex( szMenu, charsmax( szMenu ), "\wMap: \d%s\y| \wplayed: \d%s", MapInfo[ 0 ], MapInfo[ 1 ] )
  866.         menu_additem( menu, szMenu )
  867.     }
  868.    
  869.     menu_setprop( menu, MPROP_BACKNAME, "Previous Page" )
  870.     menu_setprop( menu, MPROP_NEXTNAME, "Next Page" )
  871.     menu_display( id, menu, page )
  872.    
  873.     return 1
  874. }
  875.  
  876. public sub_playedmaps( id, menu, item )
  877. {
  878.     if( item == MENU_EXIT ) return menu_destroy( menu )
  879.    
  880.     new MapDatas[ 2 ][ 32 ], page
  881.     player_menu_info( id, menu, menu, page )
  882.     parse( Played[ item ], MapDatas[ 0 ], 31, MapDatas[ 1 ], 31 )
  883.    
  884.     ColorChat( id, "Map: ^3%s^1| played: ^3%s", MapDatas[ 0 ], MapDatas[ 1 ] )
  885.     return PlayedMaps( id, page )
  886. }
  887.  
  888. /*********** Orders **************/
  889. public Orders()
  890. {
  891.     arrayset( iRtv, 0, sizeof iRtv )
  892.     arrayset( MyMap, 0, sizeof MyMap )
  893.     arrayset( MyVote, 0, sizeof MyVote )
  894.     arrayset( Revote, 0, sizeof Revote )
  895.     arrayset( MapVote, 0, sizeof MapVote )
  896.     arrayset( StopRevote, 0, sizeof StopRevote )
  897.     arrayset( DontShowMenu, 0, sizeof DontShowMenu )
  898. }
  899.  
  900. /*********** Load maps **************/
  901. LoadMaps()
  902. {
  903.     ArrayClear( g_aMaps )
  904.     ArrayClear( g_nMaps )
  905.    
  906.     new file[ 128 ]
  907.     get_configsdir( file, charsmax( file ) )
  908.    
  909.     add( file, charsmax( file ), "/maps.ini" )
  910.    
  911.     if( !file_exists( file ) )
  912.         log_amx( "File %s wasn't found!", file )
  913.     else
  914.     {
  915.         new f = fopen( file, "rt" )
  916.        
  917.         if( !f )
  918.             return PLUGIN_HANDLED
  919.        
  920.         new data[ 512 ]
  921.         get_mapname( mapname, charsmax( mapname ) )
  922.        
  923.         while( fgets( f, data, charsmax( data ) ) )
  924.         {
  925.             trim( data )
  926.            
  927.             if( data[ 0 ] == EOS || data[ 0 ] == '/' || data[ 0 ] == ';' || equali( data, mapname ) || !isValidMap( data ) )
  928.                 continue
  929.            
  930.             ArrayPushString( g_aMaps, data )
  931.         }
  932.         fclose( f )
  933.     }
  934.    
  935.     if( !ArraySize( g_aMaps ) )
  936.     {
  937.         new fail[ 64 ]
  938.         formatex( fail, charsmax( fail ), "No maps found. (%s)", file )
  939.        
  940.         set_fail_state( fail )
  941.     }
  942.    
  943.     return 1
  944. }
  945.  
  946. /*********** Load played maps **************/
  947. LoadPlayed()
  948. {
  949.     new Line[ 64 ], MapDatas[ 2 ][ 32 ],  LineNum, bool:Found
  950.    
  951.     new File = fopen( PlayedFile, "rt" )
  952.    
  953.     get_mapname( mapname, charsmax( mapname ) )
  954.    
  955.     while( !feof( File ) )
  956.     {
  957.         fgets( File, Line, charsmax( Line ) )
  958.        
  959.         if( Line[ 0 ] == ';' || strlen( Line ) < 2 )
  960.             continue
  961.        
  962.         parse( Line, MapDatas[ 0 ], 31, MapDatas[ 1 ], 31 )
  963.        
  964.         if( equali( MapDatas[ 0 ], mapname ) )
  965.         {
  966.             format( Line, sizeof Line - 1, "^"%s^" ^"%d^"", mapname, str_to_num( MapDatas[ 1 ] ) + 1 )
  967.             write_file( PlayedFile, Line, LineNum )
  968.             Found = true
  969.         }
  970.        
  971.         LineNum++
  972.     }
  973.    
  974.     fclose( File )
  975.    
  976.     if( !Found ) AddMaps()
  977. }
  978.  
  979. public AddMaps()
  980. {
  981.     new Line[ 32 ]
  982.     new File = fopen( PlayedFile, "at+" )
  983.    
  984.     formatex( Line, sizeof Line - 1, "^"%s^" ^"%d^"^n", currentmap, 1 )
  985.     fprintf( File, Line )
  986.     fclose( File )
  987. }
  988.  
  989. LoadPlayedMaps()
  990. {
  991.     new Line[ 64 ], Len
  992.     new File = fopen( PlayedFile, "rt" )
  993.     if( File )
  994.     {
  995.         for( new i; i < file_size( PlayedFile, 1 ) - 1; i++ )
  996.         {
  997.             read_file( PlayedFile, i, Line, charsmax( Line ), Len )
  998.            
  999.             if( Line[ 0 ] == ';' || strlen( Line ) < 2 )
  1000.                 continue
  1001.            
  1002.             remove_quotes( Line )
  1003.            
  1004.             copy( Played[ i ], sizeof Line - 1, Line )
  1005.         }
  1006.     }
  1007.    
  1008.     fclose( File )
  1009. }
  1010.  
  1011. /*********** Load recent maps **************/
  1012. public LoadRecentMaps()
  1013. {
  1014.     new Line[ 64 ]
  1015.     new File = fopen( RecentFile, "rt" )
  1016.     if( File )
  1017.     {
  1018.         while( !feof( File ))
  1019.         {
  1020.             fgets( File, Line, charsmax( Line ) )
  1021.             trim( Line )
  1022.            
  1023.             if( Line[ 0 ] == ';' || strlen( Line ) < 2 )
  1024.                 continue
  1025.            
  1026.             copy( RecentMaps[ RecentMap++ ], charsmax( Line ), Line )
  1027.         }
  1028.     }
  1029.    
  1030.     fclose( File )
  1031. }
  1032.  
  1033. public WriteRecentList()
  1034. {
  1035.     new File = fopen( RecentFile, "wt" )
  1036.     if( File )
  1037.     {
  1038.         fprintf( File, "%s", currentmap )
  1039.        
  1040.         for( new i; i < 3; i++ )
  1041.         {
  1042.             if( equali( RecentMaps[ i ], RecentMaps[ i + 1 ] ) || equali( RecentMaps[ i ], currentmap ) )
  1043.                 continue
  1044.            
  1045.             fprintf( File, "^n%s", RecentMaps[ i ] )
  1046.         }
  1047.     }
  1048.    
  1049.     fclose( File )
  1050. }
  1051.  
  1052. /*********** Is valid map **************/
  1053. stock bool:isValidMap( Map[] )
  1054. {
  1055.     if( is_map_valid( Map ) )
  1056.         return true
  1057.    
  1058.     new Len = strlen( Map ) - 4
  1059.    
  1060.     if( 0 > Len )
  1061.         return false
  1062.    
  1063.     if( equali( Map[ Len ], ".bsp" ) )
  1064.     {
  1065.         Map[ Len ] = '^0'
  1066.        
  1067.         if( is_map_valid( Map ) )
  1068.             return true
  1069.     }
  1070.    
  1071.     return false
  1072. }
  1073.  
  1074. /*********** Stocks **************/
  1075. stock GetName( id )
  1076. {
  1077.     new szName[ 32 ]
  1078.     get_user_name( id, szName, charsmax( szName ) )
  1079.     return szName
  1080. }
  1081.  
  1082. /*********** ColorChat **************/
  1083. stock ColorChat( const client, const string[ ], { Float, Sql, Resul, _ } :... )
  1084. {
  1085.     new msg[ 191 ], players[ 32 ], count = 1
  1086.    
  1087.     static len; len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
  1088.     vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
  1089.    
  1090.     if( client )
  1091.         players[ 0 ] = client
  1092.     else
  1093.         get_players( players, count, "ch" )
  1094.    
  1095.     for( new i; i < count; i++ )
  1096.     {
  1097.         if( is_user_connected( players[ i ] ) )
  1098.         {
  1099.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ),_, players[ i ] )
  1100.             write_byte( players[ i ] )
  1101.             write_string( msg )
  1102.             message_end()
  1103.         }
  1104.     }
  1105.     return 1
  1106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement