Raised This Month: $ Target: $400
 0% 

Mapcycle generator (place maps randomly lines)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rirre
Veteran Member
Join Date: Nov 2006
Old 06-05-2009 , 13:40   Mapcycle generator (place maps randomly lines)
Reply With Quote #1

Hi there,

I have a couple of servers and i have a map generator plugin to place maps from maps/ folder into maps.ini and mapcycle.txt, but i want it to place all maps randomly in mapcycle.txt file.
Since if all maps is in same line in all server mapcycle.txt
so do all servers use same map on mapchange.
Every server choose the map from the top and go down.
I hope you understood what I said.
randomly placed in mapcycle.txt should be enough to explain how i want it.
Attached Files
File Type: sma Get Plugin or Get Source (map_generator.sma - 924 views - 3.5 KB)
Rirre is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-05-2009 , 14:02   Re: Mapcycle generator (place maps randomly lines)
Reply With Quote #2

I found a old and basic plugin which does that :

Code:
        stock ShakeMapcyle()     {         new const MapcycleFile[] = "mapcycle.txt";         new Map[ 64 ];         new h = fopen( MapcycleFile, "rb" );                 new Array:SavedMaps = ArrayCreate( 64 );                 while( !feof( h ) )         {             fgets( h, Map, charsmax( Map ) );             trim( Map );             if ( Map[0] )  { ArrayPushString( SavedMaps, Map ); }         }                 fclose( h );         delete_file( MapcycleFile );                 new Cnt;         new MapCnt;         new Rand;         new Rand2;                 Cnt = iMapCnt = ArraySize( SavedMaps );         while( Cnt )         {             Rand  = random( MapCnt );             Rand2 = random( MapCnt );             if( Rand != Rand2 )             {                 ArraySwap( SavedMaps, Rand, Rand2 );                 Cnt--;             }         }                 h = fopen( MapcycleFile, "wb" );                 for( new i; i < MapCnt; ++i )         {               ArrayGetString( SavedMaps, i, Map, charsmax( Map ) );             fputs( h, Map );             fputc( h, '^n' );         }                         fclose( h );         ArrayDestroy( SavedMaps );     }

Put this function in plubin_cfg() for example.
__________________
Arkshine is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 06-05-2009 , 14:07   Re: Mapcycle generator (place maps randomly lines)
Reply With Quote #3

Can you write it to a whole plugin with includes? thx
Rirre is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-05-2009 , 14:11   Re: Mapcycle generator (place maps randomly lines)
Reply With Quote #4

Code:
        #include <amxmodx>         public plugin_init()     {         register_plugin( "Shake Mapcyle", "1.0.0", "Arkshine" );     }         public plugin_cfg()     {         ShakeMapcyle();     }         stock ShakeMapcyle()     {         new const MapcycleFile[] = "mapcycle.txt";         new Map[ 64 ];         new h = fopen( MapcycleFile, "rb" );                 new Array:SavedMaps = ArrayCreate( 64 );                 while( !feof( h ) )         {             fgets( h, Map, charsmax( Map ) );             trim( Map );             if ( Map[0] )  { ArrayPushString( SavedMaps, Map ); }         }                 fclose( h );         delete_file( MapcycleFile );                 new Cnt;         new MapCnt;         new Rand;         new Rand2;                 Cnt = MapCnt = ArraySize( SavedMaps );         while( Cnt )         {             Rand  = random( MapCnt );             Rand2 = random( MapCnt );             if( Rand != Rand2 )             {                 ArraySwap( SavedMaps, Rand, Rand2 );                 Cnt--;             }         }                 h = fopen( MapcycleFile, "wb" );                 for( new i; i < MapCnt; ++i )         {               ArrayGetString( SavedMaps, i, Map, charsmax( Map ) );             fputs( h, Map );             fputc( h, '^n' );         }                         fclose( h );         ArrayDestroy( SavedMaps );     }

It's basic but should be enough.
__________________
Arkshine is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 06-05-2009 , 14:18   Re: Mapcycle generator (place maps randomly lines)
Reply With Quote #5

Thanks It works!
Rirre is offline
Reply


Thread Tools
Display Modes

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 13:52.


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