PHP:
#include <amxmodx>
#include <round_terminator>
#include <timer_controller>
#include <cvi>
#define TASK_ROUNDEND 1111
new g_iWonGame;
new g_pWonForward;
new const g_szWinner[][] =
{
"",
"CVI_COWBOYSWIN",
"CVI_INDIANSWIN"
};
public plugin_init()
{
register_plugin("[CVI] Round winner", CVI_VERSION, CVI_AUTHOR);
register_message(get_user_msgid("TextMsg"), "Message_Winner");
g_pWonForward = CreateMultiForward("cvi_winner", ET_IGNORE, FP_CELL);
}
public plugin_natives()
{
register_library("cvi");
register_native("cvi_get_winner", "_get_winner");
register_native("cvi_set_winner", "_set_winner");
}
public cvi_gamemode(mode)
{
if(mode != GAME_STARTED && task_exists(TASK_ROUNDEND))
remove_task(TASK_ROUNDEND);
if(mode == GAME_RESTARTING)
g_iWonGame = false;
}
public Message_Winner(msgid, dest, id)
{
if(g_iWonGame || cvi_get_globalinfo(GI_GAMEMODE) != GAME_STARTED)
return PLUGIN_CONTINUE;
static message[20];
get_msg_arg_string(2, message, charsmax(message));
if(equal(message, "#Terrorists_Win") || equal(message, "#CTs_Win"))
{
g_iWonGame = 0;
if(equal(message, "#Terrorists_Win"))
g_iWonGame = PC_COWBOY;
else if(equal(message, "#CTs_Win"))
g_iWonGame = PC_INDIAN;
if(g_iWonGame)
{
static out[32];
formatex(out, charsmax(out), "%L", LANG_PLAYER, g_szWinner[g_iWonGame]);
set_msg_arg_string(2, out);
new ret;
ExecuteForward(g_pWonForward, ret, g_iWonGame);
client_print_color(0, print_team_default, "%s ^3%L^1", CVI_TAG, LANG_PLAYER, g_szWinner[g_iWonGame]);
return PLUGIN_HANDLED;
}
}
return PLUGIN_CONTINUE;
}
public _get_winner()
return g_iWonGame;
public _set_winner(plugin, params)
{
if(params != 1)
return -1;
new team = get_param(1);
if(team != PC_COWBOY && team != PC_INDIAN)
return -1;
TerminateRound(RoundEndType_TeamExtermination, team);
return team;
}