PDA

View Full Version : Crashed Map Recovery


Sarabveer
04-14-2014, 21:19
Hello,

I am currently looking for a SourceMod plugin that loads the map before a server crashes! Basically, if the server was on "d2_coast_01" and the server crashed, the plugin will restore the map to "d2_coast_01" after the server restarts. I need this plugin for a game called Synergy, (Which crashes alot now since the Dev's ported it to Source 2013)! I have tried this (https://forums.alliedmods.net/showthread.php?p=889196), but it messes up Synergy, it makes "sm_map" useless, and the server doesn't even change the map, even after the countdown finishes! Does anybody have an another plugin that doesn't mess with SourceMod or the game itself?

Sarabveer
04-15-2014, 08:48
Anyone?

Sarabveer
04-16-2014, 08:20
Anyone, Please? :cry:

Bacardi
04-16-2014, 09:06
Hello,

I am currently looking for a SourceMod plugin that loads the map before a server crashes!
...explain this. How exactly you know, when server is going to crash ?

Sarabveer
04-16-2014, 09:10
The plugin checks the map every 30-60 seconds, puts the maps in a log file, then when the server crashes, the plugin will load the last map (using sm_map) that was logged in the file? Basically, if the server was on "d2_coast_01" and the server crashed, the plugin will restore the map to "d2_coast_01" after the server restarts, or if d2_coast_01 wasn't logged, it would go to the previous map, in this case "d1_town_05".

Bacardi
04-16-2014, 09:40
ou, now I understand.

*edit
will changelevel command work on that game synergy ?

friagram
04-16-2014, 12:09
You could just write out a txt file of the nextmap and have the server configs execute that on startup.
I think you can maybe do it with autoexec.cfg... Else you could just write out a bat or sh and have your os execute that when the server starts.

Sarabveer
04-16-2014, 12:13
Thing is, Synergy is a HL2 Coop game. It allows you to HL2 Ep1 Ep2 with your friends. So If I was on Ep2, and the server crashed, it would go all the way back to HL2 with the Gman opening

Powerlord
04-16-2014, 12:42
For optimization reasons, you should have it save the mapname in OnMapStart rather than every 30-60 seconds.

Sarabveer
04-17-2014, 13:25
For optimization reasons, you should have it save the mapname in OnMapStart rather than every 30-60 seconds.

I don't get you.....

UPDATE: I see, so whenever a new map loads, the plugin will log the map name on MapStart, Got it!

Sarabveer
04-17-2014, 13:32
5char

Sarabveer
04-17-2014, 13:40
ou, now I understand.

*edit
will changelevel command work on that game synergy ?

Yea, it works

Bacardi
04-18-2014, 08:40
...I didn't get this part
I have tried this, but it messes up Synergy, it makes "sm_map" useless, and the server doesn't even change the map,

anyway, made test plugin. It use SM SQLite.
there is no cvar or commands.

After installing this plugin, you play (or change) levels, one or more times to get it start work.
If map has running 30 seconds, it will be loaded next time when server crash (or reboot).
If map haven't run that long, it try previous map if exist.
If even that haven't run that long, it do nothing :P

And this is just test plugin. Free to try



new Handle:g_hDB;
new Handle:g_hStatement;

public OnPluginStart()
{
SQL_TConnect(TConnect, "storage-local");
}

public TConnect(Handle:owner, Handle:hndl, const String:error[], any:data)
{
if(hndl == INVALID_HANDLE)
{
SetFailState("error: %s", error);
}

g_hDB = hndl;

/*
CREATE TABLE IF NOT EXISTS 'maps' ('map' VARCHAR PRIMARY KEY NOT NULL , 'time' DATETIME DEFAULT CURRENT_TIMESTAMP, 'loaded' BOOL)
*/
SQL_LockDatabase(g_hDB);
SQL_FastQuery(g_hDB, "CREATE TABLE IF NOT EXISTS 'maps' ('map' VARCHAR PRIMARY KEY NOT NULL , 'time' DATETIME DEFAULT CURRENT_TIMESTAMP, 'loaded' BOOL)");
SQL_UnlockDatabase(g_hDB);

/*
INSERT OR REPLACE INTO 'maps' ('map','loaded') VALUES ('de_dust2' , 1)
*/
new String:buffer[256];
g_hStatement = SQL_PrepareQuery(g_hDB, "INSERT OR REPLACE INTO 'maps' ('map','loaded') VALUES (? , ?)", buffer, sizeof(buffer));

if(g_hStatement == INVALID_HANDLE)
{
//PrintToServer("g_hStatement error: %s", buffer);
}

//PrintToServer("connect");
/* SELECT * FROM maps ORDER BY time DESC LIMIT 0 , 2*/
SQL_TQuery(g_hDB, TQuery, "SELECT map, loaded FROM maps ORDER BY time DESC LIMIT 0 , 2");
}

public TQuery(Handle:owner, Handle:hndl, const String:error[], any:data)
{
new String:buffer[MAX_NAME_LENGTH], loaded;
while(SQL_FetchRow(hndl))
{
SQL_FetchString(hndl, 0, buffer, sizeof(buffer));
loaded = SQL_FetchInt(hndl, 1);
//PrintToServer("buffer %s %i", buffer, loaded);

if(loaded)
{
ServerCommand("changelevel %s", buffer);
break;
}
}
}

public OnMapStart()
{
if(g_hDB == INVALID_HANDLE)
{
return;
}

new String:query[256];
GetCurrentMap(query, sizeof(query));
SQL_BindParamString(g_hStatement, 0, query, false);
SQL_BindParamInt(g_hStatement, 1, 0);

SQL_LockDatabase(g_hDB);
SQL_Execute(g_hStatement);
SQL_UnlockDatabase(g_hDB);

CreateTimer(30.0, update, _, TIMER_FLAG_NO_MAPCHANGE);
//PrintToServer("insert %s", query);
}

public Action:update(Handle:timer)
{
new String:query[256];
GetCurrentMap(query, sizeof(query));
SQL_BindParamString(g_hStatement, 0, query, false);
SQL_BindParamInt(g_hStatement, 1, 1);

SQL_LockDatabase(g_hDB);
SQL_Execute(g_hStatement);
SQL_UnlockDatabase(g_hDB);
//PrintToServer("update %s", query);
}

Sarabveer
04-18-2014, 10:28
...I didn't get this part


anyway, made test plugin. It use SM SQLite.
there is no cvar or commands.

After installing this plugin, you play (or change) levels, one or more times to get it start work.
If map has running 30 seconds, it will be loaded next time when server crash (or reboot).
If map haven't run that long, it try previous map if exist.
If even that haven't run that long, it do nothing :P

And this is just test plugin. Free to try



The other plugin was weird anyways!
WITH: There is no map change, changelevel doesn't work, neither does sm_map.

WITHOUT: Everything above works!

Can you you use a remote MySQL database?

Bacardi
04-18-2014, 10:38
...

Can you you use a remote MySQL database?

What if you first look, how it work. I don't have synergy to test it.

Sarabveer
04-18-2014, 10:44
What if you first look, how it work. I don't have synergy to test it.

Yea Im testing it, waiting for the server to crash? I have to see if the map changes though!

Bacardi
04-18-2014, 11:16
Yea Im testing it, waiting for the server to crash? I have to see if the map changes though!
well yes, if you can, wait and play till it crash.
If you want speed up.

rcon sm plugins reload pluginfilename

of course, load few levels and let them run over 30 seconds before reloading plugin.

Powerlord
04-18-2014, 14:27
As I recall, Synergy doesn't just take a map name, but also a game mode name. This is probably why it doesn't work.

Sarabveer
04-18-2014, 14:51
Yes it works, me and my friend tried so hard just to crash the server!

Bacardi
04-18-2014, 15:42
As I recall, Synergy doesn't just take a map name, but also a game mode name. This is probably why it doesn't work.
I can find this "game mode" from Synergy 1.1 (http://synergymod.net/docs_v11/)

But not from synergy - SourceSDK 2013 version, http://www.synergymod.net/Documents/Home


I take a break... rukia

Sarabveer
04-20-2014, 21:46
How do I use this with MySQL? Remote Database?

Bacardi
04-21-2014, 00:52
need change queries to work with mysql.
and little optimizing, not keep database connection open all the time...

I don't see any beneath to change it to remote database :/

anyway, I'm on holiday so wait little bit.

Bacardi
04-21-2014, 12:46
bump
Crash map recovery (https://forums.alliedmods.net/showthread.php?t=239087)