Raised This Month: $32 Target: $400
 8% 

[CSS] Mapchange Forcer Script crashes server


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nightshadow999
Member
Join Date: Dec 2012
Old 01-27-2014 , 17:04   [CSS] Mapchange Forcer Script crashes server
Reply With Quote #1

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.0CSRoundEnd_Drawfalse);
    
    new 
maxPlayers GetMaxClients();
    for(new 
1<= maxPlayersi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i))
        {
            
SetEntProp(iProp_Data"m_takedamage"01);
            
SetEntityMoveType(iMOVETYPE_NONE);
        }
    }

    if (
g_VoteTimer2 != INVALID_HANDLE)
    {
        
KillTimer(g_VoteTimer2);
        
g_VoteTimer2 INVALID_HANDLE;
    }        
    
g_VoteTimer2 CreateTimer(5.0Timer_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;


Last edited by Nightshadow999; 01-27-2014 at 17:08.
Nightshadow999 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-27-2014 , 17:14   Re: [CSS] Mapchange Forcer Script crashes server
Reply With Quote #2

I can't help but think this could be done more cleanly with SetNextMap and CS_TerminateRound.

Something like...

PHP Code:
#include <sourcemod>
#include <cstrike>

new Handle:g_VoteTimer INVALID_HANDLE;

public 
Plugin:myinfo =
{
    
name "Map timelimit",
    
author "Nightshadow",
    
description "",
    
version "1.1",
    
url "http://forum.i3d.net"
};


public 
OnConfigsExecuted()
{   
    
SetupTimeleftTimer();
    
SetNextMap("scoutzknivez");
}

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_EndMap_TIMER_FLAG_NO_MAPCHANGE);
        }       
    }
}

public 
Action:Timer_EndMap(Handle:timer)
{
    
g_VoteTimer INVALID_HANDLE;

    
PrintToChatAll("[SM] Restarting map \"scoutzknivez\"..");
    
CS_TerminateRound(5.0CSRoundEnd_Drawfalse);
   
    for(new 
1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i))
        {
            
SetEntProp(iProp_Data"m_takedamage"01);
            
SetEntityMoveType(iMOVETYPE_NONE);
        }
    }

    return 
Plugin_Handled;
}

public 
OnMapEnd()
{
    
g_VoteTimer INVALID_HANDLE;

Actually, I'm not sure it's necessary to freeze the players and set their m_takedamage netprop, but I left it in anyway.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Nightshadow999
Member
Join Date: Dec 2012
Old 01-27-2014 , 17:41   Re: [CSS] Mapchange Forcer Script crashes server
Reply With Quote #3

Thanks!

With your ideas and suggestions I've changed it to this and it seems to be working fine! It seems the problem was the round end on exactly 0 seconds timeleft didn't work (I tried that before and changed it to ForceChangeLevel because it didn't change). So now I changed it to 1 second after and now it works without ForceChangeLevel.

Thanks again!

PHP Code:
#include <sourcemod>
#include <cstrike>

new Handle:g_VoteTimer INVALID_HANDLE;

public 
Plugin:myinfo =
{
    
name "Map timelimit",
    
author "Nightshadow",
    
description "",
    
version "1.1",
    
url "http://forum.i3d.net"
};


public 
OnConfigsExecuted()
{   
    
SetupTimeleftTimer();
    
SetNextMap("scoutzknivez");
}

public 
OnMapTimeLeftChanged()
{
    
SetupTimeleftTimer();
}

SetupTimeleftTimer()
{
    new 
time;
    if (
GetMapTimeLeft(time) && time 0)
    {
        new 
startTime 1;
        if (
time startTime 1)
        {
            
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.0CSRoundEnd_Drawfalse);
    
    new 
maxPlayers GetMaxClients();
    for(new 
1<= maxPlayersi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i))
        {
            
SetEntProp(iProp_Data"m_takedamage"01);
            
SetEntityMoveType(iMOVETYPE_NONE);
        }
    }


    return 
Plugin_Handled;
}


public 
OnMapEnd()
{
    
g_VoteTimer INVALID_HANDLE;


Last edited by Nightshadow999; 01-27-2014 at 17:45.
Nightshadow999 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:14.


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