Is this right?
Condition is just an optional parameter, which i want to send only in case of a special event, so i can use exceptions for special events in other plugins with the forwards created
PHP Code:
/ Custom Forwards
enum _:TOTAL_FORWARDS
{
FW_USER_INFECT_PRE = 0,
FW_USER_INFECT,
FW_USER_INFECT_POST
}
new g_ForwardResult
new g_Forwards[TOTAL_FORWARDS]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_Forwards[FW_USER_INFECT_PRE] = CreateMultiForward("zp_fw_core_infect_pre", ET_CONTINUE, FP_CELL, FP_CELL, FP_CELL)
g_Forwards[FW_USER_INFECT] = CreateMultiForward("zp_fw_core_infect", ET_IGNORE, FP_CELL, FP_CELL)
g_Forwards[FW_USER_INFECT_POST] = CreateMultiForward("zp_fw_core_infect_post", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL)
}
InfectPlayer(id, attacker = 0, condition = 0)
{
ExecuteForward(g_Forwards[FW_USER_INFECT_PRE], g_ForwardResult, id, attacker, condition)
// One or more plugins blocked infection
if (g_ForwardResult >= PLUGIN_HANDLED)
return;
ExecuteForward(g_Forwards[FW_USER_INFECT], g_ForwardResult, id, attacker, condition)
flag_set(g_IsZombie, id)
if (GetZombieCount() == 1)
flag_set(g_IsFirstZombie, id)
else
flag_unset(g_IsFirstZombie, id)
ExecuteForward(g_Forwards[FW_USER_INFECT_POST], g_ForwardResult, id, attacker, condition)
CheckLastZombieHuman()
}
public native_core_infect(plugin_id, num_params, num_condition)
{
new id = get_param(1)
if (!is_user_alive(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return false;
}
if (flag_get(g_IsZombie, id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Player already infected (%d)", id)
return false;
}
new attacker = get_param(2)
if (attacker && !is_user_connected(attacker))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", attacker)
return false;
}
new condition = get_param(3)
InfectPlayer(id, attacker, condition)
return true;
}
PHP Code:
// In case of a special situation
zp_core_infect(id, attacker, 3)
PHP Code:
public fw_zp_core_infect_post(victim, attacker, condition)
{
if(condition = 3)
{
code here
}
}