/*
* This will hook the trigger_hurt when it's activated.
* What i know is that trigger_hurt can be activated via button or trigger_multiple
* This method is good for maps that conatin trains..etc
* Also we will hook which using trigger_multiple only
*
* If user is touching the train and this player touched trigger_multiple then the trigger_hurt will be called.
* In fact the trigger_hurt will be called once trigger_multiple is touched by player but we will tie it with train also. Away to avoid hardcode every map.
*/
#include "zombie_escape.inc"
#define MIN_DAMAGE 9000
// Add all moving entities
new const g_szEntities[][] =
{
"func_tracktrain",
"func_vehicle"
}
new Float:g_flLastTouched[33], bool:g_bCalled, g_iTriggerHurtForward, g_szMapName[32]
public plugin_init()
{
register_plugin("Hook Trigger Hurt", "1.0", "Raheem")
for(new iEnt = 0; iEnt <= charsmax(g_szEntities); iEnt++)
{
RegisterHam(Ham_Touch, g_szEntities[iEnt], "Fw_TouchMoving_Pre", 0)
}
RegisterHam(Ham_Touch, "trigger_multiple", "Fw_TouchTriggerMultiple_Pre", 0)
// Here we register touching any trigger_hurt
RegisterHam(Ham_Touch, "trigger_hurt", "Fw_TouchTrigger_Pre", 0)
g_iTriggerHurtForward = CreateMultiForward("ze_trigger_hurt", ET_IGNORE)
// Get map name
get_mapname(g_szMapName, charsmax(g_szMapName))
}
public ze_game_started()
{
g_bCalled = false
}
public Fw_TouchTriggerMultiple_Pre(iEnt, id)
{
// ze_military_v1 only use normal trigger hurt calling
if (equal(g_szMapName, "ze_military_v1"))
return
// Here player touching trigger_multiple
// Let's check first if he is touching also the train or not
if (TouchingMovingVehicle(id))
{
if (equal(g_szMapName, "ze_metropolitano_lg"))
{
new szModel[32]
get_entvar(iEnt, EntVars:var_model, szModel, charsmax(szModel))
if (equal(szModel, "*44"))
{
if (!g_bCalled)
{
ExecuteForward(g_iTriggerHurtForward)
g_bCalled = true
}
}
return
}
if (equal(g_szMapName, "ze_black_train_v1"))
{
new szModel[32]
pev(iEnt, pev_model, szModel, charsmax(szModel))
//get_entvar(iEnt, EntVars:var_model, szModel, charsmax(szModel))
if (equal(szModel, "*34"))
{
if (!g_bCalled)
{
ExecuteForward(g_iTriggerHurtForward)
g_bCalled = true
}
}
return
}
// Player in vehicle and he touched trigger_multiple
if (!g_bCalled)
{
// Here we execute our forward
ExecuteForward(g_iTriggerHurtForward)
g_bCalled = true
}
}
}
public Fw_TouchTrigger_Pre(iEnt, id)
{
if (!is_user_alive(id) || !pev_valid(iEnt))
return HAM_IGNORED
if (equal(g_szMapName, "ze_black_train_v1"))
return HAM_IGNORED
if (pev(iEnt, pev_dmg) > MIN_DAMAGE)
{
if (!g_bCalled)
{
ExecuteForward(g_iTriggerHurtForward)
g_bCalled = true
}
}
return HAM_IGNORED
}
public Fw_TouchMoving_Pre(iEnt, id)
{
if (!is_user_connected(id))
return HAM_IGNORED;
// ze_jurassicpark_v2 map
if (equal(g_szMapName, "ze_jurassicpark_v2"))
{
new szModel[32]
get_entvar(iEnt, EntVars:var_model, szModel, charsmax(szModel))
if (equal(szModel, "*51"))
{
return HAM_IGNORED;
}
}
// ze_egyptopark map
if (equal(g_szMapName, "ze_egyptopark"))
{
new szModel[32]
get_entvar(iEnt, EntVars:var_model, szModel, charsmax(szModel))
if (equal(szModel, "*30"))
{
return HAM_IGNORED;
}
}
g_flLastTouched[id] = get_gametime()
return HAM_IGNORED;
}
stock TouchingMovingVehicle(id)
{
if (!is_user_alive(id))
return false;
if (g_flLastTouched[id] + 0.01 >= get_gametime()) /* For more accurecy lower 0.1 to for example 0.01*/
{
return true;
}
return false;
}