TF2-Built-in-Vote-sm_nextmap-bug-fix
This hooks 'vote success' user message and changes 'sm_nextmap' cvar to usermsg's value.
This plugin helps prevent TF2 built-in vote mechanism not working through changing 'sm_nextmap' cvar forcibily.
I did a few tries but only this 'indirect' way worked. So I post this plugin although it has a ugly and indirect way.
I hope this could be helpful to other people, and if you know the way to fix this problem in right way, please reply to this thread and i would be very thankful to you.
Link to my github repository:
https://github.com/jobggun/Sourcemod...xtmap-bug-fix/
Easy access to my code:
PHP Code:
#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required
ConVar g_CvarSmnextmap = null;
public Plugin myinfo = {
name = "TF2 Built-in Vote sm_nextmap bug fix",
author = "Jobggun",
description = "Making TF2 Built-in vote work well with sourcemod nextmap plugin",
version = "1.0.0",
url = ""
};
public void OnPluginStart()
{
g_CvarSmnextmap = FindConVar("sm_nextmap");
HookUserMessage(GetUserMessageId("VotePass"), Hook_ChangeLevel, true);
}
public Action Hook_ChangeLevel(UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init)
{
int team;
char reason[256];
char map[256];
team = msg.ReadByte();
msg.ReadString(reason, sizeof(reason), false);
msg.ReadString(map, sizeof(map), false);
if(!StrEqual(reason, "#TF_vote_passed_changelevel", false))
{
return Plugin_Continue;
}
g_CvarSmnextmap.SetString(map, false, true);
return Plugin_Continue;
}
Link to my github repository:
https://github.com/jobggun/Sourcemod...xtmap-bug-fix/