PHP Code:
new String:pName[64];
Format(pName, sizeof(pName), "cl:%d", client);
new entTrail = CreateEntityByName("env_spritetrail");
if(entTrail != -1)
{
trails[client] = entTrail;
DispatchKeyValue(client, "targetname", pName);
DispatchKeyValue(entTrail, "parentname", pName);
DispatchKeyValue(entTrail, "lifetime", "15.0");
DispatchKeyValue(entTrail, "startwidth", "10.0");
DispatchKeyValue(entTrail, "endwidth", "1.0");
DispatchKeyValue(entTrail, "spritename", "materials/sprites/crystal_beam1.vmt");
DispatchKeyValue(entTrail, "renderamt", "255");
DispatchKeyValue(entTrail, "rendercolor", "255 255 255");
DispatchKeyValue(entTrail, "rendermode", "4");
DispatchSpawn(entTrail);
new Float:pos[3];
GetClientAbsOrigin(client, pos);
pos[2] += 10.0;
TeleportEntity(entTrail, pos, NULL_VECTOR, NULL_VECTOR);
SetVariantString(pName);
AcceptEntityInput(entTrail, "SetParent");
}
When I call this on my player (I also tried parenting it to a grenade), the trail appears for a short amount of time and disappears randomly, but not only that; but the trail is a straight line from the place it is teleported to and where the parent is. Why is that and how can I fix it?