text
stringlengths
0
692
pev(id, pev_view_ofs, point);
xs_vec_add(origin, point, origin);
fn_log_cli(id, "FindEntityInSphere", DIVISOR);
ent = -1;
while((ent = engfunc(EngFunc_FindEntityInSphere, ent, origin, radius)))
{
// We don't want worldspawn entity
if(ent == 0)
continue;
// We don't want our own entity
if(ent == id)
continue;
if(!pev_valid(ent))
continue;
pev(ent, pev_origin, point);
pev(ent, pev_classname, class, charsmax(class));
if(equal(class, "func_buyzone") || equal(class, "player") || equal(class, "func_bomb_target")
|| equal(class, "func_breakable") || equal(class, "func_door"))
{
fn_create_beam(origin, point, 60, 0, 255, 0); // Create green line from ID to ENT for 60 seconds
formatex(text, charsmax(text), "Found entity in sphere (ent:%i class:%s)", ent, class);
fn_log_cli(id, "FindEntityInSphere", text);
}
}
return PLUGIN_HANDLED;
}
// FindClientInPVS
// This tutorial makes lines from a player to every entity found in PVS
public tut_FindClientInPVS(id)
{
static Float:origin[3];
static Float:point[3];
static class[STR];
static text[LOG];
static ent, chain;
pev(id, pev_origin, origin);
pev(id, pev_view_ofs, point);
xs_vec_add(origin, point, origin);
fn_log_cli(id, "FindClientInPVS", DIVISOR);
ent = engfunc(EngFunc_EntitiesInPVS, id);
while(ent)
{
chain = pev(ent, pev_chain);
pev(ent, pev_origin, point);
pev(ent, pev_classname, class, charsmax(class));
if(!equal(class, ""))
{
fn_create_beam(origin, point, 60, 0, 0, 255); // Create blue line from ID to ENT for 60 seconds
formatex(text, charsmax(text), "Found entity in PVS (ent:%i class:%s)", ent, class);
fn_log_con("FindClientInPVS", text);
}
if(!chain)
break;
ent = chain;
}
return PLUGIN_HANDLED;
}
// TraceLine
// This tutorial makes 2 lines, one of them stoping on entities.
public tut_TraceLine(id)
{
static Float:origin[3];
static Float:aim[3];
static Float:point[3];
static text[LOG];
static const tr = 0;
pev(id, pev_origin, origin);
pev(id, pev_view_ofs, aim);
xs_vec_add(origin, aim, origin);
fm_get_aim_origin(id, aim);
// Multiply vector to make it larger
xs_vec_sub(aim, origin, aim);
xs_vec_mul_scalar(aim, 10.0, aim);
xs_vec_add(origin, aim, aim);
engfunc(EngFunc_TraceLine, origin, aim, 0, id, tr);
fn_log_cli(id, "TraceLine", DIVISOR);
fn_create_beam(origin, aim, 60, 255, 0, 0); // Create red line from ID to aim point for 60 seconds
formatex(text, charsmax(text), "Created red line to aim point");
fn_log_cli(id, "TraceLine", text);
get_tr2(tr, TR_vecEndPos, point);
fn_create_beam(origin, point, 60, 0, 255, 0); // Create green line from ID to hit point for 60 seconds
formatex(text, charsmax(text), "Created green line to hit point");
fn_log_cli(id, "TraceLine", text);