text
stringlengths
0
692
}
}
stock fn_create_beam(Float:origin[3], Float:end[3], t, r, g, b)
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_BEAMPOINTS);
engfunc(EngFunc_WriteCoord, origin[0]);
engfunc(EngFunc_WriteCoord, origin[1]);
engfunc(EngFunc_WriteCoord, origin[2]);
engfunc(EngFunc_WriteCoord, end[0]);
engfunc(EngFunc_WriteCoord, end[1]);
engfunc(EngFunc_WriteCoord, end[2]);
write_short(g_beamSprite);
write_byte(1);
write_byte(5);
write_byte(t);
write_byte(20);
write_byte(0);
write_byte(r);
write_byte(g);
write_byte(b);
write_byte(200);
write_byte(200);
message_end();
}
//------------------------------------------------------------------------
//Console functions
//------------------------------------------------------------------------
public con_showents()
{
new class[STR], str[LOG];
new origin[3];
new ent, owner;
for(ent=1; ent < g_maxEntities; ++ent)
{
if(!pev_valid(ent))
continue;
pev(ent, pev_origin, origin);
pev(ent, pev_classname, class, charsmax(class));
owner = pev(ent, pev_owner);
formatex(str, charsmax(str), "%i %s (owner:%i) (%f,%f,%f)", ent, class, owner, origin[0], origin[1], origin[2]);
fn_log_con("Entity", str);
}
return PLUGIN_HANDLED;
}
//------------------------------------------------------------------------
//Client functions
//------------------------------------------------------------------------
// FindEntityByString
// This tutorial makes lines from the player to every player in the map
public tut_FindEntityByString(id)
{
static Float:origin[3];
static Float:point[3];
static text[LOG];
static ent;
static const class[] = "player"; // We are going to find "player" entitities
pev(id, pev_origin, origin);
pev(id, pev_view_ofs, point);
xs_vec_add(origin, point, origin);
fn_log_cli(id, "FindEntityInSphere", DIVISOR);
ent = -1;
while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", class)))
{
// We don't want our own entity
if(ent == id)
continue;
if(!pev_valid(ent))
continue;
pev(ent, pev_origin, point);
fn_create_beam(origin, point, 60, 255, 0, 0); // Create red line from ID to ENT for 60 seconds
formatex(text, charsmax(text), "Found entity 'player' (ent:%i)", ent);
fn_log_cli(id, "FindEntityInSphere", text);
}
return PLUGIN_HANDLED;
}
// FindEntityInSphere
// This tutorial makes lines from a player to every entity found in sphere radius
public tut_FindEntityInSphere(id)
{
static Float:origin[3];
static Float:point[3];
static text[LOG];
static class[STR];
static ent;
static const radius = 2000; // We are going to find entities using this sphere radius
pev(id, pev_origin, origin);