Raised This Month: $ Target: $400
 0% 

open_dir,close_dir


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Guppy488
Member
Join Date: Jul 2010
Location: Guppy's Scripting Lab
Old 08-19-2010 , 10:11   open_dir,close_dir
Reply With Quote #1

can anyone teach me how to use read_dir , open_dir or close_dir???
i don't know how to use it,i've read from the amxmodx.org's function guide..
need help ty.

Last edited by Guppy488; 08-19-2010 at 17:55.
Guppy488 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-19-2010 , 10:53   Re: read_dir,open_dir,close_dir
Reply With Quote #2

Don't use read_dir(), it's a deprecated function since it's very slow. You need to use open_dir() + next_file().

A small example with the configs/ directory :

Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {     new dirPath [ 26 ];     get_configsdir( dirPath, charsmax( dirPath ) );     new fileName[ 32 ];     new handleDir = open_dir( dirPath, fileName, charsmax( fileName ) );         if ( !handleDir )     {         // directory was not found or unable to open it.         return;     }         do     {         // It will loop through all the found files.         server_print( "Filename : %s", fileName );     }       while ( next_file( handleDir, fileName, charsmax( fileName ) ) );         // Don't forget to close if the directory was opened successful.     close_dir( handleDir ); }
__________________

Last edited by Arkshine; 08-19-2010 at 10:55.
Arkshine is offline
Guppy488
Member
Join Date: Jul 2010
Location: Guppy's Scripting Lab
Old 08-19-2010 , 17:32   Re: read_dir,open_dir,close_dir
Reply With Quote #3

so can you tell me why i could't open without open_dir,close_dir?

Code:
#include <amxmodx> 
#include <amxmisc> 
new g_FileLocation[]="data.txt"

public plugin_init() 
{ 
    register_plugin("show motd", "1.0", "Guppy488") 
    register_clcmd("say /data", "data")  // Say
    register_clcmd("say_team /data", "data") //Team Say
    register_clcmd("amx_data", "data")  //Console command
    
} 

public data(id)
{     
    show_motd(id,g_FileLocation,"Data")
    return PLUGIN_HANDLED
}

Last edited by Guppy488; 08-19-2010 at 17:41.
Guppy488 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-19-2010 , 17:34   Re: read_dir,open_dir,close_dir
Reply With Quote #4

what?
__________________
Arkshine is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-19-2010 , 17:42   Re: read_dir,open_dir,close_dir
Reply With Quote #5

*_dir are for DIRECTORIES (folders), search in funcwiki for "file" to see functions that relate to reading files in amxx to process their info using amxx... for whatever reason.

Your code, however, does nothing of such, it only opens a MOTD window and displays the contents of "data.txt" file to a player.

I don't see any revelance of motd when the thread is about directories... and, as one said once: what ?

__________________

Last edited by Hunter-Digital; 08-19-2010 at 17:45.
Hunter-Digital is offline
Guppy488
Member
Join Date: Jul 2010
Location: Guppy's Scripting Lab
Old 08-19-2010 , 17:46   Re: read_dir,open_dir,close_dir
Reply With Quote #6

so my plugin does not need "open_dir or close_dir" ? and i can't seem to make it work,when i type /data ,it shows data.txt only..
Guppy488 is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 08-19-2010 , 18:16   Re: open_dir,close_dir
Reply With Quote #7

That's all your code has it doing...
RedRobster is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-19-2010 , 21:00   Re: open_dir,close_dir
Reply With Quote #8

Clearly I'm wasting my... typing.
I already explained what does what, but you still ask a stupid question, what can I do.
__________________
Hunter-Digital is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 08-19-2010 , 21:27   Re: read_dir,open_dir,close_dir
Reply With Quote #9

Quote:
Originally Posted by Hunter-Digital View Post
*_dir are for DIRECTORIES (folders), search in funcwiki for "file" to see functions that relate to reading files in amxx to process their info using amxx... for whatever reason.

Your code, however, does nothing of such, it only opens a MOTD window and displays the contents of "data.txt" file to a player.

I don't see any revelance of motd when the thread is about directories... and, as one said once: what ?

I'll dumb it down for him.

open_dir = open directory. A directory is a folder that holds files or other directories.

You want to open a FILE, not a DIRECTORY.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 08-19-2010 , 23:42   Re: read_dir,open_dir,close_dir
Reply With Quote #10

Quote:
Originally Posted by GXLZPGX View Post
I'll dumb it down for him.

open_dir = open directory. A directory is a folder that holds files or other directories.

You want to open a FILE, not a DIRECTORY.
But you must open a directory to open a file, sir.
__________________
Hi.
Kreation 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 22:25.


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