@Chp'
PHP Code:
#define CVAR_TPFIX "kz_tpfix"
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#define PLUGIN "Semiclip Fix"
#define VERSION "1.0"
#define AUTHOR "skyjur"
#define tmins teleport_mins[i]
#define tmaxs teleport_maxs[i]
new Float:teleport_mins[300][3]
new Float:teleport_maxs[300][3]
new teleport_ent[300]
new teleport_num
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar(CVAR_TPFIX, "1")
if(plugin_close() > 0) return 0
load_teleports()
if(teleport_num > 0) register_forward(FM_PlayerPreThink, "plrPreThink")
return 0
}
stock plugin_close()
{
new file[128]
new mapname[32]
new const tpfix = get_cvar_num(CVAR_TPFIX)
if(tpfix == 0) return 1
get_configsdir(file, 127)
get_mapname(mapname, 31)
format(file, 127, "%s/tpfix.txt", file)
if(!file_exists(file)) return 0
new ln = 0
new line[32]
new len
while ((ln = read_file(file, ln, line, 31, len)) > 0) {
if(equali(mapname, line))
{
switch(tpfix)
{
case 1: return 1
case 2: return 0
}
}
}
switch(tpfix)
{
case 1: return 0
case 2: return 1
}
return 0
}
stock load_teleports()
{
new ent = get_maxplayers()
while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "trigger_teleport")) > 0){
pev(ent, pev_absmin, teleport_mins[teleport_num])
pev(ent, pev_absmax, teleport_maxs[teleport_num])
teleport_ent[teleport_num] = ent
if(teleport_maxs[teleport_num][2] - teleport_mins[teleport_num][2] <= 128.0) teleport_num++
}
}
public plrPreThink(id)
{
if(pev(id, pev_solid) != SOLID_NOT || pev(id, pev_movetype) == MOVETYPE_NOCLIP) return
static bool:onground[33]
static Float:velocity[3]
static flags
flags = pev(id, pev_flags)
if(flags & FL_ONGROUND && !onground[id])
{
plr_check(id)
onground[id] = true
return
}
if(!(flags & FL_ONGROUND) && onground[id])
{
plr_check(id)
onground[id] = false
return
}
pev(id, pev_velocity, velocity)
if(velocity[2] < 160.0)
{
plr_check(id)
return
}
}
stock plr_check(id)
{
static Float:mins[3], Float:maxs[3]
static bool:collides
pev(id, pev_absmin, mins)
pev(id, pev_absmax, maxs)
for(new i=0; i<teleport_num; i++)
{
collides = true
if(tmins[0] > maxs[0] || tmaxs[0] < mins[0]) collides = false
else if(tmins[1] > maxs[1] || tmaxs[1] < mins[1]) collides = false
else if(tmins[2] > maxs[2] || tmaxs[2] < mins[2]) collides = false
if(collides) {
dllfunc(DLLFunc_Touch, id, teleport_ent[i])
dllfunc(DLLFunc_Touch, teleport_ent[i], id)
return 0
}
}
return 0
}
__________________