Raised This Month: $ Target: $400
 0% 

Reading from file error


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-30-2009 , 21:11   Re: Reading from file error
Reply With Quote #4

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "amx_map random"
#define VERSION "1.0"
#define AUTHOR "BOYSplayCS"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_concmd("amx_map_random""eventChangeMap"ADMIN_SLAY"- Randomly change map");
}

public 
eventChangeMap(idlevelcid)
{
    if (
cmd_access(idlevelcid2))
    {
        new 
szMap64 ];
        if( 
GetRandomMap"mapcycle.txt"szMap63 ) )
            
server_cmd"changelevel %s"szMap );
        else
            
console_printid"There were no maps to change to." );
    }
    else
        
client_print(idprint_chat"[AMXX] Denied Command Access: 'amx_map_random'!");
    
    return 
PLUGIN_HANDLED;
}

GetRandomMap( const szMapFile[ ], szReturn[ ], const iLen )
{
    new 
iFile fopenszMapFile"rt" );
    if( !
iFile )
    {
        return 
0;
    }
    
    new Array:
aMaps ArrayCreate64 );
    new 
Trie:tArrayPos TrieCreate( );
    new 
iTotal 0;
    
    static 
szData128 ], szMap64 ];
    while( !
feofiFile ) )
    {
        
fgetsiFileszData127 );
        
parseszDataszMap63 );
        
strtolowerszMap );
        
        if( 
is_map_validszMap ) && !TrieKeyExiststArrayPosszMap ) )
        {
            
ArrayPushStringaMapsszMap );
            
TrieSetCelltArrayPosszMapiTotal );
            
            
iTotal++;
        }
    }
    
    
TrieDestroytArrayPos );
    
    if( !
iTotal )
    {
        
ArrayDestroyaMaps );
        
        return 
0;
    }
    
    
ArrayGetStringaMapsrandomiTotal ), szReturniLen );
    
    
ArrayDestroyaMaps );
    
    return 
1;

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
 



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 14:59.


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