/*
* Admin Entity Editor (olds.ro) - admins select map entities by aim, move,
* remove (hide) or copy them, undo the last 20 changes, and save the result
* to configs/entedit/<mapname>.ini so it is applied again at every map load.
*
* Copyright (C) 2026 daemon (olds.ro), written by daemon's plugin agent
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details. You should have received a copy of the GNU General Public
* License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <reapi>
#define PLUGIN "Admin Entity Editor"
#define VERSION "1.0.0"
#define AUTHOR "daemon (olds.ro)"
#define ACCESS ADMIN_RCON
#define MAX_ENTS 4096
#define UNDO_SIZE 20
#define TASK_OUTLINE 10110
#define CREATED_CLASS "olds_ent_prop"
#define STATE_MOVED (1 << 0)
#define STATE_HIDDEN (1 << 1)
#define STATE_CREATED (1 << 2)
#define STATE_KNOWN (1 << 3) // g_orig holds the map's original origin
enum
{
ACT_MOVE,
ACT_HIDE,
ACT_CREATE
}
new const OUTLINE_SPRITE[] = "sprites/laserbeam.spr"
new g_state[MAX_ENTS]
new Float:g_orig[MAX_ENTS][3]
new g_hideSolid[MAX_ENTS]
new g_hideEffects[MAX_ENTS]
new g_undoEnt[UNDO_SIZE]
new g_undoAct[UNDO_SIZE]
new g_undoState[UNDO_SIZE]
new Float:g_undoOrigin[UNDO_SIZE][3]
new g_undoCount // entries in use; the newest is g_undoCount - 1
new g_selected[MAX_PLAYERS + 1]
new bool:g_negative[MAX_PLAYERS + 1] // menu moves go in the minus direction
new Trie:g_models // studio/sprite models this plugin precached for saved copies
new g_sprite
new g_maxEnts
new g_cvarSave, g_cvarStep
new g_applied[3] // moves, removals, creations applied from the file
public plugin_precache()
{
g_models = TrieCreate()
g_sprite = precache_model(OUTLINE_SPRITE)
precache_created_models()
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_cvarSave = create_cvar("olds_ent_save", "1", FCVAR_NONE,
"1 = every change is written to configs/entedit/<map>.ini at once, 0 = only with Save", true, 0.0, true, 1.0)
g_cvarStep = create_cvar("olds_ent_step", "8", FCVAR_NONE, "Units per move in the menu", true, 1.0, true, 512.0)
AutoExecConfig(true, "olds_entedit")
register_concmd("amx_ent", "cmd_ent", ACCESS,
"- menu, or: select [#index | classname] | move <dx> <dy> <dz> | remove | create | undo | save | info")
RegisterHookChain(RG_CSGameRules_RestartRound, "on_restart_round_post", true)
set_task(0.5, "task_outline", TASK_OUTLINE, _, _, "b")
g_maxEnts = min(global_get(glb_maxEntities), MAX_ENTS)
}
public plugin_cfg()
{
apply_file()
}
public plugin_end()
{
TrieDestroy(g_models)
}
public client_disconnected(id)
{
g_selected[id] = 0
}
/* ---------- helpers ---------- */
bool:remember(ent)
{
if (ent <= MaxClients || ent >= g_maxEnts || !pev_valid(ent))
return false
if (!(g_state[ent] & STATE_KNOWN))
{
pev(ent, pev_origin, g_orig[ent])
g_state[ent] |= STATE_KNOWN
}
return true
}
// A saved model is used only when it is surely precached: a brush model some map
// entity still uses, or a file this plugin precached. (An unprecached model stops the server.)
bool:model_usable(const model[])
{
if (model[0] == '*')
return engfunc(EngFunc_FindEntityByString, -1, "model", model) > 0
return TrieKeyExists(g_models, model)
}
/* ---------- file ---------- */
file_path(path[], len)
{
new map[64]
get_configsdir(path, len)
get_mapname(map, charsmax(map))
format(path, len, "%s/entedit/%s.ini", path, map)
}
precache_created_models()
{
new path[192]
file_path(path, charsmax(path))
new file = fopen(path, "rt")
if (!file)
return
new line[256], word[16], model[96]
while (!feof(file) && fgets(file, line, charsmax(line)))
{
trim(line)
if (parse(line, word, charsmax(word), model, charsmax(model)) == 2 && equal(word, "create")
&& model[0] && model[0] != '*' && contain(model, "..") < 0 && file_exists(model))
{
precache_model(model)
TrieSetCell(g_models, model, 1)
}
}
fclose(file)
}
apply_file()
{
new path[192]
file_path(path, charsmax(path))
new file = fopen(path, "rt")
if (!file)
return
new line[256], word[16], key[96], num[6][16], lineNo
while (!feof(file) && fgets(file, line, charsmax(line)))
{
lineNo++
trim(line)
if (!line[0] || line[0] == ';')
continue
new parts = parse(line, word, charsmax(word), key, charsmax(key), num[0], charsmax(num[]), num[1], charsmax(num[]),
num[2], charsmax(num[]), num[3], charsmax(num[]), num[4], charsmax(num[]), num[5], charsmax(num[]))
new Float:v[6]
for (new i = 0; i < 6 && i < parts - 2; i++)
v[i] = str_to_float(num[i])
if (equal(word, "move") && parts == 5)
{
new ent = find_by_key(key)
if (ent && remember(ent))
{
v[3] = 0.0
set_origin(ent, v)
g_state[ent] |= STATE_MOVED
g_applied[0]++
continue
}
}
else if (equal(word, "remove") && parts == 2)
{
new ent = find_by_key(key)
if (ent && remember(ent))
{
hide(ent)
g_applied[1]++
continue
}
}
else if (equal(word, "create") && parts == 8 && model_usable(key))
{
new Float:origin[3], Float:angles[3]
for (new i = 0; i < 3; i++)
{
origin[i] = v[i]
angles[i] = v[i + 3]
}
if (create_prop(key, origin, angles))
{
g_applied[2]++
continue
}
}
log_amx("[EntEdit] %s line %d not applied (unknown line, or no such entity on this map)", path, lineNo)
}
fclose(file)
server_print("[EntEdit] Applied from %s: %d move(s), %d removal(s), %d creation(s).", path, g_applied[0], g_applied[1], g_applied[2])
}
// Brush entities are found by their model (*N); point entities by class and original origin.
make_key(ent, key[], len)
{
new model[32], classname[32]
pev(ent, pev_model, model, charsmax(model))
if (model[0] == '*')
{
copy(key, len, model)
return
}
pev(ent, pev_classname, classname, charsmax(classname))
formatex(key, len, "%s@%.0f,%.0f,%.0f", classname, g_orig[ent][0], g_orig[ent][1], g_orig[ent][2])
}
find_by_key(const key[])
{
if (key[0] == '*')
return max(engfunc(EngFunc_FindEntityByString, -1, "model", key), 0)
new at = contain(key, "@")
if (at <= 0)
return 0
new classname[32], coords[64], part[3][16], Float:want[3], Float:origin[3]
copy(classname, min(at, charsmax(classname)), key)
copy(coords, charsmax(coords), key[at + 1])
replace_all(coords, charsmax(coords), ",", " ")
if (parse(coords, part[0], charsmax(part[]), part[1], charsmax(part[]), part[2], charsmax(part[])) != 3)
return 0
for (new i = 0; i < 3; i++)
want[i] = str_to_float(part[i])
new ent = -1
while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", classname)) > 0)
{
if (ent < g_maxEnts && g_state[ent] & STATE_KNOWN)
continue // already matched by another line
pev(ent, pev_origin, origin)
if (floatabs(origin[0] - want[0]) <= 1.0 && floatabs(origin[1] - want[1]) <= 1.0 && floatabs(origin[2] - want[2]) <= 1.0)
return ent
}
return 0
}
bool:save_file()
{
new path[192]
get_configsdir(path, charsmax(path))
add(path, charsmax(path), "/entedit")
if (!dir_exists(path) && mkdir(path) != 0)
return false
file_path(path, charsmax(path))
new file = fopen(path, "wt")
if (!file)
return false
fprintf(file, "; Admin Entity Editor changes for this map (written by amx_ent)^n")
new key[96], model[96], Float:origin[3], Float:angles[3], lines
for (new ent = MaxClients + 1; ent < g_maxEnts; ent++)
{
if (!g_state[ent] || !pev_valid(ent))
continue
pev(ent, pev_origin, origin)
if (g_state[ent] & STATE_CREATED)
{
if (g_state[ent] & STATE_HIDDEN)
continue
pev(ent, pev_model, model, charsmax(model))
pev(ent, pev_angles, angles)
fprintf(file, "create ^"%s^" %.1f %.1f %.1f %.1f %.1f %.1f^n", model, origin[0], origin[1], origin[2], angles[0], angles[1], angles[2])
lines++
continue
}
make_key(ent, key, charsmax(key))
if (g_state[ent] & STATE_HIDDEN)
{
fprintf(file, "remove ^"%s^"^n", key)
lines++
}
else if (g_state[ent] & STATE_MOVED)
{
fprintf(file, "move ^"%s^" %.1f %.1f %.1f^n", key, origin[0], origin[1], origin[2])
lines++
}
}
fclose(file)
server_print("[EntEdit] %d change(s) saved to %s", lines, path)
return true
}
/* ---------- edits ---------- */
set_origin(ent, const Float:origin[])
{
new Float:at[3]
at[0] = origin[0]
at[1] = origin[1]
at[2] = origin[2]
engfunc(EngFunc_SetOrigin, ent, at)
}
hide(ent)
{
if (g_state[ent] & STATE_HIDDEN)
return
g_hideSolid[ent] = pev(ent, pev_solid)
g_hideEffects[ent] = pev(ent, pev_effects)
set_pev(ent, pev_effects, g_hideEffects[ent] | EF_NODRAW)
set_pev(ent, pev_solid, SOLID_NOT)
g_state[ent] |= STATE_HIDDEN
new Float:origin[3]
pev(ent, pev_origin, origin)
engfunc(EngFunc_SetOrigin, ent, origin) // relink without the old solid
}
unhide(ent)
{
if (!(g_state[ent] & STATE_HIDDEN))
return
set_pev(ent, pev_effects, g_hideEffects[ent])
set_pev(ent, pev_solid, g_hideSolid[ent])
g_state[ent] &= ~STATE_HIDDEN
new Float:origin[3]
pev(ent, pev_origin, origin)
engfunc(EngFunc_SetOrigin, ent, origin)
}
create_prop(const model[], const Float:origin[3], const Float:angles[3])
{
if (!model[0])
return 0
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
if (!pev_valid(ent))
return 0
if (ent >= g_maxEnts)
{
engfunc(EngFunc_RemoveEntity, ent)
return 0
}
set_pev(ent, pev_classname, CREATED_CLASS)
engfunc(EngFunc_SetModel, ent, model)
set_pev(ent, pev_angles, angles)
if (model[0] == '*')
{
set_pev(ent, pev_solid, SOLID_BSP)
set_pev(ent, pev_movetype, MOVETYPE_PUSH)
}
else
{
set_pev(ent, pev_solid, SOLID_BBOX)
set_pev(ent, pev_movetype, MOVETYPE_NONE)
}
engfunc(EngFunc_SetOrigin, ent, origin)
g_state[ent] = STATE_CREATED | STATE_KNOWN
g_orig[ent] = origin
return ent
}
push_undo(ent, action)
{
if (g_undoCount == UNDO_SIZE)
{
for (new i = 1; i < UNDO_SIZE; i++)
{
g_undoEnt[i - 1] = g_undoEnt[i]
g_undoAct[i - 1] = g_undoAct[i]
g_undoState[i - 1] = g_undoState[i]
g_undoOrigin[i - 1] = g_undoOrigin[i]
}
g_undoCount--
}
new slot = g_undoCount++
g_undoEnt[slot] = ent
g_undoAct[slot] = action
g_undoState[slot] = g_state[ent]
pev(ent, pev_origin, g_undoOrigin[slot])
}
changed(id)
{
if (get_pcvar_num(g_cvarSave) && !save_file())
console_print(id, "[EntEdit] Could not write configs/entedit/; the change lasts until the map ends.")
}
bool:selection(id)
{
new ent = g_selected[id]
if (ent > MaxClients && pev_valid(ent) && ent < g_maxEnts)
return true
g_selected[id] = 0
console_print(id, "[EntEdit] Select an entity first (aim at it and use Select).")
return false
}
do_move(id, const Float:delta[3])
{
if (!selection(id))
return
new ent = g_selected[id]
remember(ent)
push_undo(ent, ACT_MOVE)
new Float:origin[3]
pev(ent, pev_origin, origin)
for (new i = 0; i < 3; i++)
origin[i] = floatclamp(origin[i] + delta[i], -16384.0, 16384.0)
engfunc(EngFunc_SetOrigin, ent, origin)
if (!(g_state[ent] & STATE_CREATED))
g_state[ent] |= STATE_MOVED
console_print(id, "[EntEdit] #%d moved to %.1f %.1f %.1f", ent, origin[0], origin[1], origin[2])
changed(id)
}
do_remove(id)
{
if (!selection(id))
return
new ent = g_selected[id]
if (g_state[ent] & STATE_HIDDEN)
{
console_print(id, "[EntEdit] #%d is already removed.", ent)
return
}
remember(ent)
push_undo(ent, ACT_HIDE)
hide(ent)
g_selected[id] = 0
console_print(id, "[EntEdit] #%d removed (amx_ent undo brings it back).", ent)
changed(id)
}
do_create(id)
{
if (!selection(id))
return
new source = g_selected[id], model[96]
pev(source, pev_model, model, charsmax(model))
if (!model[0])
{
console_print(id, "[EntEdit] #%d has no model to copy.", source)
return
}
new Float:origin[3], Float:angles[3]
if (id && is_user_alive(id))
{
aim_end(id, origin)
if (model[0] != '*')
{
new Float:mins[3]
pev(source, pev_mins, mins)
origin[2] -= mins[2] // stand it on the surface
}
}
else
{
pev(source, pev_origin, origin)
origin[0] += 64.0
}
pev(source, pev_angles, angles)
new ent = create_prop(model, origin, angles)
if (!ent)
{
console_print(id, "[EntEdit] Could not create a copy of #%d.", source)
return
}
push_undo(ent, ACT_CREATE)
g_selected[id] = ent
console_print(id, "[EntEdit] Created #%d (%s) at %.1f %.1f %.1f; it is now selected.", ent, model, origin[0], origin[1], origin[2])
changed(id)
}
do_undo(id)
{
while (g_undoCount > 0)
{
new slot = --g_undoCount
new ent = g_undoEnt[slot]
if (!pev_valid(ent))
continue
switch (g_undoAct[slot])
{
case ACT_MOVE:
{
engfunc(EngFunc_SetOrigin, ent, g_undoOrigin[slot])
g_state[ent] = (g_state[ent] & ~STATE_MOVED) | (g_undoState[slot] & STATE_MOVED)
console_print(id, "[EntEdit] Undo: #%d back at %.1f %.1f %.1f", ent, g_undoOrigin[slot][0], g_undoOrigin[slot][1], g_undoOrigin[slot][2])
}
case ACT_HIDE:
{
unhide(ent)
console_print(id, "[EntEdit] Undo: #%d is back.", ent)
}
case ACT_CREATE:
{
hide(ent) // a hidden copy is never saved
for (new p = 0; p <= MaxClients; p++)
{
if (g_selected[p] == ent)
g_selected[p] = 0
}
console_print(id, "[EntEdit] Undo: copy #%d removed.", ent)
}
}
changed(id)
return
}
console_print(id, "[EntEdit] Nothing to undo.")
}
do_select(id, const arg[])
{
new ent
if (arg[0] == '#')
ent = str_to_num(arg[1])
else if (arg[0])
ent = max(engfunc(EngFunc_FindEntityByString, -1, "classname", arg), 0)
else if (id && is_user_alive(id))
ent = aim_entity(id)
else
{
console_print(id, "[EntEdit] From the server console: amx_ent select #index or amx_ent select classname")
return
}
if (ent <= MaxClients || ent >= g_maxEnts || !pev_valid(ent))
{
console_print(id, "[EntEdit] Nothing to select there.")
return
}
g_selected[id] = ent
print_info(id, ent)
}
print_info(id, ent)
{
new classname[32], target[32], model[64], Float:origin[3]
pev(ent, pev_classname, classname, charsmax(classname))
pev(ent, pev_targetname, target, charsmax(target))
pev(ent, pev_model, model, charsmax(model))
pev(ent, pev_origin, origin)
console_print(id, "[EntEdit] Selected #%d %s (targetname ^"%s^", model ^"%s^") at %.1f %.1f %.1f", ent, classname, target, model, origin[0], origin[1], origin[2])
if (id)
client_print(id, print_chat, "[EntEdit] Selected #%d %s %s", ent, classname, model)
}
/* ---------- aim ---------- */
aim_end(id, Float:end[3], &hit = 0)
{
new Float:eyes[3], Float:offset[3], Float:angles[3], Float:dir[3], Float:far[3]
pev(id, pev_origin, eyes)
pev(id, pev_view_ofs, offset)
for (new i = 0; i < 3; i++)
eyes[i] += offset[i]
pev(id, pev_v_angle, angles)
engfunc(EngFunc_MakeVectors, angles)
global_get(glb_v_forward, dir)
for (new i = 0; i < 3; i++)
far[i] = eyes[i] + dir[i] * 4096.0
new trace = create_tr2()
engfunc(EngFunc_TraceLine, eyes, far, DONT_IGNORE_MONSTERS, id, trace)
get_tr2(trace, TR_vecEndPos, end)
hit = get_tr2(trace, TR_pHit)
free_tr2(trace)
}
// The entity under the crosshair, or else the nearest entity with a model within 48 units of the aim point.
aim_entity(id)
{
new Float:end[3], hit
aim_end(id, end, hit)
if (hit > MaxClients && pev_valid(hit))
return hit
new best, Float:bestDistance = 48.0, Float:origin[3], model[4]
for (new ent = MaxClients + 1; ent < g_maxEnts; ent++)
{
if (!pev_valid(ent))
continue
pev(ent, pev_model, model, charsmax(model))
if (!model[0] || model[0] == '*')
continue
pev(ent, pev_origin, origin)
new Float:distance = get_distance_f(origin, end)
if (distance < bestDistance)
{
bestDistance = distance
best = ent
}
}
return best
}
/* ---------- command and menu ---------- */
public cmd_ent(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new action[16], arg[32]
read_argv(1, action, charsmax(action))
read_argv(2, arg, charsmax(arg))
if (!action[0])
{
if (id)
show_editor(id)
else
console_print(id, "[EntEdit] Usage: amx_ent select [#index | classname] | move <dx> <dy> <dz> | remove | create | undo | save | info")
return PLUGIN_HANDLED
}
if (equali(action, "select"))
do_select(id, arg)
else if (equali(action, "move"))
{
new Float:delta[3], value[16]
for (new i = 0; i < 3; i++)
{
read_argv(2 + i, value, charsmax(value))
delta[i] = floatclamp(str_to_float(value), -4096.0, 4096.0)
}
do_move(id, delta)
}
else if (equali(action, "remove"))
do_remove(id)
else if (equali(action, "create"))
do_create(id)
else if (equali(action, "undo"))
do_undo(id)
else if (equali(action, "save"))
{
if (!save_file())
console_print(id, "[EntEdit] Could not write configs/entedit/.")
}
else if (equali(action, "info"))
show_status(id)
else
console_print(id, "[EntEdit] Unknown action ^"%s^".", action)
return PLUGIN_HANDLED
}
show_status(id)
{
new moved, hidden, created
for (new ent = MaxClients + 1; ent < g_maxEnts; ent++)
{
if (!g_state[ent] || !pev_valid(ent))
continue
if (g_state[ent] & STATE_CREATED)
{
if (!(g_state[ent] & STATE_HIDDEN))
created++
}
else if (g_state[ent] & STATE_HIDDEN)
hidden++
else if (g_state[ent] & STATE_MOVED)
moved++
}
console_print(id, "[EntEdit] Loaded from file: %d move(s), %d removal(s), %d creation(s). Now: %d moved, %d removed, %d created; undo %d/%d; step %d; save %d",
g_applied[0], g_applied[1], g_applied[2], moved, hidden, created, g_undoCount, UNDO_SIZE, get_pcvar_num(g_cvarStep), get_pcvar_num(g_cvarSave))
if (g_selected[id] && pev_valid(g_selected[id]))
print_info(id, g_selected[id])
}
show_editor(id)
{
new title[96], step = get_pcvar_num(g_cvarStep)
if (g_selected[id] && pev_valid(g_selected[id]))
{
new classname[32]
pev(g_selected[id], pev_classname, classname, charsmax(classname))
formatex(title, charsmax(title), "Entity editor^n\dSelected: #%d %s", g_selected[id], classname)
}
else
copy(title, charsmax(title), "Entity editor^n\dNothing selected")
new menu = menu_create(title, "on_menu")
new label[32]
menu_additem(menu, "Select (aim)", "sel")
formatex(label, charsmax(label), "Move +X / -X (%d)", step)
menu_additem(menu, label, "x")
formatex(label, charsmax(label), "Move +Y / -Y (%d)", step)
menu_additem(menu, label, "y")
formatex(label, charsmax(label), "Move +Z / -Z (%d)", step)
menu_additem(menu, label, "z")
menu_additem(menu, "Remove", "rem")
menu_additem(menu, "Create a copy here", "new")
menu_additem(menu, "Undo", "undo")
menu_additem(menu, "Save", "save")
menu_additem(menu, "Flip move direction", "flip")
menu_setprop(menu, MPROP_PERPAGE, 0)
menu_setprop(menu, MPROP_EXIT, MEXIT_FORCE)
menu_display(id, menu)
}
public on_menu(id, menu, item)
{
if (item < 0)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new info[8], access, callback
menu_item_getinfo(menu, item, access, info, charsmax(info), _, _, callback)
menu_destroy(menu)
if (!(get_user_flags(id) & ACCESS))
return PLUGIN_HANDLED
new Float:delta[3], Float:step = get_pcvar_float(g_cvarStep)
if (g_negative[id])
step = -step
if (equal(info, "sel"))
do_select(id, "")
else if (equal(info, "x") || equal(info, "y") || equal(info, "z"))
{
delta[info[0] - 'x'] = step
do_move(id, delta)
}
else if (equal(info, "rem"))
do_remove(id)
else if (equal(info, "new"))
do_create(id)
else if (equal(info, "undo"))
do_undo(id)
else if (equal(info, "save"))
{
if (save_file())
client_print(id, print_chat, "[EntEdit] Saved.")
}
else if (equal(info, "flip"))
{
g_negative[id] = !g_negative[id]
if (g_negative[id])
client_print(id, print_chat, "[EntEdit] Moves now go in the minus direction.")
else
client_print(id, print_chat, "[EntEdit] Moves now go in the plus direction.")
}
show_editor(id)
return PLUGIN_HANDLED
}
/* ---------- round restart and outline ---------- */
public on_restart_round_post()
{
// Some entities put themselves back on a new round: apply the edits again.
for (new ent = MaxClients + 1; ent < g_maxEnts; ent++)
{
if (!g_state[ent] || !pev_valid(ent))
continue
if (g_state[ent] & STATE_HIDDEN)
{
set_pev(ent, pev_effects, pev(ent, pev_effects) | EF_NODRAW)
if (pev(ent, pev_solid) != SOLID_NOT)
{
set_pev(ent, pev_solid, SOLID_NOT)
new Float:origin[3]
pev(ent, pev_origin, origin)
engfunc(EngFunc_SetOrigin, ent, origin)
}
}
}
}
public task_outline()
{
for (new id = 1; id <= MaxClients; id++)
{
new ent = g_selected[id]
if (!ent || !is_user_connected(id) || is_user_bot(id))
continue
if (!pev_valid(ent))
{
g_selected[id] = 0
continue
}
new Float:lo[3], Float:hi[3]
pev(ent, pev_absmin, lo)
pev(ent, pev_absmax, hi)
if (hi[0] - lo[0] < 2.0)
{
// a point entity without size: draw a 16-unit box around it
new Float:origin[3]
pev(ent, pev_origin, origin)
for (new i = 0; i < 3; i++)
{
lo[i] = origin[i] - 8.0
hi[i] = origin[i] + 8.0
}
}
for (new level = 0; level < 2; level++)
{
new Float:z = level ? hi[2] : lo[2]
edge(id, lo[0], lo[1], z, hi[0], lo[1], z)
edge(id, hi[0], lo[1], z, hi[0], hi[1], z)
edge(id, hi[0], hi[1], z, lo[0], hi[1], z)
edge(id, lo[0], hi[1], z, lo[0], lo[1], z)
}
edge(id, lo[0], lo[1], lo[2], lo[0], lo[1], hi[2])
edge(id, hi[0], lo[1], lo[2], hi[0], lo[1], hi[2])
edge(id, hi[0], hi[1], lo[2], hi[0], hi[1], hi[2])
edge(id, lo[0], hi[1], lo[2], lo[0], hi[1], hi[2])
}
}
edge(id, Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
{
message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
write_byte(TE_BEAMPOINTS)
write_coord_f(x1)
write_coord_f(y1)
write_coord_f(z1)
write_coord_f(x2)
write_coord_f(y2)
write_coord_f(z2)
write_short(g_sprite)
write_byte(0)
write_byte(0)
write_byte(6) // life, tenths of a second (redrawn every 0.5 s)
write_byte(4) // width
write_byte(0)
write_byte(0)
write_byte(255)
write_byte(80)
write_byte(200)
write_byte(0)
message_end()
}