Trails stay equipped when dead

Using the latest version of _Undefined’s pointshop on my server. I’ve search all 30 pages of the FP post, but it’s closed now so I can’t even get an update. I’ve seen about 6-10 people mention the same bug, and repeatedly getting told it’s fixed, but I am still not seeing it fixed.

Has anyone found a fix to removing the trails from users who die?

You most likely have duplicate variable names in your items, for example ply.TubeTrail = **** repeated across multiple items.

The best thing to do in this case is this:
if ( IsValid(ply.TubeTrail) ) then ply.TubeTrail:Remove() end
ply.TubeTrail = …

Which you should do for all base trails that ship with your addon.

The actual reason is probably because the item is never holstered.

This won’t work because you can have multiple trails equipped at once. The variable names being different works fine.

Thanks for the quick response!

I have just looked into the files, and opened all trails up. I did a quick search for “ply” across all files to see if I can find what you mentioned what may be the problem, and it seems you are on to something here.

Would this be an example of multiple files having the same function?

http://puu.sh/hkEc1/578ff21e68.png

And if so, what would you recommend I do? The immediate solution would be to remove the files from the shop until I can resolve it myself (working rn). But in the end I would have to re-create the trails I’m assuming (I’ll look into this another time).

EDIT: an example of the trail:


ITEM.Name = 'Electric Trail'
ITEM.Price = 150
ITEM.Material = 'trails/electric.vmt'

function ITEM:OnEquip(ply, modifications)
	ply.ElectricTrail = util.SpriteTrail(ply, 0, modifications.color, false, 15, 1, 4, 0.125, self.Material)
end

function ITEM:OnHolster(ply)
	SafeRemoveEntity(ply.ElectricTrail)
end

function ITEM:Modify(modifications)
	PS:ShowColorChooser(self, modifications)
end

function ITEM:OnModify(ply, modifications)
	SafeRemoveEntity(ply.ElectricTrail)
	self:OnEquip(ply, modifications)
end


ITEM.Name = 'Mouse Cursor'
ITEM.Price = 500
ITEM.Material = 'trails/cursor.vmt'

function ITEM:OnEquip(ply, modifications)
	ply.CursorTrail = util.SpriteTrail(ply, 0, modifications.color, false, 15, 1, 4, 0.125, self.Material)
end

function ITEM:OnHolster(ply)
	SafeRemoveEntity(ply.CursorTrail)
end

function ITEM:Modify(modifications)
	PS:ShowColorChooser(self, modifications)
end

function ITEM:OnModify(ply, modifications)
	SafeRemoveEntity(ply.CursorTrail)
	self:OnEquip(ply, modifications)
end

Yes, make sure the ply.***Trail is unique per item and things will be sorted.

So I can make it whatever? It won’t matter? I only ask because I figured it would need to reference something, but if I can change ABCTrail to BCETrail without a problems then that would be awesome.

As long as it’s the same throughout each individual file then yes. The default ones are named corresponding to the item names, for example the tube trail is ply.TubeTrail and the love heart trail is ply.LoveTrail.

Makes sense now, although I don’t know why you’d want multiple util.SpriteTrail trails.

Awesome. So WITHIN the file I have to make sure to change all of the copied instances to unique instances throughout the script itself. And then follow through with all of the trail files and so on.

I’ll come back with an update and hopefully a SOLVED flair.

Can I ask why i wasn’t able to find a solution in the many other threads? I have honestly not seen this solution on the others.

It took a long while for anyone to explain fully what the problem was and it eventually clicked with me that people were copy/pasting the items without renaming variables which would give the behaviour. It’s my fault really for not making utility functions for trails and avoiding the problem wholly.

Oh word word. So out of curiosity, what bugs were “fixed” in the original github fix when this was originally addressed (see OP). I saw that it was a closed task with the updates, and whatnot.

here’s what I use in one of mine, you can change/remove the team check
[lua]
ITEM.Name = ‘LOL Trail’
ITEM.Price = 12000
ITEM.Material = ‘trails/lol-trail.vmt’

function ITEM:OnEquip(ply, modifications)
if (ply:Team() != TEAM_HUNTERS) or IsValid(ply.LolTrail) then return end
ply.LolTrail = util.SpriteTrail(ply, 0, modifications.color, false, 15, 1, 4, 0.125, self.Material)
end

function ITEM:OnHolster(ply)
SafeRemoveEntity(ply.LolTrail)
ply.LolTrail = nil
end

function ITEM:Modify(modifications)
PS:ShowColorChooser(self, modifications)
end

function ITEM:OnModify(ply, modifications)
SafeRemoveEntity(ply.LolTrail)
ply.LolTrail = nil
self:OnEquip(ply, modifications)
end

function ITEM:CanPlayerEquip(ply)
return (ply:Team() == TEAM_HUNTERS) && ply:Alive()
end

function ITEM:PlayerSilentDeath(ply,mod,vic)
if vic == ply then
SafeRemoveEntity(ply.LolTrail)
ply.LolTrail = nil
end
end

function ITEM:PlayerDeath(ply,mod,vic)
if vic == ply then
SafeRemoveEntity(ply.LolTrail)
ply.LolTrail = nil
end
end
[/lua]

I can’t remember why I did it this way, but I was getting weird behaviour when people died/switched teams.
I use this on prop hunt and it works perfectly.

I’m having issues with the trail again. This time I’m getting a hidden error in the master console. I’ve seen this error with another trail but it’s most likely happening with all trails because the code runs the same. Take a look.

http://puu.sh/hMwcY/7ae23a8cbd.png

Any ideas?

util.DogpawsTrail should be util.SpriteTrail

Out of curiosity, why is that?

SpriteTrail is a function. DogpawsTrail is a nil value because it isn’t set to anything. Sprite isn’t the name of the trail, it’s the name of the function that draws it.

Alright, I changed all of them. Hopefully it works. Thank you!

:slight_smile:

Opening thread. It seems the problem has come back.

One user has these trails bought (possibly all equipped)

http://puu.sh/hW093/2f04d9be2b.jpg

This is a copy of one of the trails in question.

http://puu.sh/hW1fH/ac31f9288e.png

Any ideas?