Raised This Month: $51 Target: $400
 12% 

[CSGO] Map Change Client Crash Fixer (v1.0.7 , 2019/06/23)


Post New Thread Reply   
 
Thread Tools Display Modes
Spyrek
Senior Member
Join Date: Jun 2009
Old 03-09-2019 , 17:50   Re: [CSGO] Map Change Client Crash Fixer (v1.0.6 , 2018/09/11)
Reply With Quote #111

Quote:
Originally Posted by Cruze View Post
Yup it's not this plugin's issue.
Cvars posted in previous post also didn't help.
Spyrek is offline
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 03-10-2019 , 06:14   Re: [CSGO] Map Change Client Crash Fixer (v1.0.6 , 2018/09/11)
Reply With Quote #112

It is indeed an issue, as I described below:

Quote:
Originally Posted by sneaK View Post
I believe the issue stems from all players being disconnected just before the map actually changes on the server, leading to the map essentially "restarting". Same effect would be loading into a server by yourself, playing a couple rounds out, then disconnecting and rejoining. The map restarts all over again.
This is default server behavior. Join an empty server, wait a while. Disconnect, rejoin the same server, and the whole map will have started all over again (note total map and round time remaining). That's what's happening here, because every client is disconnecting and re-connecting, before the map actually changes.
__________________

Last edited by sneaK; 03-10-2019 at 06:14.
sneaK is offline
Agent Wesker
Senior Member
Join Date: Apr 2012
Old 03-10-2019 , 10:44   Re: [CSGO] Map Change Client Crash Fixer (v1.0.6 , 2018/09/11)
Reply With Quote #113

Quote:
Originally Posted by sneaK View Post
It is indeed an issue, as I described below:



This is default server behavior. Join an empty server, wait a while. Disconnect, rejoin the same server, and the whole map will have started all over again (note total map and round time remaining). That's what's happening here, because every client is disconnecting and re-connecting, before the map actually changes.
Temporary fix may be to skip the first person in the retry loop, downside being that person may crash but the level would successfully change.

Here's my edit below
Attached Files
File Type: sp Get Plugin or Get Source (mapcrashfixer.sp - 398 views - 2.7 KB)

Last edited by Agent Wesker; 03-10-2019 at 16:29.
Agent Wesker is offline
Spyrek
Senior Member
Join Date: Jun 2009
Old 03-10-2019 , 17:41   Re: [CSGO] Map Change Client Crash Fixer (v1.0.6 , 2018/09/11)
Reply With Quote #114

Quote:
Originally Posted by Agent Wesker View Post
Temporary fix may be to skip the first person in the retry loop, downside being that person may crash but the level would successfully change.

Here's my edit below
Maybe we can use gotv and disable hibernation?
Spyrek is offline
Agent Wesker
Senior Member
Join Date: Apr 2012
Old 03-10-2019 , 18:18   Re: [CSGO] Map Change Client Crash Fixer (v1.0.6 , 2018/09/11)
Reply With Quote #115

Quote:
Originally Posted by Spyrek View Post
Maybe we can use gotv and disable hibernation?
GoTV is a bot so that wouldn't do anything & I'm not sure disabling hibernation would fix it...

This bug only happens with SetNextMap() and not ForceChangeLevel() so you could technically edit your MapChooser plugin with that function.

I've successfully solved it with the above change, use the included mapchooser_extended if you are using that plugin. Also replace rockthevote if you have issues with that.
Attached Files
File Type: sp Get Plugin or Get Source (mapchooser_extended.sp - 402 views - 62.1 KB)
File Type: smx mapchooser_extended.smx (32.3 KB, 327 views)
File Type: sp Get Plugin or Get Source (rockthevote_retry.sp - 806 views - 7.6 KB)
File Type: sp Get Plugin or Get Source (mapcrashfixer.sp - 795 views - 3.2 KB)

Last edited by Agent Wesker; 03-11-2019 at 01:20.
Agent Wesker is offline
OneMore
Senior Member
Join Date: Feb 2019
Old 03-11-2019 , 17:22   Re: [CSGO] Map Change Client Crash Fixer (v1.0.6 , 2018/09/11)
Reply With Quote #116

Quote:
Originally Posted by Agent Wesker View Post
...use the included mapchooser_extended if you are using that plugin.
Would you please publish here or select somehow the changes in mapchooser_extended? I use Ultimate mapchooser and hope to do the same with it, or even ask a developer to include in the source code.
OneMore is offline
paulo_crash
AlliedModders Donor
Join Date: May 2016
Location: Brazil
Old 03-11-2019 , 20:32   Re: [CSGO] Map Change Client Crash Fixer (v1.0.6 , 2018/09/11)
Reply With Quote #117

Quote:
Originally Posted by Agent Wesker View Post
GoTV is a bot so that wouldn't do anything & I'm not sure disabling hibernation would fix it...

This bug only happens with SetNextMap() and not ForceChangeLevel() so you could technically edit your MapChooser plugin with that function.

I've successfully solved it with the above change, use the included mapchooser_extended if you are using that plugin. Also replace rockthevote if you have issues with that.
Doubt is, I use the standard plugins of sourcemod, in the case the mapchooser itself and even the standard rockthevote as well.

If this problem is solved with the change you say because they do not do in the plugin itself, would not it be better in the case?
paulo_crash is offline
Agent Wesker
Senior Member
Join Date: Apr 2012
Old 03-11-2019 , 21:20   Re: [CSGO] Map Change Client Crash Fixer (v1.0.6 , 2018/09/11)
Reply With Quote #118

Quote:
Originally Posted by paulo_crash View Post
Doubt is, I use the standard plugins of sourcemod, in the case the mapchooser itself and even the standard rockthevote as well.

If this problem is solved with the change you say because they do not do in the plugin itself, would not it be better in the case?
If clients crash on rockthevote then download my edited version, otherwise only add mapcrashfixer to fix the change level issue.
Agent Wesker is offline
Cruze
Veteran Member
Join Date: May 2017
Old 03-13-2019 , 13:04   Re: [CSGO] Map Change Client Crash Fixer (v1.0.6 , 2018/09/11)
Reply With Quote #119

Quote:
Originally Posted by Agent Wesker View Post
GoTV is a bot so that wouldn't do anything & I'm not sure disabling hibernation would fix it...

This bug only happens with SetNextMap() and not ForceChangeLevel() so you could technically edit your MapChooser plugin with that function.

I've successfully solved it with the above change, use the included mapchooser_extended if you are using that plugin. Also replace rockthevote if you have issues with that.
Works on normal map change but game still crashes on rockthevote!
Using mapchooser_extended.
rockthevote_extended:
PHP Code:
/**
 * vim: set ts=4 :
 * =============================================================================
 * Rock The Vote Extended
 * Creates a map vote when the required number of players have requested one.
 *
 * Rock The Vote Extended (C)2012-2013 Powerlord (Ross Bemrose)
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
 * =============================================================================
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * As a special exception, AlliedModders LLC gives you permission to link the
 * code of this program (as well as its derivative works) to "Half-Life 2," the
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
 * by the Valve Corporation.  You must obey the GNU General Public License in
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
 * this exception to all derivative works.  AlliedModders LLC defines further
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
 * or <http://www.sourcemod.net/license.php>.
 *
 * Version: $Id$
 */

#include <sourcemod>
#include <mapchooser>
#include "include/mapchooser_extended"
#include <nextmap>
#include <multicolors>

#pragma semicolon 1

#define MCE_VERSION "1.10.1"

public Plugin:myinfo =
{
    
name "Rock The Vote Extended",
    
author "Powerlord and AlliedModders LLC",
    
description "Provides RTV Map Voting",
    
version MCE_VERSION,
    
url "https://forums.alliedmods.net/showthread.php?t=156974"
};

new 
Handle:g_Cvar_Needed INVALID_HANDLE;
new 
Handle:g_Cvar_MinPlayers INVALID_HANDLE;
new 
Handle:g_Cvar_InitialDelay INVALID_HANDLE;
new 
Handle:g_Cvar_Interval INVALID_HANDLE;
new 
Handle:g_Cvar_ChangeTime INVALID_HANDLE;
new 
Handle:g_Cvar_RTVPostVoteAction INVALID_HANDLE;

new 
bool:g_CanRTV false;        // True if RTV loaded maps and is active.
new bool:g_RTVAllowed false;    // True if RTV is available to players. Used to delay rtv votes.
new g_Voters 0;                // Total voters connected. Doesn't include fake clients.
new g_Votes 0;                // Total number of "say rtv" votes
new g_VotesNeeded 0;            // Necessary votes before map vote begins. (voters * percent_needed)
new bool:g_Voted[MAXPLAYERS+1] = {false, ...};

new 
bool:g_InChange false;

public 
OnPluginStart()
{
    
LoadTranslations("common.phrases");
    
LoadTranslations("rockthevote.phrases");
    
LoadTranslations("basevotes.phrases");
    
    
g_Cvar_Needed CreateConVar("sm_rtv_needed""0.60""Percentage of players needed to rockthevote (Def 60%)"0true0.05true1.0);
    
g_Cvar_MinPlayers CreateConVar("sm_rtv_minplayers""0""Number of players required before RTV will be enabled."0true0.0truefloat(MAXPLAYERS));
    
g_Cvar_InitialDelay CreateConVar("sm_rtv_initialdelay""30.0""Time (in seconds) before first RTV can be held"0true0.00);
    
g_Cvar_Interval CreateConVar("sm_rtv_interval""240.0""Time (in seconds) after a failed RTV before another can be held"0true0.00);
    
g_Cvar_ChangeTime CreateConVar("sm_rtv_changetime""0""When to change the map after a succesful RTV: 0 - Instant, 1 - RoundEnd, 2 - MapEnd"_true0.0true2.0);
    
g_Cvar_RTVPostVoteAction CreateConVar("sm_rtv_postvoteaction""0""What to do with RTV's after a mapvote has completed. 0 - Allow, success = instant change, 1 - Deny"_true0.0true1.0);
    
    
RegConsoleCmd("say"Command_Say);
    
RegConsoleCmd("say_team"Command_Say);
    
    
RegConsoleCmd("sm_rtv"Command_RTV);
    
    
RegAdminCmd("sm_forcertv"Command_ForceRTVADMFLAG_CHANGEMAP"Force an RTV vote");
    
RegAdminCmd("mce_forcertv"Command_ForceRTVADMFLAG_CHANGEMAP"Force an RTV vote");
    
    
// Rock The Vote Extended cvars
    
CreateConVar("rtve_version"MCE_VERSION"Rock The Vote Extended Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
    
AutoExecConfig(true"rtv");
}

public 
OnMapStart()
{
    
g_Voters 0;
    
g_Votes 0;
    
g_VotesNeeded 0;
    
g_InChange false;
    
    
/* Handle late load */
    
for (new i=1i<=MaxClientsi++)
    {
        if (
IsClientConnected(i))
        {
            
OnClientConnected(i);    
        }    
    }
}

public 
OnMapEnd()
{
    
g_CanRTV false;    
    
g_RTVAllowed false;
}

public 
OnConfigsExecuted()
{    
    
g_CanRTV true;
    
g_RTVAllowed false;
    
CreateTimer(GetConVarFloat(g_Cvar_InitialDelay), Timer_DelayRTV_TIMER_FLAG_NO_MAPCHANGE);
}

public 
OnClientConnected(client)
{
    if(
IsFakeClient(client))
        return;
    
    
g_Voted[client] = false;

    
g_Voters++;
    
g_VotesNeeded RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
    
    return;
}

public 
OnClientDisconnect(client)
{
    if(
IsFakeClient(client))
        return;
    
    if(
g_Voted[client])
    {
        
g_Votes--;
    }
    
    
g_Voters--;
    
    
g_VotesNeeded RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
    
    if (!
g_CanRTV)
    {
        return;    
    }
    
    if (
g_Votes && 
        
g_Voters && 
        
g_Votes >= g_VotesNeeded && 
        
g_RTVAllowed 
    {
        if (
GetConVarInt(g_Cvar_RTVPostVoteAction) == && HasEndOfMapVoteFinished())
        {
            return;
        }
        
        
StartRTV();
    }    
}

public 
Action:Command_RTV(clientargs)
{
    if (!
g_CanRTV || !client)
    {
        return 
Plugin_Handled;
    }
    
    
AttemptRTV(client);
    
    return 
Plugin_Handled;
}

public 
Action:Command_Say(clientargs)
{
    if (!
g_CanRTV || !client)
    {
        return 
Plugin_Continue;
    }
    
    
decl String:text[192];
    if (!
GetCmdArgString(textsizeof(text)))
    {
        return 
Plugin_Continue;
    }
    
    new 
startidx 0;
    if(
text[strlen(text)-1] == '"')
    {
        
text[strlen(text)-1] = '\0';
        
startidx 1;
    }
    
    new 
ReplySource:old SetCmdReplySource(SM_REPLY_TO_CHAT);
    
    if (
strcmp(text[startidx], "rtv"false) == || strcmp(text[startidx], "rockthevote"false) == 0)
    {
        
AttemptRTV(client);
    }
    
    
SetCmdReplySource(old);
    
    return 
Plugin_Continue;    
}

AttemptRTV(client)
{
    if (!
g_RTVAllowed  || (GetConVarInt(g_Cvar_RTVPostVoteAction) == && HasEndOfMapVoteFinished()))
    {
        
CReplyToCommand(client"[SM] %t""RTV Not Allowed");
        return;
    }
        
    if (!
CanMapChooserStartVote())
    {
        
CReplyToCommand(client"[SM] %t""RTV Started");
        return;
    }
    
    if (
GetClientCount(true) < GetConVarInt(g_Cvar_MinPlayers))
    {
        
CReplyToCommand(client"[SM] %t""Minimal Players Not Met");
        return;            
    }
    
    if (
g_Voted[client])
    {
        
CReplyToCommand(client"[SM] %t""Already Voted"g_Votesg_VotesNeeded);
        return;
    }    
    
    new 
String:name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
    
g_Votes++;
    
g_Voted[client] = true;
    
    
CPrintToChatAll("[SM] %t""RTV Requested"nameg_Votesg_VotesNeeded);
    
    if (
g_Votes >= g_VotesNeeded)
    {
        
StartRTV();
    }    
}

public 
Action:Timer_DelayRTV(Handle:timer)
{
    
g_RTVAllowed true;
}

StartRTV()
{
    if (
g_InChange)
    {
        return;    
    }
    
    if (
EndOfMapVoteEnabled() && HasEndOfMapVoteFinished())
    {
        
/* Change right now then */
        
new String:map[PLATFORM_MAX_PATH];
        if (
GetNextMap(mapsizeof(map)))
        {
            
CPrintToChatAll("[SM] %t""Changing Maps"map);
            
CreateTimer(5.0Timer_ChangeMap_TIMER_FLAG_NO_MAPCHANGE);
            
g_InChange true;
            
            
ResetRTV();
            
            
g_RTVAllowed false;
        }
        return;    
    }
    
    if (
CanMapChooserStartVote())
    {
        new 
MapChange:when MapChange:GetConVarInt(g_Cvar_ChangeTime);
        
InitiateMapChooserVote(when);
        
        
ResetRTV();
        
        
g_RTVAllowed false;
        
CreateTimer(GetConVarFloat(g_Cvar_Interval), Timer_DelayRTV_TIMER_FLAG_NO_MAPCHANGE);
    }
}

ResetRTV()
{
    
g_Votes 0;
            
    for (new 
i=1i<=MAXPLAYERSi++)
    {
        
g_Voted[i] = false;
    }
}

public 
Action Timer_ChangeMap(Handle hTimer)
{        
    
char map[PLATFORM_MAX_PATH];
    if (
GetNextMap(mapsizeof(map)))
    {    
        
LogMessage("RTV changing map manually to %s"map);
        
LogAction(-1, -1"RTV changing map manually to %s"map);
        
CreateTimer(0.1Timer_Final);
    }
}

public 
Action Timer_Final(Handle hTimer)
{
    
g_InChange false;
        
    
char map[PLATFORM_MAX_PATH];
    if (
GetNextMap(mapsizeof(map)))
    {    
        
ForceChangeLevel(map"RTV after mapvote");
    }
}
/*
public Action:Timer_ChangeMap(Handle:hTimer)
{
    g_InChange = false;
    
    LogMessage("RTV changing map manually");
    
    new String:map[PLATFORM_MAX_PATH];
    if (GetNextMap(map, sizeof(map)))
    {    
        ForceChangeLevel(map, "RTV after mapvote");
    }
    
    return Plugin_Stop;
}
*/

// Rock The Vote Extended functions

public Action:Command_ForceRTV(clientargs)
{
    if (!
g_CanRTV || !client)
    {
        return 
Plugin_Handled;
    }

    
ShowActivity2(client"[RTVE] ""%t""Initiated Vote Map");

    
StartRTV();
    
    return 
Plugin_Handled;

__________________
Taking paid private requests! Contact me
Cruze is offline
Agent Wesker
Senior Member
Join Date: Apr 2012
Old 03-13-2019 , 15:48   Re: [CSGO] Map Change Client Crash Fixer (v1.0.6 , 2018/09/11)
Reply With Quote #120

Quote:
Originally Posted by Cruze View Post
Works on normal map change but game still crashes on rockthevote!
Using mapchooser_extended.
rockthevote_extended:
PHP Code:
/**
 * vim: set ts=4 :
 * =============================================================================
 * Rock The Vote Extended
 * Creates a map vote when the required number of players have requested one.
 *
 * Rock The Vote Extended (C)2012-2013 Powerlord (Ross Bemrose)
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
 * =============================================================================
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * As a special exception, AlliedModders LLC gives you permission to link the
 * code of this program (as well as its derivative works) to "Half-Life 2," the
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
 * by the Valve Corporation.  You must obey the GNU General Public License in
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
 * this exception to all derivative works.  AlliedModders LLC defines further
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
 * or <http://www.sourcemod.net/license.php>.
 *
 * Version: $Id$
 */

#include <sourcemod>
#include <mapchooser>
#include "include/mapchooser_extended"
#include <nextmap>
#include <multicolors>

#pragma semicolon 1

#define MCE_VERSION "1.10.1"

public Plugin:myinfo =
{
    
name "Rock The Vote Extended",
    
author "Powerlord and AlliedModders LLC",
    
description "Provides RTV Map Voting",
    
version MCE_VERSION,
    
url "https://forums.alliedmods.net/showthread.php?t=156974"
};

new 
Handle:g_Cvar_Needed INVALID_HANDLE;
new 
Handle:g_Cvar_MinPlayers INVALID_HANDLE;
new 
Handle:g_Cvar_InitialDelay INVALID_HANDLE;
new 
Handle:g_Cvar_Interval INVALID_HANDLE;
new 
Handle:g_Cvar_ChangeTime INVALID_HANDLE;
new 
Handle:g_Cvar_RTVPostVoteAction INVALID_HANDLE;

new 
bool:g_CanRTV false;        // True if RTV loaded maps and is active.
new bool:g_RTVAllowed false;    // True if RTV is available to players. Used to delay rtv votes.
new g_Voters 0;                // Total voters connected. Doesn't include fake clients.
new g_Votes 0;                // Total number of "say rtv" votes
new g_VotesNeeded 0;            // Necessary votes before map vote begins. (voters * percent_needed)
new bool:g_Voted[MAXPLAYERS+1] = {false, ...};

new 
bool:g_InChange false;

public 
OnPluginStart()
{
    
LoadTranslations("common.phrases");
    
LoadTranslations("rockthevote.phrases");
    
LoadTranslations("basevotes.phrases");
    
    
g_Cvar_Needed CreateConVar("sm_rtv_needed""0.60""Percentage of players needed to rockthevote (Def 60%)"0true0.05true1.0);
    
g_Cvar_MinPlayers CreateConVar("sm_rtv_minplayers""0""Number of players required before RTV will be enabled."0true0.0truefloat(MAXPLAYERS));
    
g_Cvar_InitialDelay CreateConVar("sm_rtv_initialdelay""30.0""Time (in seconds) before first RTV can be held"0true0.00);
    
g_Cvar_Interval CreateConVar("sm_rtv_interval""240.0""Time (in seconds) after a failed RTV before another can be held"0true0.00);
    
g_Cvar_ChangeTime CreateConVar("sm_rtv_changetime""0""When to change the map after a succesful RTV: 0 - Instant, 1 - RoundEnd, 2 - MapEnd"_true0.0true2.0);
    
g_Cvar_RTVPostVoteAction CreateConVar("sm_rtv_postvoteaction""0""What to do with RTV's after a mapvote has completed. 0 - Allow, success = instant change, 1 - Deny"_true0.0true1.0);
    
    
RegConsoleCmd("say"Command_Say);
    
RegConsoleCmd("say_team"Command_Say);
    
    
RegConsoleCmd("sm_rtv"Command_RTV);
    
    
RegAdminCmd("sm_forcertv"Command_ForceRTVADMFLAG_CHANGEMAP"Force an RTV vote");
    
RegAdminCmd("mce_forcertv"Command_ForceRTVADMFLAG_CHANGEMAP"Force an RTV vote");
    
    
// Rock The Vote Extended cvars
    
CreateConVar("rtve_version"MCE_VERSION"Rock The Vote Extended Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
    
AutoExecConfig(true"rtv");
}

public 
OnMapStart()
{
    
g_Voters 0;
    
g_Votes 0;
    
g_VotesNeeded 0;
    
g_InChange false;
    
    
/* Handle late load */
    
for (new i=1i<=MaxClientsi++)
    {
        if (
IsClientConnected(i))
        {
            
OnClientConnected(i);    
        }    
    }
}

public 
OnMapEnd()
{
    
g_CanRTV false;    
    
g_RTVAllowed false;
}

public 
OnConfigsExecuted()
{    
    
g_CanRTV true;
    
g_RTVAllowed false;
    
CreateTimer(GetConVarFloat(g_Cvar_InitialDelay), Timer_DelayRTV_TIMER_FLAG_NO_MAPCHANGE);
}

public 
OnClientConnected(client)
{
    if(
IsFakeClient(client))
        return;
    
    
g_Voted[client] = false;

    
g_Voters++;
    
g_VotesNeeded RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
    
    return;
}

public 
OnClientDisconnect(client)
{
    if(
IsFakeClient(client))
        return;
    
    if(
g_Voted[client])
    {
        
g_Votes--;
    }
    
    
g_Voters--;
    
    
g_VotesNeeded RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
    
    if (!
g_CanRTV)
    {
        return;    
    }
    
    if (
g_Votes && 
        
g_Voters && 
        
g_Votes >= g_VotesNeeded && 
        
g_RTVAllowed 
    {
        if (
GetConVarInt(g_Cvar_RTVPostVoteAction) == && HasEndOfMapVoteFinished())
        {
            return;
        }
        
        
StartRTV();
    }    
}

public 
Action:Command_RTV(clientargs)
{
    if (!
g_CanRTV || !client)
    {
        return 
Plugin_Handled;
    }
    
    
AttemptRTV(client);
    
    return 
Plugin_Handled;
}

public 
Action:Command_Say(clientargs)
{
    if (!
g_CanRTV || !client)
    {
        return 
Plugin_Continue;
    }
    
    
decl String:text[192];
    if (!
GetCmdArgString(textsizeof(text)))
    {
        return 
Plugin_Continue;
    }
    
    new 
startidx 0;
    if(
text[strlen(text)-1] == '"')
    {
        
text[strlen(text)-1] = '\0';
        
startidx 1;
    }
    
    new 
ReplySource:old SetCmdReplySource(SM_REPLY_TO_CHAT);
    
    if (
strcmp(text[startidx], "rtv"false) == || strcmp(text[startidx], "rockthevote"false) == 0)
    {
        
AttemptRTV(client);
    }
    
    
SetCmdReplySource(old);
    
    return 
Plugin_Continue;    
}

AttemptRTV(client)
{
    if (!
g_RTVAllowed  || (GetConVarInt(g_Cvar_RTVPostVoteAction) == && HasEndOfMapVoteFinished()))
    {
        
CReplyToCommand(client"[SM] %t""RTV Not Allowed");
        return;
    }
        
    if (!
CanMapChooserStartVote())
    {
        
CReplyToCommand(client"[SM] %t""RTV Started");
        return;
    }
    
    if (
GetClientCount(true) < GetConVarInt(g_Cvar_MinPlayers))
    {
        
CReplyToCommand(client"[SM] %t""Minimal Players Not Met");
        return;            
    }
    
    if (
g_Voted[client])
    {
        
CReplyToCommand(client"[SM] %t""Already Voted"g_Votesg_VotesNeeded);
        return;
    }    
    
    new 
String:name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
    
g_Votes++;
    
g_Voted[client] = true;
    
    
CPrintToChatAll("[SM] %t""RTV Requested"nameg_Votesg_VotesNeeded);
    
    if (
g_Votes >= g_VotesNeeded)
    {
        
StartRTV();
    }    
}

public 
Action:Timer_DelayRTV(Handle:timer)
{
    
g_RTVAllowed true;
}

StartRTV()
{
    if (
g_InChange)
    {
        return;    
    }
    
    if (
EndOfMapVoteEnabled() && HasEndOfMapVoteFinished())
    {
        
/* Change right now then */
        
new String:map[PLATFORM_MAX_PATH];
        if (
GetNextMap(mapsizeof(map)))
        {
            
CPrintToChatAll("[SM] %t""Changing Maps"map);
            
CreateTimer(5.0Timer_ChangeMap_TIMER_FLAG_NO_MAPCHANGE);
            
g_InChange true;
            
            
ResetRTV();
            
            
g_RTVAllowed false;
        }
        return;    
    }
    
    if (
CanMapChooserStartVote())
    {
        new 
MapChange:when MapChange:GetConVarInt(g_Cvar_ChangeTime);
        
InitiateMapChooserVote(when);
        
        
ResetRTV();
        
        
g_RTVAllowed false;
        
CreateTimer(GetConVarFloat(g_Cvar_Interval), Timer_DelayRTV_TIMER_FLAG_NO_MAPCHANGE);
    }
}

ResetRTV()
{
    
g_Votes 0;
            
    for (new 
i=1i<=MAXPLAYERSi++)
    {
        
g_Voted[i] = false;
    }
}

public 
Action Timer_ChangeMap(Handle hTimer)
{        
    
char map[PLATFORM_MAX_PATH];
    if (
GetNextMap(mapsizeof(map)))
    {    
        
LogMessage("RTV changing map manually to %s"map);
        
LogAction(-1, -1"RTV changing map manually to %s"map);
        
CreateTimer(0.1Timer_Final);
    }
}

public 
Action Timer_Final(Handle hTimer)
{
    
g_InChange false;
        
    
char map[PLATFORM_MAX_PATH];
    if (
GetNextMap(mapsizeof(map)))
    {    
        
ForceChangeLevel(map"RTV after mapvote");
    }
}
/*
public Action:Timer_ChangeMap(Handle:hTimer)
{
    g_InChange = false;
    
    LogMessage("RTV changing map manually");
    
    new String:map[PLATFORM_MAX_PATH];
    if (GetNextMap(map, sizeof(map)))
    {    
        ForceChangeLevel(map, "RTV after mapvote");
    }
    
    return Plugin_Stop;
}
*/

// Rock The Vote Extended functions

public Action:Command_ForceRTV(clientargs)
{
    if (!
g_CanRTV || !client)
    {
        return 
Plugin_Handled;
    }

    
ShowActivity2(client"[RTVE] ""%t""Initiated Vote Map");

    
StartRTV();
    
    return 
Plugin_Handled;

Please pastebin me your SM log file since enabling my edited plugin.
Agent Wesker 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 19:52.


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