Raised This Month: $60 Target: $400
 15% 

Solved Copy File


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tepegoz
Senior Member
Join Date: Apr 2019
Old 01-10-2020 , 09:37   Copy File
Reply With Quote #1

I want copy a file with code. Just for config folder I will type "amx_copy File1 OutputName" and File1 will copy same config folder as OutputName

Last edited by tepegoz; 01-11-2020 at 07:28.
tepegoz is offline
Shitty
Member
Join Date: Sep 2019
Old 01-10-2020 , 09:42   Re: Copy File
Reply With Quote #2

Why do you want to do this while you can just copy the file by your hands..?!

You just have to go addons/amxmodx/configs and just copy what you need..
__________________
Quote:
Originally Posted by OciXCrom View Post
WhAt Is WaTeRing aNd TowErInG?!

Last edited by Shitty; 01-10-2020 at 09:43.
Shitty is offline
tepegoz
Senior Member
Join Date: Apr 2019
Old 01-10-2020 , 09:51   Re: Copy File
Reply With Quote #3

You are so smart. so there's something blocking it
tepegoz is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 01-10-2020 , 10:52   Re: Copy File
Reply With Quote #4

Quote:
Originally Posted by Shitty View Post
Why do you want to do this while you can just copy the file by your hands..?!

You just have to go addons/amxmodx/configs and just copy what you need..
Correct, but he wants a plugin which allows him to do it from the server console. Reason don't matter. Nothing harmful can be done for you to be concerned if he knows what he is doing.

@tepegoz
Search. Not hard.
__________________
Discord: wEight#6773

Hobbies:
- Map Designing (Any Half-Life 1 Engine Game)
- Pawn (Intermediate / Counter-Strike 1.6 only)
- C#/VB for .Net (Intermediate / Winforms)
- Java (Mostly Android Application Development)
redivcram is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-10-2020 , 18:04   Re: Copy File
Reply With Quote #5

amx_copy <source file> <destination file>

amx_copy "plugins.ini" "plugins_ini_backup.ini"

PHP Code:

#include <amxmodx>
#include <amxmisc>

new const Version[] = "0.1";

enum ReturnVals
{
    
FILE_COPY_SUCCESSFUL,
    
ERROR_FILE_DOES_NOT_EXIST,
    
ERROR_OPENING_SOURCE,
    
ERROR_CREATING_DEST,
    
ERROR_ARGS
}

public 
plugin_init() 
{
    
register_plugin"Copy Config Dir File" Version "bugsy" );
    
    
register_concmd"amx_copy" "CopyFileCmd" );
}

public 
CopyFileCmdid )
{
    if ( ( 
get_user_flagsid ) & ADMIN_RCON ) )
    {
        switch ( 
CopyFileid ) )
        {
            case 
FILE_COPY_SUCCESSFULconsole_printid "* File copy successful" );
            case 
ERROR_FILE_DOES_NOT_EXISTconsole_printid "* The source file does not exist in your configs directory." );
            case 
ERROR_OPENING_SOURCEconsole_printid "* There was an error opening the source file." );
            case 
ERROR_CREATING_DESTconsole_printid "* There was an error creating the destination file." );
            case 
ERROR_ARGSconsole_printid "* Must use command as follows: amx_copy [source filename] [destination filename]" );
        }
    }
}

public 
ReturnVals:CopyFileid )
{
    new 
szSource64 ] , szDest64 ] , iDirLen ReturnVals:rvResult iSource iDest iBytesRead FileBuffer1024 ];
    
    
iDirLen get_configsdirszSource charsmaxszSource ) );
    
copyszDest charsmaxszDest ) , szSource );
    
    
szSourceiDirLen ] = '/';
    
szDestiDirLen ] = '/';
    
iDirLen++;
    
    if ( !
read_argvszSourceiDirLen ] , charsmaxszSource ) - iDirLen ) || !read_argvszDestiDirLen ] , charsmaxszDest ) - iDirLen ) )
    {
        
rvResult ERROR_ARGS;
    }
    else
    {
        if ( 
file_existsszSource ) )
        {
            if ( ( 
iSource fopenszSource "rb" ) ) )
            {
                if ( ( 
iDest fopenszDest "wb" ) ) )
                {
                    while( ( 
iBytesRead fread_blocksiSource FileBuffer sizeofFileBuffer ) , BLOCK_BYTE ) ) )
                    {
                        
fwrite_blocksiDest FileBuffer iBytesRead BLOCK_BYTE );
                    }
                    
                    
fcloseiSource );
                    
fcloseiDest );
                }
                else
                {
                    
fcloseiSource );
                    
rvResult ERROR_CREATING_DEST;
                }
            }
            else
            {
                
rvResult ERROR_OPENING_SOURCE;
            }
        }
        else
        {
            
rvResult ERROR_FILE_DOES_NOT_EXIST;
        }
    }
    
    return 
rvResult;

__________________

Last edited by Bugsy; 01-10-2020 at 19:14.
Bugsy is offline
tepegoz
Senior Member
Join Date: Apr 2019
Old 01-11-2020 , 07:28   Re: Copy File
Reply With Quote #6

thanks working
tepegoz is offline
Reply


Thread Tools
Display Modes

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 19:52.


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