Raised This Month: $12 Target: $400
 3% 

[Any]Binding button for server


Post New Thread Reply   
 
Thread Tools Display Modes
Author
AK978
Senior Member
Join Date: Jun 2018
Plugin ID:
6451
Plugin Version:
1.2
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    [Any]Binding button for server
    Old 02-27-2019 , 13:46   [Any]Binding button for server
    Reply With Quote #1

    server_bind_key.smx

    Description:
    Directory mode allows players to select temporary binding commands.
    bind - SCORE,DUCK,ZOOM,WALK,SPEED
    Plugin testing is available


    player command:
    sm_bind_menu


    The server administrator provides five open-bound instructions
    conVar:
    sm_command_1 "" //example:sm_buy
    sm_command_2 ""
    sm_command_3 ""
    sm_command_4 ""
    sm_command_5 ""



    version:
    1.0 New Plugin
    1.1 Add Remove bind
    1.2 Code Optimization(optimization: Dragokas)
    1.3 Bug fixes and code optimization(optimization: Dragokas)

    ==================
    server_bind_key_v2.smx

    v2 version - bind *26 key
    "ATTACK"
    "JUMP"
    "DUCK"
    "FORWARD"
    "BACK"
    "USE"
    "CANCEL"
    "LEFT"
    "RIGHT"
    "MOVELEFT"
    "MOVERIGHT"
    "ATTACK2"
    "RUN"
    "RELOAD"
    "ALT1"
    "ALT2"
    "SCORE"
    "SPEED"
    "WALK"
    "ZOOM",
    "WEAPON1"
    "WEPAON2"
    "BULLRUSH"
    "GRENADE1"
    "GRENADE2"
    "ATTACK3"


    Code:
    //You need to change your server command to place your server open binding
    (Should be able to put a lot)
    line 61:
    new const String:g_command[][] = 
    {
    	"sm_buy",
    	"sm_pm",
    	"sm_votes",
    	"sm_dm",
    	"sm_l"
    };

    player command:
    sm_binds_menu


    version:
    1.0 New Plugin



    My plugins

    贊助網址 Donation URL
    https://pay.ecpay.com.tw/CreditPayme...=3050613&Enn=e
    Attached Files
    File Type: sp Get Plugin or Get Source (server_bind_key.sp - 502 views - 7.4 KB)
    File Type: sp Get Plugin or Get Source (server_bind_key_v2.sp - 545 views - 16.5 KB)

    Last edited by AK978; 03-01-2019 at 20:16.
    AK978 is offline
    Dragokas
    Veteran Member
    Join Date: Nov 2017
    Location: Ukraine on fire
    Old 02-27-2019 , 16:08   Re: [Any]Binding button for server
    Reply With Quote #2

    Thanks.

    Code:
    			if(StrEqual(item, command_1, false))
    			{
    				strcopy(tab_command[param1], 32, command_1);
    			}	
    			else if(StrEqual(item, command_2, false))
    			{
    				strcopy(tab_command[param1], 32, command_2);
    			}
    			else if(StrEqual(item, command_3, false))
    			{
    				strcopy(tab_command[param1], 32, command_3);
    			}
    			else if(StrEqual(item, command_4, false))
    			{
    				strcopy(tab_command[param1], 32, command_4);
    			}
    			else if(StrEqual(item, command_5, false))
    			{
    				strcopy(tab_command[param1], 32, command_5);
    			}
    you can cut to:
    Code:
    strcopy(tab_command[param1], sizeof(tab_command[]), item);
    Code:
    strcopy(tab_command[param1], 32, command_6);
    >>>
    Code:
    tab_command[param1][0] = '\0';
    All code could be cut to 1/2 size. All menus can be "packed" to 1. You can just create one more global variable g_iClientChoose[MAXPLAYERS+1] (int or string) and store there currently selected item. Next, in the final menu handler you can check that variable and such a way you know what string array you need to copy item to.

    Also, instead of FindConVar you can use globally declared handles (ConVar). Just assign values returned by CreateConVar. Usually, for that kind of job people use HookConVarChange instead of OnMapStart.
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
    [My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

    Last edited by Dragokas; 02-27-2019 at 16:14.
    Dragokas is offline
    AK978
    Senior Member
    Join Date: Jun 2018
    Old 02-27-2019 , 16:12   Re: [Any]Binding button for server
    Reply With Quote #3

    Thank you for your teaching.

    I don't understand this.
    g_iClientChoose[MAXPLAYERS+1]

    Last edited by AK978; 02-27-2019 at 16:43.
    AK978 is offline
    Dragokas
    Veteran Member
    Join Date: Nov 2017
    Location: Ukraine on fire
    Old 02-27-2019 , 16:36   Re: [Any]Binding button for server
    Reply With Quote #4

    I don't have one.
    What concrete you don't understand?
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
    [My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
    Dragokas is offline
    AK978
    Senior Member
    Join Date: Jun 2018
    Old 02-27-2019 , 17:08   Re: [Any]Binding button for server
    Reply With Quote #5

    There is another place that has not been changed.

    You can just create one more global variable g_iClientChoose[MAXPLAYERS+1] (int or string) and store there currently selected item. Next, in the final menu handler you can check that variable and such a way you know what string array you need to copy item to.

    I don’t understand here.


    Format(s_command_1, sizeof(s_command_1), "bind key[Tab] - %s", tab_command[client]);
    AddMenuItem(menu, "key_tab", s_command_1);
    This will show the saved items

    VERSION:
    1.2
    Attached Files
    File Type: sp Get Plugin or Get Source (server_bind_key.sp - 440 views - 9.7 KB)

    Last edited by AK978; 02-27-2019 at 17:36.
    AK978 is offline
    Dragokas
    Veteran Member
    Join Date: Nov 2017
    Location: Ukraine on fire
    Old 02-28-2019 , 19:03   Re: [Any]Binding button for server
    Reply With Quote #6

    Here it is.

    It's even possible to "pack" code again 1/2 of size by creating arrays instead of different variables for each key. Just my thoughts.

    Code:
    iButtons == SCORE
    If you plan to run command when multiple keys are pressed it's better to make bit check:
    Code:
    iButtons & SCORE
    Also, if you need to run 2 commands (e.g., if both DUCK + ZOOM keys are pressed), you need to remove all "else" statements.
    Attached Files
    File Type: sp Get Plugin or Get Source (server_bind_key (1).sp - 459 views - 7.3 KB)
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
    [My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
    Dragokas is offline
    AK978
    Senior Member
    Join Date: Jun 2018
    Old 02-28-2019 , 20:20   Re: [Any]Binding button for server
    Reply With Quote #7

    Thanks Dragokas,optimized and fixed bugs.

    version:
    1.3

    Last edited by AK978; 03-01-2019 at 19:32.
    AK978 is offline
    AK978
    Senior Member
    Join Date: Jun 2018
    Old 03-01-2019 , 12:08   Re: [Any]Binding button for server
    Reply With Quote #8

    add v2 version

    bind * 26 key
    AK978 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 18:40.


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