AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   New Plugin Submissions (https://forums.alliedmods.net/forumdisplay.php?f=26)
-   -   [ReApi/ReGameDll] Unreal Spawn Fixer (https://forums.alliedmods.net/showthread.php?t=335724)

karaulov 12-28-2021 04:16

[ReApi/ReGameDll] Unreal Spawn Fixer
 
Plug-in can add "ignoring spawns count" for game.

Added possible to play any map with any spawn count. (For example with this plug-in you can play map with 8 spawn points at server with 32 players)

ReApi+ReGameDll is required.

Also need use semiclip, resemiclip, or internal semiclip.
Code:

Code:

#include <amxmodx>
#include <reapi>
#include <fakemeta>

#define USE_OWN_SEMICLIP_IF_NOT_FOUND

#define PLUGIN "Unreal Spawn Fixer"
#define AUTHOR "karaulov"

new maxplayers = 32;

public plugin_init()
{
  new VERSION[64] = "1.1";
  register_plugin(PLUGIN, VERSION, AUTHOR);
 
  RegisterHookChain(RG_CSGameRules_RestartRound, "RestartRound_Pre", false);
  RegisterHookChain(RG_CSGameRules_RestartRound, "RestartRound_Post", true);
 
  if (cvar_exists("resemiclip_version"))
  {
      add(VERSION,charsmax(VERSION),"_resemiclip");
      server_cmd("semiclip_option semiclip 1");
      server_cmd("semiclip_option time 0");
  }
  else if (cvar_exists("team_semiclip_version"))
  {
      add(VERSION,charsmax(VERSION),"_team_semiclip");
      set_cvar_num("semiclip",1);
      set_cvar_num("semiclip_block_team",0);
      set_cvar_num("semiclip_duration",0);
  }
  else
  {
      add(VERSION,charsmax(VERSION),"_semiclip");
#if defined USE_OWN_SEMICLIP_IF_NOT_FOUND
      register_forward(FM_PlayerPreThink, "preThink");
      register_forward(FM_PlayerPostThink, "postThink");
      register_forward(FM_AddToFullPack, "addToFullPack", 1);
      maxplayers = get_maxplayers();
#endif
  }
 
  register_cvar("unreal_spawn_fixer", VERSION, FCVAR_SERVER | FCVAR_SPONLY);
   
  set_member_game(m_bLevelInitialized,true);
  set_member_game(m_iSpawnPointCount_CT,32);
  set_member_game(m_iSpawnPointCount_Terrorist,32);
 
  set_cvar_float("mp_respawn_immunitytime",0.5);
  set_cvar_num("mp_respawn_immunity_force_unset",0);
  set_cvar_num("mp_kill_filled_spawn",0);
}

public RestartRound_Pre()
{
  if (cvar_exists("resemiclip_version"))
  {
      server_cmd("semiclip_option semiclip 1");
      server_cmd("semiclip_option time 0");
  }
  else if (cvar_exists("team_semiclip_version"))
  {
      set_cvar_num("semiclip",1);
      set_cvar_num("semiclip_block_team",0);
      set_cvar_num("semiclip_duration",0);
  }
 
  set_cvar_float("mp_respawn_immunitytime",0.5);
  set_cvar_num("mp_respawn_immunity_force_unset",0);
  set_cvar_num("mp_kill_filled_spawn",0);
}

public RestartRound_Post()
{
  set_member_game(m_bLevelInitialized,true);
  set_member_game(m_iSpawnPointCount_CT,32);
  set_member_game(m_iSpawnPointCount_Terrorist,32);
}

//AUTHOR "skyjur"
new bool:plrSolid[33]
new bool:plrRestore[33]
new plrTeam[33]

public addToFullPack(es, e, ent, host, hostflags, player, pSet)
{
  if(player)
  {
      if(plrSolid[host] && plrSolid[ent] && plrTeam[host] == plrTeam[ent])
      {
        set_es(es, ES_Solid, SOLID_NOT)
        set_es(es, ES_RenderMode, kRenderTransAlpha)
        set_es(es, ES_RenderAmt, 230)
      }
  }
}

FirstThink()
{
  for(new i = 1; i <= maxplayers; i++)
  {
      if(!is_user_alive(i))
      {
        plrSolid[i] = false
        continue
      }
   
      plrTeam[i] = get_user_team(i)
      plrSolid[i] = get_entvar(i, var_solid) == SOLID_SLIDEBOX ? true : false
  }
}

public preThink(id)
{
  static i, LastThink
 
  if(LastThink > id)
  {
      FirstThink()
  }
  LastThink = id

 
  if(!plrSolid[id]) return
 
  for(i = 1; i <= maxplayers; i++)
  {
      if(!plrSolid[i] || id == i) continue
   
      if(plrTeam[i] == plrTeam[id])
      {
        set_entvar(i, var_solid, SOLID_NOT)
        plrRestore[i] = true
      }
  }
}

public postThink(id)
{
  static i
 
  for(i = 1; i <= maxplayers; i++)
  {
      if(plrRestore[i])
      {
        set_entvar(i, var_solid, SOLID_SLIDEBOX)
        plrRestore[i] = false
      }
  }
}

For using it with hlds need replace reapi functions with alternative .

JusTGo 12-28-2021 04:49

Re: [ReApi/ReGameDll] Unreal Spawn Fixer
 
What do you need mp_respawn_immunitytime for?

karaulov 12-28-2021 06:31

Re: [ReApi/ReGameDll] Unreal Spawn Fixer
 
Not kill by worldspawn

Shadows Adi 12-28-2021 08:54

Re: [ReApi/ReGameDll] Unreal Spawn Fixer
 
If you need reGameDLL for this plugin, why not use it's cvars?
PHP Code:

// Kill the player in filled spawn before spawning some one else (Prevents players stucking in each other).
// Only disable this if you have semiclip or other plugins that prevents stucking
// 0 - disabled
// 1 - enabled
//
// Default value: "1"
mp_kill_filled_spawn 1 

Also, don't hardcode:
Code:

new maxplayers = 32;
Not all servers has 32 players. Use get_maxplayers() or m_nMaxPlayers game member.
Code:

get_member_game(m_nMaxPlayers)

Natsheh 12-28-2021 21:14

Re: [ReApi/ReGameDll] Unreal Spawn Fixer
 
Its not hard coding since the game is already limited for 32 players max, but he need to initialize it as a constant.

karaulov 12-28-2021 22:47

Re: [ReApi/ReGameDll] Unreal Spawn Fixer
 
Quote:

Originally Posted by Shadows Adi (Post 2767122)
If you need reGameDLL for this plugin, why not use it's cvars?
PHP Code:

// Kill the player in filled spawn before spawning some one else (Prevents players stucking in each other).
// Only disable this if you have semiclip or other plugins that prevents stucking
// 0 - disabled
// 1 - enabled
//
// Default value: "1"
mp_kill_filled_spawn 1 

Also, don't hardcode:
Code:

new maxplayers = 32;
Not all servers has 32 players. Use get_maxplayers() or m_nMaxPlayers game member.
Code:

get_member_game(m_nMaxPlayers)

It initialized at maxplayers = get_maxplayers(); line. But it not using if server has TeamSemiclip or Resemiclip.

mp_kill_filled_spawn not adding more spawn points, and players can't join to any team.

JusTGo 12-29-2021 04:37

Re: [ReApi/ReGameDll] Unreal Spawn Fixer
 
You don't need mp_respawn_immunitytime if you set mp_kill_filled_spawn to 0.

mp_kill_filled_spawn disable worldspawn damage unless the map has other issues.


All times are GMT -4. The time now is 15:49.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.