Change this to ReAPI

Сообщения
35
Реакции
9
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;
}
Specifically the _set_winner function, I dont wanna use anything related to Round_terminator
 

Garey

ninjaCow
Сообщения
422
Реакции
1,056
Помог
10 раз(а)
show your attempts to port to reapi, otherwise wrong section
 
Сообщения
35
Реакции
9
PHP:
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); // THIS
rg_round_end( 3.0, ?, ? );

return team;
}
Thing is, I wanna change the TerminateRound and use rg_round_end, thing is, do I need to use "team" or use switch with CT/TT team and do

PHP:
rg_round_end( 3.0, WINSTATUS_CT, ROUND_END_DRAW );
rg_round_end( 3.0, WINSTATUS_TT, ROUND_END_DRAW );
or something like that?
 
Сообщения
35
Реакции
9
Gotta check that, another question on rg_round_end how do you replace RoundEndType_TeamExtermination? or is not needed?
20 Июн 2018
Gotta check that, another question on rg_round_end how do you replace RoundEndType_TeamExtermination? or is not needed?

edit

PHP:
public _set_winner(plugin, params)
{
    new iCowboy[32], iCowboyNum;
    new iIndian[32], iIndianNum;
 
    get_players(iCowboy, iCowboyNum, "ae", "TERRORIST");
    get_players(iIndian, iIndianNum, "ae", "CT");
 
    if(iCowboyNum <= 0)
    {
        rg_round_end(
            .tmDelay = 1.0,
            .st = WINSTATUS_TERRORISTS,
            .message = "COWBOY"
        );
    }
    else if(iIndianNum <= 0)
    {
        rg_round_end(
            .tmDelay = 1.0,
            .st = WINSTATUS_CTS,
            .message = "INDIOS"
        );
    }
}/[php]

Something like that? Considering _set_winner is used as a native with the following return

[php]/**
 * Sets/gets winner.
 *
 * @param value   sets new winner.
 * @return        winner.
 */
native cvi_get_winner();
native cvi_set_winner(value);
 

Garey

ninjaCow
Сообщения
422
Реакции
1,056
Помог
10 раз(а)
Just use WINSTATUS_CT/WINSTATUS_TT
 

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

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