Im creating a small and easy autorenamer and I can't figure out how to find or rename files from the cstrike_swedish folder that some of the players are using.
Because rename_file starts in normal cstrike how do I find cstrike_swedish folder properly to rename a file?
I have this code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Chip"
#define VERSION "1.0"
#define AUTHOR "OFFBEAT"
#define MAX_ARRAY 32 // Max number of letters in map and name
#define MAX_DEMO 128 // Max size of demo name
//Create a global array for the playername, mapname and new demo
new g_szJumper[MAX_ARRAY];
new g_szMapname[MAX_ARRAY];
new g_szDemName[MAX_ARRAY + 1][MAX_DEMO];
public plugin_init( )
{
register_plugin( PLUGIN, VERSION, AUTHOR );
register_clcmd( "say /end", "fnEnd" ); // When recorder types /end kill the player, stop the recording and rename the demo
}
public fnEnd( id )
{
client_cmd( id, "kill" ); // Kill player by console
set_task( 1.0, "fnStopDemo", id ); // Set the task to stop demo
get_user_name( id, g_szJumper, sizeof( g_szJumper ) ); // Get the playername
get_mapname( g_szMapname, sizeof( g_szMapname ) ); // Get the mapname
format( g_szDemName[id], MAX_DEMO - 1, "%s_%s.dem", g_szMapname, g_szJumper ); // Save the new demo as mapname_playername
server_print( "*** Demo saved as: %s ***", g_szDemName[id] ); // Print out the new demo name
return PLUGIN_HANDLED;
}
// Stop the current demo recording and start a renaming task
public fnStopDemo( id )
{
client_cmd( id, "stop" );
set_task( 0.5, "fnRenameDemo", id );
return PLUGIN_HANDLED;
}
// Rename the current recorded demo to mapname_playername
public fnRenameDemo( id )
{
rename_file( "newdemo.dem", g_szDemName[id], 1 ); // On this part I need to find file from the cstrike_swedish folder
return PLUGIN_HANDLED;
}
SOLVED:
PHP Code:
public fnRenameDemo( id )
{
rename_file( "newdemo.dem", g_szDemName[id], 1 );
return PLUGIN_HANDLED;
}
to
PHP Code:
// new g_szDemo [MAX_DEMO * 2]; - in global
public fnRenameDemo( id )
{
formatex( g_szDemo, sizeof( g_szDemo ), "../cstrike_swedish/%s", g_szDemName[id] );
rename_file( "../cstrike_swedish/newdemo.dem", g_szDemo, true );
return PLUGIN_HANDLED;
}
Thanks Hunter-Digital!