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

Drums Plugin [CS1.6]


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Fun Stuff       
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 04-20-2020 , 12:58   Drums Plugin [CS1.6]
Reply With Quote #1

Drums

Version 1.0 :

First version of the drums plugin.

Version 1.1 :

Improved the code.

Version 1.1.0 :

Optimized the code.

Version 1.1.1 :

Optimized the code, again.

Video :

https://www.youtube.com/watch?v=dGm1-LSQ6LI

Command :
Type in console : d_menu
Attached Files
File Type: 7z drums.7z (379.6 KB, 165 views)
File Type: sma Get Plugin or Get Source (drums.sma - 235 views - 1.8 KB)

Last edited by Grovliom; 04-21-2020 at 10:37. Reason: New Version
Grovliom is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-20-2020 , 13:24   Re: Drums Plugin
Reply With Quote #2

Poorly coded, could be optimized a lot. Save your paths in a 2D array. use the menu_additem() info parameter to pass info into it, this way the switch() could be removed and a lot of code will become unnessecary. Also please don't hardcode array lengths, use charsmax() instead. U could use menu_display() just once, just check if item != MENU_EXIT.

Remove the .amxx file from your post, it's not allowed to post .amxx files.
__________________

Last edited by Napoleon_be; 04-20-2020 at 13:40.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 04-20-2020 , 13:52   Re: Drums Plugin
Reply With Quote #3

Quote:
Originally Posted by Napoleon_be View Post
Poorly coded, could be optimized a lot. Save your paths in a 2D array. use the menu_additem() info parameter to pass info into it, this way the switch() could be removed and a lot of code will become unnessecary. Also please don't hardcode array lengths, use charsmax() instead. U could use menu_display() just once, just check if item != MENU_EXIT.

Remove the .amxx file from your post, it's not allowed to post .amxx files.
im just a beginer trying to learn. i will try to optimize it, but what is charsmax()
Grovliom is offline
thEsp
BANNED
Join Date: Aug 2017
Old 04-20-2020 , 14:02   Re: Drums Plugin
Reply With Quote #4

Neat idea but in my opinion not worth approving.
thEsp is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-20-2020 , 14:28   Re: Drums Plugin
Reply With Quote #5

PHP Code:
menu_item_getinfo(menuitemaccessdata8iName63callback); 
-->

PHP Code:
menu_item_getinfo(menuitemaccessdatacharsmax(data), iNamecharsmax(iName), callback); 
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 04-20-2020 , 15:03   Re: Drums Plugin
Reply With Quote #6

Charmax is defined in amxx include library, You can open and read anytime to learn new things .
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
Old 04-20-2020, 18:30
Grovliom
This message has been deleted by Grovliom.
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 04-21-2020 , 08:32   Re: Drums Plugin [CS1.6]
Reply With Quote #7

Ok! i Improved the code a bit...
Grovliom is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-21-2020 , 09:03   Re: Drums Plugin [CS1.6]
Reply With Quote #8

Looks much better. You could actually just remove this part:

PHP Code:
new data[8], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdatacharsmax(data), iNamecharsmax(iName), callback);
    new 
key str_to_num(data); 
and use this:

PHP Code:
client_cmd(id"spk %s"drums[item]); 
This way, you just eliminated the switch() and extra useless typing.

EDIT:

Did you test your plugin before updating the thread? This won't work

PHP Code:
public plugin_precache()
{
    
precache_sound(drums[0][0]) //Precache the drum samples

Use a for() loop instead.

Also, this isn't nessecary, since you already check if player didn't press MENU_EXIT.
PHP Code:
if(item == MENU_EXIT// if pressed MENU_EXIT or 0 it destroys the menu
    
{
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED
    

Just simply destroy the menu at the end of the function.
__________________

Last edited by Napoleon_be; 04-21-2020 at 09:10.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 04-21-2020 , 09:36   Re: Drums Plugin [CS1.6]
Reply With Quote #9

Quote:
Originally Posted by Napoleon_be View Post
Looks much better. You could actually just remove this part:

PHP Code:
new data[8], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdatacharsmax(data), iNamecharsmax(iName), callback);
    new 
key str_to_num(data); 
and use this:

PHP Code:
client_cmd(id"spk %s"drums[item]); 
This way, you just eliminated the switch() and extra useless typing.

EDIT:

Did you test your plugin before updating the thread? This won't work

PHP Code:
public plugin_precache()
{
    
precache_sound(drums[0][0]) //Precache the drum samples

Use a for() loop instead.

Also, this isn't nessecary, since you already check if player didn't press MENU_EXIT.
PHP Code:
if(item == MENU_EXIT// if pressed MENU_EXIT or 0 it destroys the menu
    
{
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED
    

Just simply destroy the menu at the end of the function.
i tested the plugin and it worked really good! no errors and no warnings.. i will optimize it more if you want!

Last edited by Grovliom; 04-21-2020 at 09:37.
Grovliom is offline
thEsp
BANNED
Join Date: Aug 2017
Old 04-21-2020 , 09:59   Re: Drums Plugin [CS1.6]
Reply With Quote #10

Quote:
i tested the plugin and it worked really good! no errors and no warnings.. i will optimize it more if you want!
Make sure players download the sounds if they don't have them already.

Code:
for (new iSound = 0; iSound < sizeof(drums); iSound++)     precache_sound(drums[iSound]);

Last edited by thEsp; 04-21-2020 at 10:00.
thEsp is offline
Reply



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 18:51.


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