Raised This Month: $ Target: $400
 0% 

read file


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 01-07-2020 , 07:11   Re: read file
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
By using dynamic arrays. This is the code I use in nearly all my plugins:

PHP Code:
ReadFile()
{
    new 
szFilename[256]
    
get_configsdir(szFilenamecharsmax(szFilename))
    
add(szFilenamecharsmax(szFilename), "/FileName.ini")

    new 
iFilePointer fopen(szFilename"rt")

    if(
iFilePointer)
    {
        new 
szData[128]
        new Array:
myArray ArrayCreate()

        while(!
feof(iFilePointer))
        {
            
fgets(iFilePointerszDatacharsmax(szData))
            
trim(szData)

            switch(
szData[0])
            {
                case 
EOS';''#': continue
                default:
                {
                    
ArrayPushString(myArrayszData)
                }
            }
        }

        for(new 
iArraySize(myArray); i++)
        {
            
server_cmd("say %a"ArrayGetStringHandle(myArrayi))
        }

        
ArrayDestroy(myArray)
        
fclose(iFilePointer)
    }

can you modify the current code instead of dynamic array bit easier for me.
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
 



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 02:56.


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