Change this to ReAPI

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
35
Реакции
9
Hello, I was messing around with ReAPI but dont know what exactly has to be changed to make this work

PHP:
#include <amxmodx>
#include <round_terminator>
#include <timer_controller>
#include <thehidden>

#define TASK_ROUNDEND 1111

new g_iWonGame;
new g_pWonForward;

new const g_szWinner[][] =
{
  "",
  "TH_TWIN",
  "TH_CTWIN"
};

public plugin_init()
{
  register_plugin("[TH] Round winner", TH_VERSION, TH_AUTHOR);

  register_message(get_user_msgid("TextMsg"), "Message_Winner");
  g_pWonForward = CreateMultiForward("th_winner", ET_IGNORE, FP_CELL);
}

public plugin_natives()
{
  register_library("thehidden");
  register_native("th_get_winner", "_get_winner");
  register_native("th_set_winner", "_set_winner");
}

public th_gamemode(mode)
{
  if(mode != GAME_STARTED && task_exists(TASK_ROUNDEND))
    remove_task(TASK_ROUNDEND);

  switch(mode)
  {
    case GAME_RESTARTING: g_iWonGame = false;
    case GAME_PREPARING:
    {
      set_task(6.0, "End_Round_False", TASK_ROUNDEND, _, _, "b");
      g_iWonGame = false;
    }
  }
}

public client_disconnected(id)
{
  if(get_winner())
    End_Round_False(id);
}

public End_Round_False(taskid)
{
  if(th_get_gamemode() == GAME_STARTED || th_get_gamemode() == GAME_UNSET)
  {
    if(taskid != TASK_ROUNDEND)
      TerminateRound(RoundEndType_TeamExtermination, 2, MapType_Bomb);
    else
    {
      if(RoundTimerGet()-floatround(th_get_roundtime()) < 6)
        TerminateRound(RoundEndType_TeamExtermination, 2, MapType_Bomb);

    }
  }
}

public get_winner()
{
  new who, num;
  static players[32];

  get_players(players, num, "ae", "TERRORIST");
  if(num <= 0)
    return who = 2;

  get_players(players, num, "ae", "CT");
  if(num <= 0)
    return who = 1;

  return who;
}

public Message_Winner(msgid, dest, id)
{
  if(th_get_gamemode() != GAME_STARTED || g_iWonGame)
    return PLUGIN_CONTINUE;
  
  static message[20];
  get_msg_arg_string(2, message, charsmax(message));
  if(equal(message, "#Terrorists_Win") || equal(message, "#CTs_Win"))
  {
    new who;
    if(equal(message, "#Terrorists_Win"))
      who = 1;
    else if(equal(message, "#CTs_Win"))
      who = 2;

    if(!who)
      who = get_winner();

    if(who)
    {
      if(who == 1)
      {
        new hidden = th_get_globalinfo(GI_HIDDEN);
        if(is_user_alive(hidden))
          th_set_globalinfo(GI_NEXTHIDDEN, hidden);
      }

      g_iWonGame = who;
      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);

      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 != 1 && team != 2)
    return -1;

  TerminateRound(RoundEndType_TeamExtermination, team);
  return team;
}
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу