I'm trying to do simple player trails using TE_SetupBeamFollow but after standing still for too long the trail gets deleted.. I tried using TIMER_REPEAT but that didn't help either. What would be a good way of making this work and not get deleted while standing still?
I have googled and looked through all the plugins that were similar to what I am trying to do with this but I can't really find a set solution for getting the entity not to disappear. All the plugins and sources I have found don't seem to be able to keep the entity from disappearing when standing still. If you have a certain plugin that you think I haven't look through and does offer this functionality feel free to post it please! Otherwise I just want advice on how to properly make the timer repeat/ trail not disappear.
Save the entity reference when you spawn it and periodically (not too often though) resolve it back into an ent index. if it exists continue, if it doesn't - respawn. Or just periodically respawn it (and kill the previous one if exists). That will work too.
Save the entity reference when you spawn it and periodically (not too often though) resolve it back into an ent index. if it exists continue, if it doesn't - respawn. Or just periodically respawn it (and kill the previous one if exists). That will work too.
Problem is, these are temp ents, as in, no actual entities.
Once you call TE_SetupBeamFollow, it's a fire-and-forget - hence why method also returns void.
__________________
Stopped hosting servers as of November 2018, no longer active around here.
Will using this have the same functionality just with creating a ent that doesn't automatically delete?
Also are you guys saying there isn't a way to make it just auto refresh itself? If there is anyways can someone point me in the right direction to find it or provide a source where it is used?
g_hCvar_Trail_Enable = CreateConVar("sm_trail_enable", "1", "Enable or Disable all features of the plugin.", _, true, 0.0, true, 1.0);
g_hCvar_Trail_AdminOnly = CreateConVar("sm_trail_adminonly", "0", "Enable trails only for Admins (VOTE Flag).", _, true, 0.0, true, 1.0);
g_hCvar_Trail_Duration = CreateConVar("sm_trail_duration", "1.0", "Duration of the trail.", _, true, 1.0, true, 100.0);
g_hCvar_Trail_Fade_Duration = CreateConVar("sm_trail_fade_duration", "1", "Duration of the trail.", _, true, 1.0, true, 100.0);
g_hCvar_Trail_Width = CreateConVar("sm_trail_width", "5.0", "Width of the trail.", _, true, 1.0, true, 100.0);
g_hCvar_Trail_End_Width = CreateConVar("sm_trail_end_width", "1.0", "Width of the trail.", _, true, 1.0, true, 100.0);
g_hCvar_Trail_Per_Round = CreateConVar("sm_trail_per_round", "5", "How many times per round a client can use the command.", _, true, 1.0, true, 100.0);
g_Cookie_Trail = RegClientCookie("TrailColor", "TrailColor", CookieAccess_Protected);
RegConsoleCmd("sm_trail", Command_Trail, "Opens a menu for players to choose their trail colors.");
RegConsoleCmd("sm_trails", Command_Trail, "Opens a menu for players to choose their trail colors.");
public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (IsValidClient(client) && g_bCvar_Trail_Enable && g_bTrail[client])
{
g_iSpamCMD = 0;
if (IsValidClient(client))
{
if (g_SpawnTimer[client] != null)
{
ResetTimer(g_SpawnTimer[client]);
ResetTimer(g_TrailTimer[client]);
}
}
}
return Plugin_Handled;
}
public int MenuHandler1(Menu menu, MenuAction action, int param1, int param2)
{
switch(action)
{
case MenuAction_Select:
{
char info[32];
menu.GetItem(param2, info, sizeof(info));
TrailSelection(param1, StringToInt(info), false);
}
case MenuAction_End:
{
delete menu;
}
}
return;
}
public Action Command_Trail(int client, int args)
{
if (!g_bCvar_Trail_Enable)
return Plugin_Handled;
if (!IsValidClient(client))
{
CPrintToChat(client, "%s {red}ERROR{default}: You must be alive and not a spectator!", CHAT_BANNER);
return Plugin_Handled;
}
if (g_bCvar_Trail_AdminOnly)
{
if (!CheckCommandAccess(client, "sm_playertrails_override", ADMFLAG_RESERVATION))
{
CPrintToChat(client, "%s {red}ERROR{default}: Only admins may use this command.", CHAT_BANNER);
return Plugin_Handled;
}
}
g_iSpamCMD += 1;
if (g_iSpamCMD >= g_iCvar_Trail_Per_Round)
{
CPrintToChat(client, "%s {red}ERROR{default}: You must wait until next round!", CHAT_BANNER);
return Plugin_Handled;
}
if (args < 1)
{
Menu menu = new Menu(MenuHandler1, MENU_ACTIONS_ALL);
menu.SetTitle("Trail Colors Menu:");
menu.AddItem("1", "red");
menu.AddItem("2", "orange");
menu.AddItem("3", "yellow");
menu.AddItem("4", "green");
menu.AddItem("5", "blue");
menu.AddItem("6", "purple");
menu.AddItem("7", "pink");
menu.AddItem("8", "cyan");
menu.AddItem("9", "white");
menu.AddItem("0", "none");
menu.ExitButton = false;
menu.Display(client, MENU_TIME_FOREVER);
public Action Timer_TrailsCheck(Handle Timer, any serial)
{
int client = GetClientFromSerial(serial);
if (!IsValidClient(client))
return Plugin_Stop;
if (!IsPlayerAlive(client))
return Plugin_Stop;
if (g_bTimerCheck[client])
return Plugin_Stop;
if (g_bCvar_Trail_Enable && g_bTrail[client])
{
if (g_bCvar_Trail_AdminOnly)
{
if (!CheckCommandAccess(client, "sm_playertrails_override", ADMFLAG_RESERVATION))
{
CPrintToChat(client, "%s {red}ERROR{default}: You do not have access to trails!", CHAT_BANNER);
return Plugin_Continue;
}
}
float fPosition[3];
GetClientAbsOrigin(client, fPosition);
int iButtons = GetClientButtons(client);
if (!bVectorsEqual(fPosition, g_fPosition[client]))
{
g_iMatches[client] += 1;
}
if (iButtons == g_iButtons[client])
{
g_iMatches[client] += 1;
}
if (g_iMatches[client] < 2)
{
g_iMatches[client] = 0;
}
public Action Timer_TrailCooldown(Handle Timer, any serial)
{
int client = GetClientFromSerial(serial);
if (!IsValidClient(client))
return Plugin_Stop;
if (!IsPlayerAlive(client))
return Plugin_Stop;
g_bTimerCheck[client] = false;
return Plugin_Handled;
}
public OnSettingsChange(ConVar convar, const char[] oldValue, const char[] newValue)
{
if (convar == g_hCvar_Trail_Enable)
g_bCvar_Trail_Enable = StringToInt(newValue) ? true : false;
else if (convar == g_hCvar_Trail_AdminOnly)
g_bCvar_Trail_AdminOnly = StringToInt(newValue) ? true : false;
else if (convar == g_hCvar_Trail_Duration)
g_fCvar_Trail_Duration = StringToFloat(newValue);
else if (convar == g_hCvar_Trail_Fade_Duration)
g_iCvar_Trail_Fade_Duration = StringToInt(newValue);
else if (convar == g_hCvar_Trail_Width)
g_fCvar_Trail_Width = StringToFloat(newValue);
else if (convar == g_hCvar_Trail_End_Width)
g_fCvar_Trail_End_Width = StringToFloat(newValue);
else if (convar == g_hCvar_Trail_Per_Round)
g_iCvar_Trail_Per_Round = StringToInt(newValue);
}
switch(g_iCookieTrail[client])
{
case 0:
{
g_bTrail[client] = false;
}
case 1:
{
g_iTrailcolor[client][0] = 255;
g_iTrailcolor[client][1] = 0;
g_iTrailcolor[client][2] = 0;
g_bTrail[client] = true;
CreateTrails(client);
if (!spawned) {
CPrintToChat(client, "%s Your trail color is {red}red.", CHAT_BANNER);
CPrintToChat(client, "%s You must stand still to apply the new trail.", CHAT_BANNER);
}
}
case 2:
{
g_iTrailcolor[client][0] = 255;
g_iTrailcolor[client][1] = 128;
g_iTrailcolor[client][2] = 0;
g_bTrail[client] = true;
CreateTrails(client);
if (!spawned) {
CPrintToChat(client, "%s Your trail color is {darkorange}orange.", CHAT_BANNER);
CPrintToChat(client, "%s You must stand still to apply the new trail.", CHAT_BANNER);
}
}
case 3:
{
g_iTrailcolor[client][0] = 255;
g_iTrailcolor[client][1] = 255;
g_iTrailcolor[client][2] = 0;
g_bTrail[client] = true;
CreateTrails(client);
if (!spawned) {
CPrintToChat(client, "%s Your trail color is {orange}yellow.", CHAT_BANNER);
CPrintToChat(client, "%s You must stand still to apply the new trail.", CHAT_BANNER);
}
}
case 4:
{
g_iTrailcolor[client][0] = 0;
g_iTrailcolor[client][1] = 255;
g_iTrailcolor[client][2] = 0;
g_bTrail[client] = true;
CreateTrails(client);
if (!spawned) {
CPrintToChat(client, "%s Your trail color is {green}green.", CHAT_BANNER);
CPrintToChat(client, "%s You must stand still to apply the new trail.", CHAT_BANNER);
}
}
case 5:
{
g_iTrailcolor[client][0] = 0;
g_iTrailcolor[client][1] = 0;
g_iTrailcolor[client][2] = 255;
g_bTrail[client] = true;
CreateTrails(client);
if (!spawned) {
CPrintToChat(client, "%s Your trail color is {blue}blue.", CHAT_BANNER);
CPrintToChat(client, "%s You must stand still to apply the new trail.", CHAT_BANNER);
}
}
case 6:
{
g_iTrailcolor[client][0] = 127;
g_iTrailcolor[client][1] = 0;
g_iTrailcolor[client][2] = 127;
g_bTrail[client] = true;
CreateTrails(client);
if (!spawned) {
CPrintToChat(client, "%s Your trail color is {purple}purple.", CHAT_BANNER);
CPrintToChat(client, "%s You must stand still to apply the new trail.", CHAT_BANNER);
}
}
case 7:
{
g_iTrailcolor[client][0] = 255;
g_iTrailcolor[client][1] = 0;
g_iTrailcolor[client][2] = 127;
g_bTrail[client] = true;
CreateTrails(client);
if (!spawned) {
CPrintToChat(client, "%s Your trail color is {pink}pink.", CHAT_BANNER);
CPrintToChat(client, "%s You must stand still to apply the new trail.", CHAT_BANNER);
}
}
case 8:
{
g_iTrailcolor[client][0] = 0;
g_iTrailcolor[client][1] = 255;
g_iTrailcolor[client][2] = 255;
g_bTrail[client] = true;
CreateTrails(client);
if (!spawned) {
CPrintToChat(client, "%s Your trail color is {lightblue}cyan.", CHAT_BANNER);
CPrintToChat(client, "%s You must stand still to apply the new trail.", CHAT_BANNER);
}
}
case 9:
{
g_iTrailcolor[client][0] = 255;
g_iTrailcolor[client][1] = 255;
g_iTrailcolor[client][2] = 255;
g_bTrail[client] = true;
CreateTrails(client);
if (!spawned) {
CPrintToChat(client, "%s Your trail color is {default}white.", CHAT_BANNER);
CPrintToChat(client, "%s You must stand still to apply the new trail.", CHAT_BANNER);
}
}
}
}
That's because it's currently not possible to do anything other than this with TE_SetupBeamFollow.
I've done by far way to many different methods, and the one there is the best I could manage given the circumstances.
The issue is that changing any of values can cause different side effects; as such, the method I used worked best for changed cvars.
I would surely love for someone to give input or provide a better method, but as far as I am aware, you can not control temporary entities (TE). So killing them and starting them again isn't a viable option; thus, this whole issue I am having. If anyone wants to make a fool of me and provide an example method of killing temp ents and starting them again with a player in motion, I'd sure have a good laugh at myself for it.