Hi,
I'm running a scoutzknivez server with CSSDM. Because I forced no round endings, it won't reload the map after timelimit runs out.
That's why I wrote the following script to force mapchange. Unfortunately it seems like it's crashing the server in about 50% of the cases, right at the mapchange. Nothing to see in the logs, error logs etc.
Anyone knows what can be the cause?
I took a part from the script from sourcemod mapvoter, so it's a little bit messy maybe.
Cheers,
Nightshadow
PHP Code:
#include <sourcemod>
#include <cstrike>
#include <morecolors>
#include <sdktools>
new Handle:g_VoteTimer = INVALID_HANDLE;
new Handle:g_VoteTimer2 = INVALID_HANDLE;
public Plugin:myinfo =
{
name = "Map timelimit",
author = "Nightshadow",
description = "",
version = "1.1",
url = "http://forum.i3d.net"
};
public OnMapStart()
{
SetupTimeleftTimer();
}
public OnMapTimeLeftChanged()
{
SetupTimeleftTimer();
}
SetupTimeleftTimer()
{
new time;
if (GetMapTimeLeft(time) && time > 0)
{
new startTime = 0;
if (time - startTime < 0)
{
PrintToChatAll("[SM] Reloading map immediately..");
}
else
{
if (g_VoteTimer != INVALID_HANDLE)
{
KillTimer(g_VoteTimer);
g_VoteTimer = INVALID_HANDLE;
}
g_VoteTimer = CreateTimer(float(time - startTime), Timer_StartMapVote, _, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
public Action:Timer_StartMapVote(Handle:timer)
{
g_VoteTimer = INVALID_HANDLE;
PrintToChatAll("[SM] Restarting map \"scoutzknivez\"..");
CS_TerminateRound(5.0, CSRoundEnd_Draw, false);
new maxPlayers = GetMaxClients();
for(new i = 1; i <= maxPlayers; i++)
{
if (IsClientInGame(i) && IsPlayerAlive(i))
{
SetEntProp(i, Prop_Data, "m_takedamage", 0, 1);
SetEntityMoveType(i, MOVETYPE_NONE);
}
}
if (g_VoteTimer2 != INVALID_HANDLE)
{
KillTimer(g_VoteTimer2);
g_VoteTimer2 = INVALID_HANDLE;
}
g_VoteTimer2 = CreateTimer(5.0, Timer_ChangeMap, _, TIMER_FLAG_NO_MAPCHANGE);
return Plugin_Handled;
}
public Action:Timer_ChangeMap(Handle:timer)
{
g_VoteTimer2 = INVALID_HANDLE;
ForceChangeLevel("scoutzknivez", "Reloading map");
return Plugin_Stop;
}
public OnMapEnd()
{
g_VoteTimer = INVALID_HANDLE;
g_VoteTimer2 = INVALID_HANDLE;
}