Quote:
Originally Posted by Dispenz0r
Code:
L 07/12/2019 - 17:15:50: [SM] Exception reported: Entity 445 (445) is not a CBaseEntity
L 07/12/2019 - 17:15:50: [SM] Blaming: duckpiano.smx
L 07/12/2019 - 17:15:50: [SM] Call stack trace:
L 07/12/2019 - 17:15:50: [SM] [0] AcceptEntityInput
L 07/12/2019 - 17:15:50: [SM] [1] Line 153, D:\TF2Server\steamapps\common\Team Fortress 2 Dedicated Server\tf\addons\sourcemod\scripting\duckpiano.sp::RemoveAllPianos
L 07/12/2019 - 17:15:50: [SM] [2] Line 37, D:\TF2Server\steamapps\common\Team Fortress 2 Dedicated Server\tf\addons\sourcemod\scripting\duckpiano.sp::OnPluginEnd
Seem to be getting very similar errors such as this often
|
Because the plugin stores the piano entities as normal entity indices, which can be removed and filled in by a different entity without the plugin knowing. (i.e. on round restart all props are removed)
There's actually a lot of design flaws that you should be hesitant about putting this on a server. Clearing the pianos runs a "Kill" on the entity, while not even checking if the entity is valid or even a prop_dynamic. So it could kill logic entities or entities that will crash the server (similar to "Kill" on the player or world).
Not to mention OnPlayerRunCmd gets everyone's POV entity THEN does checks to make sure they are pressing the right button.
This plugin has some potential. I did a pretty much full redo, I formatted it to my personal code style and fixed a few things:
1. Use Entity References instead of index to store.
2. Use ArrayList instead of a hardcoded capped list.
3. Auto cleanup of the piano list once it hits the cap. (Instead of spawning in 16 pianos, round resets but the count doesn't)
4. Delete the Trace handle within the spawn command (Resource leak!)
5. Fixed the math against float values using int values. Minor nit, but should still keep this in mind when working with floats.
6. Added sanity checks to OnPlayerRunCmd before trying to get an entity they are aiming at. Also now checks if the player is alive to prevent spectators from spamming pianos.
7. Added sm_piano_max convar to constrain the amount of pianos made.
8. Added AutoExecConfig() for convars.
9. Adjusted version to conform to Semantic Versioning 2.0.0
10. Moved Precache from client connect to on MapStart.
Some features that'd be cool to have:
1. ServerCommand for maps to add in the piano themselves or a server operator to add in. "sm_piano_ex <X> <Y> <Z> [P] [Y] [R] [sound pitch] [sound file] [model?]"
2. Command that contains additional properties, such as: sm_piano [pitch] [sound file]. Which would allow better customization etc.
3. Player limits, limit how many any admin can create
4. Player leave cleanup. If an admin creates them and leaves should it remove the piano?
5. Color depending on the piano's sound pitch?
Anyways here's my UNTESTED version: