Hello,
I'm trying to create a plugin that moves a demo file to another folder. My server (CSGO) is running the Get5 Plugin by splewis, which is setting up 5v5 matches and automaticially records demos to the csgo folder on the server. This causes two problems:
1. Demos are stuck on the server and clan members cannot retrieve them without getting acess the the server files, which I do not want to do
2. The demo names include the map and the date of recording (yy-mm-dd-hh) but there could be multiple matches started in the same hour, so the previous demo gets overwritten
My attempted solution is a plugin that moves the demo file to another folder (/csgo/demos in this case) where another program running on the server can take care of it. The Get5 plugin provides a Forward that is called when demo recording is finished.
When I tested my plugin without a timer it did find a file (using FileExists) at 'oldpath' but it didn't move it to 'newpath'. I think that the Forward is called before the demo is properly saved, so the file cannot be acessed by RenameFile(). I now want to add a timer to wait a few seconds until the demo is hopefully saved and can be moved.
This is the server console print when the demo recording finishes. The underlined lines are from my plugin. As you can see there are two more lines after that, I assume that the demo is finished after those are printed.
Quote:
[Quixz 5v5] An admin force ended the match.
2019-07-28_16_de_overpass.dem
19-07-28-16-22-de_overpass.dem
addons/sourcemod/../../2019-07-28_16_de_overpass.dem
addons/sourcemod/../../Demos/19-07-28-16-22-de_overpass.dem
Completed GOTV demo "2019-07-28_16_de_overpass.dem", recording time 32.4
StopRecording: 1023 frames flushed in 0.25 seconds
|
When I compile the code below I get 'error 100: function prototypes do not match' in the line where I use CreateTimer.
What is causing this error?
Is my theory about the demo file not being saved in time correct?
Thank you for you help in advance!
Code:
#include <sourcemod>
#include <sdktools>
#include <timers.inc>
public Plugin myinfo =
{
name = "Demo mover",
author = "dasBunny",
description = "Moves demos once a Get5 matches finish",
version = "1.0",
url = "quixz.eu"
};
public void OnPluginStart(){
}
public void Get5_OnDemoFinished(const char[] filename){
CreateTimer(5.0, MoveFile, filename); // <--- Error is in this line
}
public Action MoveFile(Handle timer, const char[] filename){
new String:oldpath[256], String:newpath[256], String:newname[256], String:map[64];
PrintToServer(filename);
//Creating a new filename with more detailed timestamp
int stamp=GetTime();
FormatTime(newname,sizeof(newname),"%y-%m-%d-%H-%M-%S-",stamp);
GetCurrentMap(map, sizeof(map));
StrCat(newname, sizeof(newname), map);
StrCat(newname, sizeof(newname), ".dem");
PrintToServer(newname);
//Building the paths and moving the file
BuildPath(Path_SM,oldpath,sizeof(oldpath),"../../%s",filename);
BuildPath(Path_SM,newpath,sizeof(newpath),"../../demos/%s",newname);
PrintToServer(oldpath);
PrintToServer(newpath);
RenameFile(newpath, oldpath);
return Plugin_Handled;
}