Garry's Mod

Garry's Mod

[TTT/2] Hot Potato!
 This topic has been pinned, so it's probably important
SkyDivingL  [developer] 29 Jan, 2021 @ 11:48am
Errors thread
Let me know if and how the add-on is ruining your day and I'll try to fix it.
< >
Showing 1-15 of 20 comments
[★SG★] Guushi 21 Feb, 2021 @ 4:32pm 
Players found an issue. If you are holding a Detectives weapon or equipment and a traitor gives you the potato, the weapon or equipment overrides the potato as long as you are holding the weapon/equipment.
[★SG★] Guushi 21 Feb, 2021 @ 4:33pm 
I'm assuming the outcome is the same if you are a Traitor and ur holding a T weapon.
SkyDivingL  [developer] 22 Feb, 2021 @ 8:03am 
Originally posted by ★SG★ Guushi:
Players found an issue. If you are holding a Detectives weapon or equipment and a traitor gives you the potato, the weapon or equipment overrides the potato as long as you are holding the weapon/equipment.


Originally posted by ★SG★ Guushi:
I'm assuming the outcome is the same if you are a Traitor and ur holding a T weapon.

Hey, thanks for letting me know. I confirmed this was the case and updated the add-on. Please let me know if the issue pops up again or other issues come up.
The Stig 23 May, 2021 @ 10:21pm 
@SkyDivingL I got these two errors:

[[TTT/2] Hot Potato!] gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua:145: attempt to call method 'Detonate' (a nil value)
1. fn - gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua:145
2. unknown - lua/ulib/shared/hook.lua:109
3. FireBullets - [C]:-1
4. ShootBullet - gamemodes/terrortown/entities/weapons/weapon_tttbase.lua:328
5. unknown - lua/weapons/weapon_stenmk3/shared.lua:75

[[TTT/2] Hot Potato!] gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua:151: attempt to call method 'Detonate' (a nil value)
1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua:151

I highly suspect it is because we were holding our guns for some reason and not the hot potato when we were given it, so the "GetActiveWeapon()" call was pulling the gun we were holding and not the hot potato, hence the 'Detonate' function didn't exist.

Maybe try using 'self:Detonate(ply)' instead of calling GetActiveWeapon()?
And adding a timer.Simple to ply:SelectWeapon( "weapon_ttt_hotpotato" ) so they equip it after a delay?

Also, the speed boost convar didn't seem to do anything.
Last edited by The Stig; 23 May, 2021 @ 10:23pm
SkyDivingL  [developer] 24 May, 2021 @ 5:25am 
Originally posted by The Stig:
@SkyDivingL I got these two errors:

[[TTT/2] Hot Potato!] gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua:145: attempt to call method 'Detonate' (a nil value)
1. fn - gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua:145
2. unknown - lua/ulib/shared/hook.lua:109
3. FireBullets - [C]:-1
4. ShootBullet - gamemodes/terrortown/entities/weapons/weapon_tttbase.lua:328
5. unknown - lua/weapons/weapon_stenmk3/shared.lua:75

[[TTT/2] Hot Potato!] gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua:151: attempt to call method 'Detonate' (a nil value)
1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua:151

I highly suspect it is because we were holding our guns for some reason and not the hot potato when we were given it, so the "GetActiveWeapon()" call was pulling the gun we were holding and not the hot potato, hence the 'Detonate' function didn't exist.

Maybe try using 'self:Detonate(ply)' instead of calling GetActiveWeapon()?
And adding a timer.Simple to ply:SelectWeapon( "weapon_ttt_hotpotato" ) so they equip it after a delay?

Also, the speed boost convar didn't seem to do anything.

Can you tell me anything that happened before the error occurred? From your description it sounds like you were holding a weapon and somebody gave you an activated hot potato, but that shouldn't cause any issues.

I'll look at the issue and also that of the convar.
The Stig 24 May, 2021 @ 5:48am 
Originally posted by SkyDivingL:
From your description it sounds like you were holding a weapon and somebody gave you an activated hot potato, but that shouldn't cause any issues.

That is exactly what happened. I had to manually select the hot potato to hold it, ran out of time, but didn't explode and the second error happened.

The first error happened away from me so I didn't see what happened, but I copied it from the console anyway.
SkyDivingL  [developer] 24 May, 2021 @ 8:23am 
Originally posted by The Stig:
Originally posted by SkyDivingL:
From your description it sounds like you were holding a weapon and somebody gave you an activated hot potato, but that shouldn't cause any issues.

That is exactly what happened. I had to manually select the hot potato to hold it, ran out of time, but didn't explode and the second error happened.

The first error happened away from me so I didn't see what happened, but I copied it from the console anyway.

I'm investigating some causes for this error. I have managed to recreate it, and it looks like other addons interfered with the logic of the potato.

The potato works by removing the equipment 1 item (slot 7 typically, but irrelevant) and replacing it with the activated potato. It doesn't matter what weapon you're holding when this happens (with the exception of a potato that's already activated).

After that, the code assumes the player is still holding the potato. I've tried to prevent players from losing the potato: they can't drop it, they can't switch weapons, it blows up on death.

I forgot that some addons could strip weapons from a player, such as the Free Kill Gun Gifter. This weapon in particular removes the equipment 1 item, and if this is an activated potato, there is no way to access Detonate(). This recreates the issue you had.

I'll try and fix this issue for some addons I know (FKG gifter, handcuffs), but could you also tell me about any other addons you use that have similar effects? This allows me to make sure the fix works for these addons as well.

On the subject of the speed convar, I can't find any issues with it either. It is only applied to the player holding an activated potato. By default it's 1.2x boost and I observe this in testing, and I confirmed the convar works in general by setting it to 100x. Maybe 1.2x wasn't noticeable?
The Stig 24 May, 2021 @ 10:17am 
Originally posted by SkyDivingL:
Originally posted by The Stig:

That is exactly what happened. I had to manually select the hot potato to hold it, ran out of time, but didn't explode and the second error happened.

The first error happened away from me so I didn't see what happened, but I copied it from the console anyway.

I'm investigating some causes for this error. I have managed to recreate it, and it looks like other addons interfered with the logic of the potato.

The potato works by removing the equipment 1 item (slot 7 typically, but irrelevant) and replacing it with the activated potato. It doesn't matter what weapon you're holding when this happens (with the exception of a potato that's already activated).

After that, the code assumes the player is still holding the potato. I've tried to prevent players from losing the potato: they can't drop it, they can't switch weapons, it blows up on death.

I forgot that some addons could strip weapons from a player, such as the Free Kill Gun Gifter. This weapon in particular removes the equipment 1 item, and if this is an activated potato, there is no way to access Detonate(). This recreates the issue you had.

I'll try and fix this issue for some addons I know (FKG gifter, handcuffs), but could you also tell me about any other addons you use that have similar effects? This allows me to make sure the fix works for these addons as well.

On the subject of the speed convar, I can't find any issues with it either. It is only applied to the player holding an activated potato. By default it's 1.2x boost and I observe this in testing, and I confirmed the convar works in general by setting it to 100x. Maybe 1.2x wasn't noticeable?

Oh, the speed convar is only applied to a live potato? My fault then.
The hot potato never exploded when we used it around 10 times on different maps, we weren't using weapon-stripping weapons every time. But if it's working for you then there's something on my end that's interfering with it. Not sure when I can get around to testing.

As for addons I use that could strip weapons, here's some links:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2249861635
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=785294711
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1821994534
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1821993909

There's also the randomat, though that might be a bit much to make compatible:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2055805086
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2428342861
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2428350426

This mod might also interfere, putting it here just in case:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2451418207
The Stig 25 May, 2021 @ 3:20am 
@SkyDivingL I've found the problem: TFA Guns. From my testing, the hot potato failed to work every time a bot was holding a TFA gun, but worked fine otherwise.

What is a TFA Gun? Any weapon using TFA Base as a base for the weapon, for example these weapons: https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2451435560

I tested with the duel-wield shotguns (classname: c_reaper_nope) from the mod above, here's what I did to get the error:

Make someone hold out a TFA weapon, give them a hot potato, and the player will fail to switch from the TFA weapon to the hot potato, after they were supposed to explode, this error will occur:

[[TTT/2] Hot Potato!] gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua:164: attempt to call method 'Detonate' (a nil value)
1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua:164

Timer Failed! [Bot03_PotatoTooHot][@gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua (line 162)]
SkyDivingL  [developer] 25 May, 2021 @ 5:51pm 
Originally posted by The Stig:
@SkyDivingL I've found the problem: TFA Guns. From my testing, the hot potato failed to work every time a bot was holding a TFA gun, but worked fine otherwise.

What is a TFA Gun? Any weapon using TFA Base as a base for the weapon, for example these weapons: https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2451435560

I tested with the duel-wield shotguns (classname: c_reaper_nope) from the mod above, here's what I did to get the error:

Make someone hold out a TFA weapon, give them a hot potato, and the player will fail to switch from the TFA weapon to the hot potato, after they were supposed to explode, this error will occur:

[[TTT/2] Hot Potato!] gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua:164: attempt to call method 'Detonate' (a nil value)
1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua:164

Timer Failed! [Bot03_PotatoTooHot][@gamemodes/terrortown/entities/weapons/weapon_ttt_hotpotato.lua (line 162)]
Thanks for getting it down to something very specific. I'll see if I can fix the issue with this information.
SkyDivingL  [developer] 26 May, 2021 @ 11:47am 
Originally posted by The Stig:
@SkyDivingL I've found the problem: TFA Guns. From my testing, the hot potato failed to work every time a bot was holding a TFA gun, but worked fine otherwise.

You were right! If someone is holding one of your overwatch guns when given a potato, they switch to the potato but immediately switch back.

What I did to (hopefully) fix this is to strip all weapons from the target rather than just the equipment 1 item. This circumvents that weird non-switch issue.

I wish I could think of a more elegant solution to the problem, but I don't understand the weapon not properly switching in the first place, so this will have to do.

I've updated the addon. Let me know if it's still busted!
Malivil 26 May, 2021 @ 1:51pm 
Does the player get their weapons back if they give the hot potato away?
SkyDivingL  [developer] 26 May, 2021 @ 3:47pm 
Originally posted by Malivil:
Does the player get their weapons back if they give the hot potato away?
If all works well, yes. Weapons are stripped but returned with the same ammo.
The Stig 26 May, 2021 @ 8:12pm 
@SkyDivingL From my testing, it all works! Thanks so much for all that.
Malivil 27 May, 2021 @ 4:40am 
Originally posted by SkyDivingL:
Originally posted by Malivil:
Does the player get their weapons back if they give the hot potato away?
If all works well, yes. Weapons are stripped but returned with the same ammo.

That's awesome, good job =)
< >
Showing 1-15 of 20 comments
Per page: 1530 50