AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]: Rename a file from cstrike_swedish (https://forums.alliedmods.net/showthread.php?t=163979)

OFFBEAT 08-05-2011 20:46

[SOLVED]: Rename a file from cstrike_swedish
 
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_pluginPLUGINVERSIONAUTHOR );
    
    
register_clcmd"say /end""fnEnd" );  // When recorder types /end kill the player, stop the recording and rename the demo
}

public 
fnEndid )
{
    
client_cmdid"kill" );  // Kill player by console
    
    
set_task1.0"fnStopDemo"id );  // Set the task to stop demo
    
    
get_user_nameidg_szJumpersizeofg_szJumper ) );  // Get the playername
    
get_mapnameg_szMapnamesizeofg_szMapname ) );  // Get the mapname
    
    
formatg_szDemName[id], MAX_DEMO 1"%s_%s.dem"g_szMapnameg_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 fnStopDemoid )
{
    
client_cmdid"stop" );
    
    
set_task0.5"fnRenameDemo"id );
    
    return 
PLUGIN_HANDLED;
}

// Rename the current recorded demo to mapname_playername
public fnRenameDemoid )
{
    
rename_file"newdemo.dem"g_szDemName[id], ); // On this part I need to find file from the cstrike_swedish folder
    
    
return PLUGIN_HANDLED;




SOLVED:
PHP Code:

public fnRenameDemoid )
{
    
rename_file"newdemo.dem"g_szDemName[id], );
    
    return 
PLUGIN_HANDLED;


to
PHP Code:

// new g_szDemo [MAX_DEMO * 2];  - in global

public fnRenameDemoid )
{
    
formatexg_szDemosizeofg_szDemo ), "../cstrike_swedish/%s"g_szDemName[id] );
    
rename_file"../cstrike_swedish/newdemo.dem"g_szDemotrue );
    
    return 
PLUGIN_HANDLED;




Thanks Hunter-Digital!

Exolent[jNr] 08-05-2011 21:04

Re: Rename a file from cstrike_swedish
 
You can't modify client files.

OFFBEAT 08-05-2011 21:21

Re: Rename a file from cstrike_swedish
 
So it's impossible to rename a demo in cstrike_swedish when it's possible in cstrike? Why's that. :?

Exolent[jNr] 08-05-2011 22:11

Re: Rename a file from cstrike_swedish
 
It's not possible at all to modify client-side files.
You can only rename server files.

OFFBEAT 08-05-2011 22:13

Re: Rename a file from cstrike_swedish
 
Its lan recording demos for kz.

fysiks 08-06-2011 02:16

Re: Rename a file from cstrike_swedish
 
Quote:

Originally Posted by OFFBEAT (Post 1526648)
Its lan recording demos for kz.

Doesn't matter. A plugin on the server cannot do it.

OFFBEAT 08-06-2011 08:35

Re: Rename a file from cstrike_swedish
 
I think you guys get me wrong here, it is for recording on my own lan and im alone on the server and recording demos for myself (and it works perfectly on cstrike). My only question then is, is it impossible to retrieve a path to cstrike_swedish?

xPaw 08-06-2011 09:21

Re: Rename a file from cstrike_swedish
 
Quote:

Originally Posted by fysiks (Post 1526731)
Doesn't matter. A plugin on the server cannot do it.

His plugin is for listenservers..

Hunter-Digital 08-06-2011 09:37

Re: Rename a file from cstrike_swedish
 
Try 0 as the 3rd param on rename_file() and add the path before it... like so: "cstrike_swedish/demo.dem"

OFFBEAT 08-06-2011 19:32

Re: Rename a file from cstrike_swedish
 
Quote:

Originally Posted by Hunter-Digital (Post 1526964)
Try 0 as the 3rd param on rename_file() and add the path before it... like so: "cstrike_swedish/demo.dem"

Didn't work :?


All times are GMT -4. The time now is 03:21.

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