Raised This Month: $ Target: $400
 0% 

Finding a name in the .ini


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Baws
Veteran Member
Join Date: Oct 2012
Old 12-31-2013 , 13:11   Finding a name in the .ini
Reply With Quote #1

I tried to do this but didn't work. With what i need help is to type /search and search for the word in the .ini list. Look what i did, but it didn't work:

PHP Code:

__________________
Like my clean plugins and work?

Last edited by Baws; 12-31-2013 at 15:46.
Baws is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-31-2013 , 13:56   Re: Finding a name in the .ini
Reply With Quote #2

I've already (i think) told you it is a bad idea to search in a file during game time, it is better to cache the file content into variables (arrays, dynamic arrays) and to search in there.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 12-31-2013 , 14:43   Re: Finding a name in the .ini
Reply With Quote #3

How?

This?: https://forums.alliedmods.net/showpo...59&postcount=4
__________________
Like my clean plugins and work?

Last edited by Baws; 12-31-2013 at 14:49.
Baws is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 12-31-2013 , 15:33   Re: Finding a name in the .ini
Reply With Quote #4

On plugin_init or somewhere else read the whole .ini file and save each line into a dynamic array with ArrayPushString, then iterate through the array when someone writes /search and compare the line with your search string.
Backstabnoob is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 12-31-2013 , 15:42   Re: Finding a name in the .ini
Reply With Quote #5

Exemple? Please?
__________________
Like my clean plugins and work?
Baws is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-31-2013 , 17:48   Re: Finding a name in the .ini
Reply With Quote #6

There are tons of plugins that cache files. You can see my Bot Apology plugin for an example that uses arrays. If you use simple arrays (which will have hardcoded lengths) You then simply loop through each one and use equal[i]() or contain[i]() on each string.
__________________

Last edited by fysiks; 12-31-2013 at 19:23.
fysiks is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-31-2013 , 19:24   Re: Finding a name in the .ini
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
You then simply loop through each one and use equal[i]() or contain[i]() on each string.
__________________
fysiks is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 12-31-2013 , 18:14   Re: Finding a name in the .ini
Reply With Quote #8

Ok done, now if i want to see if the word is there, how to check it? how to do that V ?

PHP Code:
    else if(equali(say_args"/search"))
    {    
        if(!
songname or word not found)
                return
        else if(
songname or word found)
        {
        
inistialize(); here is where we read the line
        SearchSong menu here its a menu
the menu is where all the matches arelike there is 10 eminem songs and i type /search eminem in the menu i see all eminem songsyou get it
__________________
Like my clean plugins and work?

Last edited by Baws; 12-31-2013 at 18:47.
Baws is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 12-31-2013 , 19:39   Re: Finding a name in the .ini
Reply With Quote #9

Hard to understand really, i'm not that good. I'm a beginner. Example :/ ?
__________________
Like my clean plugins and work?
Baws is offline
Baws
Veteran Member
Join Date: Oct 2012
Old 12-31-2013 , 19:56   Re: Finding a name in the .ini
Reply With Quote #10

But like for the menu i just do this?

PHP Code:
if(equali(say_args"/search"))
{
SearchSong(id)



public 
SearchSong(id)
{
    new 
menu menu_create("\ySeached for:\r""searchsong_handler")
    for( new 
1<= songcounti++ )
    {
        new 
num[3];
        
num_to_str(inum2);
        
menu_additem(menug_media_names[i], num);
    }
    
    
menu_display(idmenu);

    return 
PLUGIN_HANDLED;
}

public 
searchsong_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], name[64]; 
    new 
accesscallback
    
menu_item_getinfo(menuitemaccessdatacharsmax(data), namecharsmax(name), callback);

    
songlistfile[id] = item
    
    play_media
(iditem);
    
    return 
PLUGIN_HANDLED;

__________________
Like my clean plugins and work?
Baws 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 10:09.


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