Raised This Month: $ Target: $400
 0% 

Maps in file


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-23-2011 , 02:58   Re: Maps in file
Reply With Quote #2

Quote:
Originally Posted by extreem View Post
Here is code, I think you will understand what I want.
Not really. Your code (when it works) will say that the map is aim_awp when it's actually awp_india.

However, I think you need to trim() the lines after you read them from the file. Also, I would recommend using the "newer" file function because they are more intuitive, IMO.

This is a quick version that basically does the same that you are trying to do in yours:

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_clcmd("say /test""testFunc")
}
public 
testFunc()
{
    new 
mapsfile[128]
    
get_localinfo("amxx_configsdir"mapsfilecharsmax(mapsfile))
    
add(mapsfilecharsmax(mapsfile), "/allmaps.ini")

    new 
fopen(mapsfile"r")
    new 
data[32]
    new 
szMap[32]; get_mapname(szMapcharsmax(szMap));
        
    if(
f)
    {
        while( !
feof(f) )
        {
            
fgets(fdatacharsmax(data))
            
trim(data)
            
            if( 
equal(szMapdata) )
            {
                
client_print(0print_chat"This map is in the list.")
            }
            else
            {
                
client_print(0print_chat"This map is NOT in the list.")
            }
        }
        
fclose(f)
    }

If you explain extactly what you are trying to do (the ultimate goal of your project) we can either tell you how to do it eith a different method or elaborate on this method.
__________________

Last edited by fysiks; 12-23-2011 at 02:59.
fysiks 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 11:55.


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