Raised This Month: $51 Target: $400
 12% 

Solved How do i get all map existing in the server?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-04-2017 , 23:15   How do i get all map existing in the server?
Reply With Quote #1

Hello, i want to make a loop to take a list off all maps of the server from cstrike/maps, any idea/native to do this ?
__________________
Project: Among Us

Last edited by Craxor; 05-05-2017 at 09:27.
Craxor is offline
Send a message via ICQ to Craxor
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-04-2017 , 23:43   Re: How do i get all map existing in the server?
Reply With Quote #2

For the sake of time I found a function written by Arkshine that I edited to retrieve maps. This will only print them out, you will need to edit it if you want the map filenames to load into an array or whatever.
PHP Code:
public GetMaps()
{
    new 
fileName32 ] , len;
    new 
handleDir open_dir"maps/"fileNamecharsmaxfileName ) );
    
    if ( !
handleDir )
    {
        
// directory was not found or unable to open it.
        
return;
    }

    
// It will loop through all the found files.
    
do
    {
        
len strlenfileName );
        
        
//Check if file extension is '.bsp'.
        
if ( ( len ) && ( equalifileNamelen ] , ".bsp" ) ) )
        {
            
server_print"Filename : %s"fileName );
        }
    }   
    while ( 
next_filehandleDirfileNamecharsmaxfileName ) ) );
    
    
// Don't forget to close if the directory was opened successful.
    
close_dirhandleDir );

__________________

Last edited by Bugsy; 05-04-2017 at 23:47.
Bugsy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-05-2017 , 09:26   Re: How do i get all map existing in the server?
Reply With Quote #3

Thanks, working perfect, no i don't wanne insert in an array, i just one add them in a menu with a loop and using menu_additem, anyway works perfect, i had just to remove the .bsp part of name with replace_all() native.
__________________
Project: Among Us

Last edited by Craxor; 05-05-2017 at 09:27.
Craxor is offline
Send a message via ICQ to Craxor
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-05-2017 , 19:35   Re: How do i get all map existing in the server?
Reply With Quote #4

Quote:
Originally Posted by Craxor View Post
Thanks, working perfect, no i don't wanne insert in an array, i just one add them in a menu with a loop and using menu_additem, anyway works perfect, i had just to remove the .bsp part of name with replace_all() native.
You can trim off the ".bsp" like this instead of calling a native.
Code:
//Check if file extension is '.bsp'. if ( ( len > 4 ) && ( equali( fileName[ len - 4 ] , ".bsp" , 4 ) ) ) {
    fileName[ len - 4 ] = EOS;
    server_print( "Filename:[%s]", fileName ); }
__________________

Last edited by Bugsy; 05-05-2017 at 19:44.
Bugsy is offline
Hectik17
AlliedModders Donor
Join Date: Oct 2005
Old 05-05-2017 , 20:33   Re: How do i get all map existing in the server?
Reply With Quote #5

Hey does this display the maplist in console or motd?
Hectik17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-05-2017 , 20:48   Re: How do i get all map existing in the server?
Reply With Quote #6

This code example prints them out in server console.
__________________
Bugsy is offline
Hectik17
AlliedModders Donor
Join Date: Oct 2005
Old 05-05-2017 , 21:28   Re: How do i get all map existing in the server?
Reply With Quote #7

What if there are to many maps to print won't the sever crash? Is it listed in pages? Sorry I would test but for some reason my server ftp wis down
Hectik17 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-05-2017 , 21:35   Re: How do i get all map existing in the server?
Reply With Quote #8

The code isn't meant to print in console, it does this just as a demonstration/example. It will not have an issue printing a large list, but nobody will be able to see it.
__________________
Bugsy is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-05-2017 , 22:45   Re: How do i get all map existing in the server?
Reply With Quote #9

Just a little question, what's differente between do{}, while{} and for{} ?
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-05-2017 , 23:30   Re: How do i get all map existing in the server?
Reply With Quote #10

The difference is when the condition is checked resulting in the code execution. This is not specific to Pawn, you can google this same logic for C.

Here's a result I found that explains it a bit: https://www.quora.com/What-is-the-di...o-While-in-C++
__________________
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode