Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

WIP: Add pause ability #14

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 46 additions & 8 deletions amxmodx/scripting/csdm_core.sma
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ enum forwardlist_e
iFwdGamemodeChanged
}

new HookChain:g_hTraceAttack
new HookChain:g_hCSGameRules_RestartRound,
HookChain:g_hCSGameRules_DeadPlayerWeapons,
HookChain:g_hCBasePlayer_Killed,
HookChain:g_hCBasePlayer_Spawn,
HookChain:g_hCBasePlayer_TraceAttack

new Array:g_aConfigData, Trie:g_tConfigSections, Trie:g_tConfigValues
new g_eCustomForwards[forwardlist_e]
new g_iIgnoreReturn, g_iMaxPlayers, g_iFwdEmitSound, g_iTotalItems
Expand Down Expand Up @@ -83,12 +88,12 @@ public plugin_init()
register_plugin(CSDM_PLUGIN_NAME, CSDM_VERSION_STRING, "wopox1337\Vaqtincha")
register_cvar("csdm_version", CSDM_VERSION_STRING, FCVAR_SPONLY|FCVAR_UNLOGGED)

RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound", .post = false)
RegisterHookChain(RG_CSGameRules_DeadPlayerWeapons, "CSGameRules_DeadPlayerWeapons", .post = false)
g_hCSGameRules_RestartRound = RegisterHookChain(RG_CSGameRules_RestartRound, "CSGameRules_RestartRound", .post = false)
g_hCSGameRules_DeadPlayerWeapons = RegisterHookChain(RG_CSGameRules_DeadPlayerWeapons, "CSGameRules_DeadPlayerWeapons", .post = false)

RegisterHookChain(RG_CBasePlayer_Killed, "CSGameRules_PlayerKilled", .post = false)
RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn", .post = true)
DisableHookChain(g_hTraceAttack = RegisterHookChain(RG_CBasePlayer_TraceAttack, "CBasePlayer_TraceAttack", .post = false))
g_hCBasePlayer_Killed = RegisterHookChain(RG_CBasePlayer_Killed, "CSGameRules_PlayerKilled", .post = false)
g_hCBasePlayer_Spawn = RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn", .post = true)
DisableHookChain(g_hCBasePlayer_TraceAttack = RegisterHookChain(RG_CBasePlayer_TraceAttack, "CBasePlayer_TraceAttack", .post = false))

set_msg_block(get_user_msgid("HudTextArgs"), BLOCK_SET)
set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET)
Expand All @@ -97,6 +102,39 @@ public plugin_init()
ExecuteForward(g_eCustomForwards[iFwdInitialized], g_iIgnoreReturn, CSDM_VERSION_STRING)
}

public plugin_pause()
{
DisableHookChain(g_hCSGameRules_RestartRound)
DisableHookChain(g_hCSGameRules_DeadPlayerWeapons)
DisableHookChain(g_hCBasePlayer_Killed)
DisableHookChain(g_hCBasePlayer_Spawn)
DisableHookChain(g_hCBasePlayer_TraceAttack)

if(g_iFwdEmitSound)
{
unregister_forward(FM_EmitSound, g_iFwdEmitSound, .post = false)
g_iFwdEmitSound = 0
}

set_msg_block(get_user_msgid("HudTextArgs"), BLOCK_NOT)
set_msg_block(get_user_msgid("ClCorpse"), BLOCK_NOT)
}

public plugin_unpause()
{
EnableHookChain(g_hCSGameRules_RestartRound)
EnableHookChain(g_hCSGameRules_DeadPlayerWeapons)
EnableHookChain(g_hCBasePlayer_Killed)
EnableHookChain(g_hCBasePlayer_Spawn)
EnableHookChain(g_hCBasePlayer_TraceAttack)

if(g_bBlockGunpickupSound)
g_iFwdEmitSound = register_forward(FM_EmitSound, "EmitSound", ._post = false)

set_msg_block(get_user_msgid("HudTextArgs"), BLOCK_SET)
set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET)
}

new iEquipManId, iEquipManGFuncId, iEquipManSFuncId

public plugin_cfg()
Expand Down Expand Up @@ -466,9 +504,9 @@ PluginCallFunc(const eArrayData[config_s], const szLineData[])
CheckForwards()
{
if(g_iGamemode != NORMAL_HIT)
EnableHookChain(g_hTraceAttack)
EnableHookChain(g_hCBasePlayer_TraceAttack)
else
DisableHookChain(g_hTraceAttack)
DisableHookChain(g_hCBasePlayer_TraceAttack)

if(g_bBlockGunpickupSound && !g_iFwdEmitSound)
{
Expand Down
90 changes: 83 additions & 7 deletions amxmodx/scripting/csdm_map_cleaner.sma
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ new const g_szMapEntityList[][] =
"info_hostage_rescue",
"func_vip_safetyzone",
"info_vip_start",
"hostage_entity",
"monster_scientist",
"func_escapezone",
"func_buyzone",
"armoury_entity",
"game_player_equip",
"player_weaponstrip"
"func_buyzone"
}

new Trie:g_tMapEntitys, g_iFwdEntitySpawn, g_iMaxPlayers, g_iFwdSetModel
new g_bitRemoveObjects, bool:g_bRemoveWeapons, bool:g_bExcludeBomb
new HamHook:g_hWeaponBoxSpawn, HamHook:g_hShieldSpawn
new HamHook:g_hWeaponBoxSpawn,
HamHook:g_hShieldSpawn,
HamHook:g_hCGamePlayerEquip_Use,
HamHook:g_hCStripWeapons_Use
new HookChain: g_hCSGameRules_CleanUpMap


public plugin_precache()
{
Expand All @@ -55,7 +56,7 @@ public plugin_precache()
TrieSetCell(g_tMapEntitys, g_szMapEntityList[i], i)
}

g_iFwdEntitySpawn = register_forward(FM_Spawn, "Entity_Spawn")
//g_iFwdEntitySpawn = register_forward(FM_Spawn, "Entity_Spawn")

if(g_bitRemoveObjects & func_buyzone) {
CreateBuyZone()
Expand Down Expand Up @@ -86,8 +87,13 @@ public plugin_init()

DisableHamForward(g_hWeaponBoxSpawn = RegisterHam(Ham_Spawn, "weaponbox", "CWeaponBox_Spawn", .Post = true))
DisableHamForward(g_hShieldSpawn = RegisterHam(Ham_Spawn, "weapon_shield", "CWShield_Spawn", .Post = true))
DisableHamForward(g_hCGamePlayerEquip_Use = RegisterHam(Ham_Use, "game_player_equip", "CGamePlayerEquip_Use_Pre", .Post = false))
DisableHamForward(g_hCStripWeapons_Use = RegisterHam(Ham_Use, "player_weaponstrip", "CStripWeapons_Use_Pre", .Post = false))
DisableHookChain(g_hCSGameRules_CleanUpMap = RegisterHookChain(RG_CSGameRules_CleanUpMap, "CSGameRules_CleanUpMap", .post = true))

g_iMaxPlayers = get_maxplayers()

MapEntities_Toggle()
}

public plugin_cfg()
Expand Down Expand Up @@ -132,6 +138,76 @@ public Entity_SetModel(const pEntity, const szModel[]) <SetModel_Disabled>
return FMRES_IGNORED
}

public plugin_pause()
{
MapEntities_Toggle(true)
}

public plugin_unpause()
{
MapEntities_Toggle(false)
}

MapEntities_Toggle(bEnable = false)
{
for(new i; i < sizeof g_szMapEntityList; i++)
{
new entity = NULLENT;

while(( entity = rg_find_ent_by_class(entity, g_szMapEntityList[i], true) ))
set_entvar(entity, var_solid, bEnable ? SOLID_TRIGGER : SOLID_NOT)
}

if(bEnable)
{
DisableHamForward(g_hCGamePlayerEquip_Use)
DisableHamForward(g_hCStripWeapons_Use)
DisableHamForward(g_hWeaponBoxSpawn)
DisableHamForward(g_hShieldSpawn)
DisableHookChain(g_hCSGameRules_CleanUpMap)
}
else
{
EnableHamForward(g_hCGamePlayerEquip_Use)
EnableHamForward(g_hCStripWeapons_Use)
EnableHamForward(g_hWeaponBoxSpawn)
EnableHamForward(g_hShieldSpawn)
EnableHookChain(g_hCSGameRules_CleanUpMap)
}

set_cvar_num("mp_weapons_allow_map_placed", bEnable)
set_cvar_num("mp_give_player_c4", bEnable)
}

public CSGameRules_CleanUpMap()
{
RemoveHostageEntities()
}

RemoveHostageEntities()
{
new entity = NULLENT;

while((entity = rg_find_ent_by_class(entity, "hostage_entity")))
{
set_entvar(entity, var_health, 0.0);
set_entvar(entity, var_movetype, MOVETYPE_TOSS);
set_entvar(entity, var_deadflag, DEAD_DEAD);
set_entvar(entity, var_effects, EF_NODRAW);
set_entvar(entity, var_solid, SOLID_NOT);
}
}

public CGamePlayerEquip_Use_Pre()
{
return HAM_SUPERCEDE
}

public CStripWeapons_Use_Pre()
{
return HAM_SUPERCEDE
}

public Entity_Spawn(const pEntity)
{
if(is_nullent(pEntity))
Expand Down