大家好,以下是csgo的WARMOD比赛插件的刀战选阵营系统,经常会在刀战结束选阵营的时候服务器卡死。
大神们知道这是哪段代码出问题了?
DisplayStayLeaveVote(winner)
{
if(!IsVoteInProgress())
{
new Handle:menu = CreateMenu(Handle_VoteStayLeave);
SetMenuTitle(menu, "请选择阵营!");
AddMenuItem(menu, "0", "当前阵营");
AddMenuItem(menu, "1", "对方阵营");
SetMenuExitButton(menu, false);
new UsersInTeam[16],
UsersCount = 0;
for( new i = 1; i <= MaxClients; i++ )
{
if(IsClientInGame(i) && GetClientTeam(i) == winner)
{
UsersInTeam[UsersCount++] = i;
}
}
VoteMenu(menu, UsersInTeam, UsersCount, 30);
}
}
public Handle_VoteStayLeave(Handle:menu, MenuAction:action, param1, param2)
{
if(action == MenuAction_End)
{
CloseHandle(menu);
}
else if(action == MenuAction_VoteEnd)
//war_mode = MODE_NONE;
if(param1 == 0)
{
CreateTimer(3.0, Kaishibisai);
}
else
{
/*// Testing: Autoswitch all clients
new theClientTeam = 0;
for(new i = 1; i <= max_clients; i++)
{
if(IsClientInGame(i) && (theClientTeam = GetClientTeam(i)) >= TEAMINDEX_T)
{
// Switch
CS_SwitchTeam( i, 5 - theClientTeam );
}
}*/
ServerCommand("mp_swapteams");
CreateTimer(3.0, Kaishibisai);
}
}
}
public Event_Round_End(Handle:event, const String:name[], bool:dontBroadcast)
{
if (!IsActive(0, true))
{
return;
}
new winner = GetEventInt(event, "winner");
// stats
if (GetConVarBool(g_h_stats_enabled))
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && GetClientTeam(i) == winner)
{
clutch_stats[i][CLUTCH_WON] = 1;
}
LogClutchStats(i);
}
LogEvent("{\"event\": \"round_end\", \"winner\": %d, \"reason\": %d}", winner, GetEventInt(event, "reason"));
}
if (winner > 1 && g_t_score)
{
if (g_t_knife)
{
/*// knife round won
if (GetConVarBool(g_h_auto_knife) && GetConVarBool(g_h_auto_ready))
{
PrintToChatAll(" \x2%s\x1 %d 正在投票选择阵营......", CHAT_PREFIX, winner );
DisplayStayLeaveVote( winner );
}*/
if (GetConVarBool(g_h_stats_enabled))
{
LogEvent("{\"event\": \"knife_win\", \"team\": %d}", winner);
}
PrintToChatAll(" \x2%s \x07%d\x1正在投票选择阵营......", CHAT_PREFIX, winner );
DisplayStayLeaveVote( winner );
g_t_knife = false;
g_t_had_knife = true;
}
if (!g_live)
{
return;
}
if (!g_t_money)
{
g_t_money = true;
}
AddScore(winner);
CheckScores();
}
}
这是完整插件:http://pan.baidu.com/s/1mgkgBck
大神们知道这是哪段代码出问题了?
DisplayStayLeaveVote(winner)
{
if(!IsVoteInProgress())
{
new Handle:menu = CreateMenu(Handle_VoteStayLeave);
SetMenuTitle(menu, "请选择阵营!");
AddMenuItem(menu, "0", "当前阵营");
AddMenuItem(menu, "1", "对方阵营");
SetMenuExitButton(menu, false);
new UsersInTeam[16],
UsersCount = 0;
for( new i = 1; i <= MaxClients; i++ )
{
if(IsClientInGame(i) && GetClientTeam(i) == winner)
{
UsersInTeam[UsersCount++] = i;
}
}
VoteMenu(menu, UsersInTeam, UsersCount, 30);
}
}
public Handle_VoteStayLeave(Handle:menu, MenuAction:action, param1, param2)
{
if(action == MenuAction_End)
{
CloseHandle(menu);
}
else if(action == MenuAction_VoteEnd)
//war_mode = MODE_NONE;
if(param1 == 0)
{
CreateTimer(3.0, Kaishibisai);
}
else
{
/*// Testing: Autoswitch all clients
new theClientTeam = 0;
for(new i = 1; i <= max_clients; i++)
{
if(IsClientInGame(i) && (theClientTeam = GetClientTeam(i)) >= TEAMINDEX_T)
{
// Switch
CS_SwitchTeam( i, 5 - theClientTeam );
}
}*/
ServerCommand("mp_swapteams");
CreateTimer(3.0, Kaishibisai);
}
}
}
public Event_Round_End(Handle:event, const String:name[], bool:dontBroadcast)
{
if (!IsActive(0, true))
{
return;
}
new winner = GetEventInt(event, "winner");
// stats
if (GetConVarBool(g_h_stats_enabled))
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && GetClientTeam(i) == winner)
{
clutch_stats[i][CLUTCH_WON] = 1;
}
LogClutchStats(i);
}
LogEvent("{\"event\": \"round_end\", \"winner\": %d, \"reason\": %d}", winner, GetEventInt(event, "reason"));
}
if (winner > 1 && g_t_score)
{
if (g_t_knife)
{
/*// knife round won
if (GetConVarBool(g_h_auto_knife) && GetConVarBool(g_h_auto_ready))
{
PrintToChatAll(" \x2%s\x1 %d 正在投票选择阵营......", CHAT_PREFIX, winner );
DisplayStayLeaveVote( winner );
}*/
if (GetConVarBool(g_h_stats_enabled))
{
LogEvent("{\"event\": \"knife_win\", \"team\": %d}", winner);
}
PrintToChatAll(" \x2%s \x07%d\x1正在投票选择阵营......", CHAT_PREFIX, winner );
DisplayStayLeaveVote( winner );
g_t_knife = false;
g_t_had_knife = true;
}
if (!g_live)
{
return;
}
if (!g_t_money)
{
g_t_money = true;
}
AddScore(winner);
CheckScores();
}
}
这是完整插件:http://pan.baidu.com/s/1mgkgBck