Post by KillerMen on Jun 19, 2016 22:54:44 GMT
Plugin: Call Message [Zombie-Escape]
Admin Cmd (Console)
ON Call: cl_off_callme
OFF Call: cl_on_callme
Admin Cmd (Console)
ON Call: cl_off_callme
OFF Call: cl_on_callme
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#if AMXX_VERSION_NUM < 183
#include <colorchat>
#endif
new RequiredEnt, bool:HasUsedButton, bool:block
public plugin_init()
{
register_plugin("[ZE] Heli Button Info whit Call OFF / ON ", "1.0", "KilLeR MeN =)")
register_clcmd("cl_off_callme", "call_off")
register_clcmd("cl_on_callme", "call_on")
new iEnt1 = -1, iEnt2 = -1, Float:fspeed, Float:origin[3], Float:origin2[3], Float:fdistance, Float:ShortDistance = 99999.9, bool:FoundEnt
while((iEnt1 = engfunc(EngFunc_FindEntityByString, iEnt1 , "classname", "path_track")) != 0)
{
pev(iEnt1, pev_speed, fspeed)
if(2.0 < fspeed < 40.0)
{
pev(iEnt1, pev_origin, origin)
//log_amx("track origin %f %f %f", origin[0], origin[1], origin[2])
while((iEnt2 = engfunc(EngFunc_FindEntityByString, iEnt2 , "classname", "func_button")) != 0)
{
fm_get_brush_entity_origin(iEnt2, origin2)
fdistance = get_distance_f(origin, origin2)
if(fdistance < ShortDistance)
{
RequiredEnt = iEnt2
ShortDistance = fdistance
//log_amx("ent %i distance %f", iEnt2, fdistance)
}
FoundEnt = true
}
break
}
}
if(!FoundEnt)
{
while((iEnt1 = engfunc(EngFunc_FindEntityByString, iEnt1 , "classname", "trigger_multiple")) != 0)
{
fm_get_brush_entity_origin(iEnt1, origin)
//log_amx("trigger origin %f %f %f", origin[0], origin[1], origin[2])
while((iEnt2 = engfunc(EngFunc_FindEntityByString, iEnt2 , "classname", "func_button")) != 0)
{
fm_get_brush_entity_origin(iEnt2, origin2)
fdistance = get_distance_f(origin, origin2)
if(fdistance < ShortDistance)
{
RequiredEnt = iEnt2
ShortDistance = fdistance
//log_amx("ent %i distance %f", iEnt2, fdistance)
}
FoundEnt = true
}
break
}
}
if(FoundEnt)
{
register_logevent("Event_RoundStart", 2, "0=World triggered", "1=Round_Start")
RegisterHam(Ham_Use, "func_button", "fwButtonUsed")
}
else
set_fail_state("[Zombie Escape] Call Button not found.")
}
public Event_RoundStart()
{
HasUsedButton = false
block = false
}
public fwButtonUsed(ent, id, activator, iType, Float:fValue)
{
if(block && ent == RequiredEnt)
{
ColorChat(id, GREEN, "[Zombie Escape] ^1Call Button Is Currently Off ^4!")
return 4;
}
else if(!HasUsedButton && ent == RequiredEnt)
{
new szName[33]; get_user_name(id, szName, charsmax(szName))
ColorChat(0, GREEN, "[Zombie Escape] ^1Player ^4%s ^1Press The Call Button !", szName)
HasUsedButton = true
}
return 1;
}
stock fm_get_brush_entity_origin(index, Float:origin[3])
{
new Float:mins[3], Float:maxs[3];
pev(index, pev_origin, origin);
pev(index, pev_mins, mins);
pev(index, pev_maxs, maxs);
origin[0] += (mins[0] + maxs[0]) * 0.5;
origin[1] += (mins[1] + maxs[1]) * 0.5;
origin[2] += (mins[2] + maxs[2]) * 0.5;
return 1;
}
public call_off(id) block = true, HasUsedButton = true
public call_on(id) block = false, HasUsedButton = false