Raised This Month: $32 Target: $400
 8% 

[TF2] Duck Piano


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Firewolf24
Junior Member
Join Date: Apr 2017
Location: IKEA
Plugin ID:
6589
Plugin Version:
0.1
Plugin Category:
Fun Stuff
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Old 06-02-2019 , 16:54   [TF2] Duck Piano
    Reply With Quote #1

    [TF2] Duck Piano

    Description:
    It's a duck, it's a piano, it's a duck inside a piano!
    A working piano that you can play if you try hard enough(!)

    Commands:
    • sm_piano - Spawns a piano under your crosshair
    • sm_pianosound <path/to/sound.wav> - Sets a custom sound
    • sm_clearpianos - Removes all spawned pianos

    Convars:
    • sm_piano_pitch - Sets the pitch range for the piano (default: 40)

    Changelist:

    June 2nd 2019 - 0.1
    • Initial release
    Attached Files
    File Type: sp Get Plugin or Get Source (duckpiano.sp - 877 views - 4.3 KB)

    Last edited by Firewolf24; 06-02-2019 at 16:55. Reason: forgot plugin options :|
    Firewolf24 is offline
    PC Gamer
    Veteran Member
    Join Date: Mar 2014
    Old 06-03-2019 , 00:38   Re: [TF2] Duck Piano
    Reply With Quote #2

    Tested with both .wav and .mp3 sounds. Works great. Thanks!
    PC Gamer is offline
    Dispenz0r
    Senior Member
    Join Date: May 2011
    Old 07-12-2019 , 12:51   Re: [TF2] Duck Piano
    Reply With Quote #3

    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
    Dispenz0r is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 07-12-2019 , 13:55   Re: [TF2] Duck Piano
    Reply With Quote #4

    Quote:
    Originally Posted by Dispenz0r View Post
    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:
    Attached Files
    File Type: sp Get Plugin or Get Source (duckpiano.sp - 512 views - 5.7 KB)

    Last edited by Mitchell; 07-14-2019 at 03:53.
    Mitchell is offline
    MAGNAT2645
    Senior Member
    Join Date: Nov 2015
    Location: AlliedMods.net
    Old 07-13-2019 , 01:43   Re: [TF2] Duck Piano
    Reply With Quote #5

    Mitchell, your version logs error:

    L 07/13/2019 - 07:52:22: [SM] Exception reported: Invalid Handle 0 (error: 4)
    L 07/13/2019 - 07:52:22: [SM] Blaming: duckpiano.smx
    L 07/13/2019 - 07:52:22: [SM] Call stack trace:
    L 07/13/2019 - 07:52:22: [SM] [0] ArrayList.FindValue
    L 07/13/2019 - 07:52:22: [SM] [1] Line 50, /home/forums/content/files/7/4/2/3/4/176317.attach::OnPlayerRunCmd

    I think it's because alPianos is null by default (it can be valid only by using sm_piano command). So OnPlayerRunCmd trying to process invalid ArrayList.
    __________________

    Last edited by MAGNAT2645; 07-13-2019 at 01:52.
    MAGNAT2645 is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 07-13-2019 , 11:26   Re: [TF2] Duck Piano
    Reply With Quote #6

    Quote:
    Originally Posted by MAGNAT2645 View Post
    Mitchell, your version logs error:

    L 07/13/2019 - 07:52:22: [SM] Exception reported: Invalid Handle 0 (error: 4)
    L 07/13/2019 - 07:52:22: [SM] Blaming: duckpiano.smx
    L 07/13/2019 - 07:52:22: [SM] Call stack trace:
    L 07/13/2019 - 07:52:22: [SM] [0] ArrayList.FindValue
    L 07/13/2019 - 07:52:22: [SM] [1] Line 50, /home/forums/content/files/7/4/2/3/4/176317.attach::OnPlayerRunCmd

    I think it's because alPianos is null by default (it can be valid only by using sm_piano command). So OnPlayerRunCmd trying to process invalid ArrayList.
    Ya my bad I just forgot to check for null, like I said untested.
    Updated to 1.1.1 in previous post

    Last edited by Mitchell; 07-13-2019 at 13:24.
    Mitchell is offline
    Dagothur
    Member
    Join Date: Dec 2014
    Old 07-19-2019 , 12:49   Re: [TF2] Duck Piano
    Reply With Quote #7

    This is really fun, thanks for it

    For whatever reason the IN_ATTACK2 old buttons check in OnPlayerRunCmd() doesn't work for me so I implemented rate limiting using GetGameTime(). It seemed like even though IN_ATTACK2 was being held down the bit would get set and unset (possibly related to still running SM 1.8?).
    Dagothur is offline
    Sreaper
    髪を用心
    Join Date: Nov 2009
    Old 06-12-2020 , 16:07   Re: [TF2] Duck Piano
    Reply With Quote #8

    Setting the sound to "" will crash the server.

    Code:
    L 06/12/2020 - 13:11:58: Engine error: Host_Error: CEngineSoundServer::PrecacheSound:  Bad string:

    Last edited by Sreaper; 06-12-2020 at 16:08.
    Sreaper is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 14:26.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode