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

[ANY] Console Cmd As Host (Listen Server Only) [v1.0.4 | 08-May-2022]


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Plugin ID:
7660
Plugin Version:
1.0.4
Plugin Category:
Gameplay
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Executes plugin commands from the console as if it were the host client index.
    Old 05-31-2021 , 10:12   [ANY] Console Cmd As Host (Listen Server Only) [v1.0.4 | 08-May-2022]
    Reply With Quote #1

    LISTEN SERVER ONLY

    IMPORTANT NOTE: SourceMod doesn't support Listen Servers.

    Description

    Usually, plugin commands, when typed from the console, don't work on listen servers because the client index output is 0 (server).

    A workaround to this is binding commands with the say command.
    e.g.: (in console) "sm_admin" don't works, while "say !sm_admin" works.

    This plugin executes plugin commands from the console as if it were the host, by finding its client index.

    This is useful for me to test plugins in my local server for development purposes, hope to be useful for others as well.

    Features
    • Convert console commands with client index 0 to their respective client host index.

    Cvars

    A configuration file named "console_cmd_listensv.cfg" will automatically be created for you upon the first run in the "\cfg\sourcemod\" folder.

    PHP Code:
    // Enable/Disable the plugin.
    // 0 = Disable, 1 = Enable.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "1.000000"
    console_cmd_listensv_enable "1"

    // Automatically set the client (except bots) with Admin_Root flag and Immunity 99.
    // 0 = OFF, 1 = HOST ONLY, 2 = EVERYONE.
    // -
    // Default: "1"
    // Minimum: "0.000000"
    // Maximum: "2.000000"
    console_cmd_listensv_setadmin "1" 
    Admin Commands
    • sm_whoishost => Print a table displaying the clients and who is the host to the console. (z flag required)
    • sm_print_cvars_console_cmd_listensv => Print the plugin related cvars and their respective values to the console. (z flag required)

    Change Log

    Spoiler


    Known Supported Games
    • Left 4 Dead 1
    • Left 4 Dead 2
    • Pirates, Vikings, and Knights II
    • Alien Swarm

    Notes
    • This plugin only works on LISTEN SERVER. (local host launched with "-insecure" parameter)
    • The host is detected by finding the client with the IP = loopback/localhost or 127.X.X.X. (you can check this info by typing status in console)

    Thank you!

    Related Plugins

    Post Reply
    • Any feedback, bug reports, fixes, improvements, translations or suggestions for the plugin are welcome.

    Installation
    • Put the "console_cmd_listensv.smx" file (click Get Plugin) in your "\addons\sourcemod\plugins\" folder.
    Attached Files
    File Type: sp Get Plugin or Get Source (console_cmd_listensv.sp - 217 views - 15.6 KB)
    __________________

    Last edited by Marttt; 01-15-2023 at 12:20.
    Marttt is offline
    Psyk0tik
    Veteran Member
    Join Date: May 2012
    Location: Homeless
    Old 05-31-2021 , 11:29   Re: [L4D1 & L4D2] Console Cmd As Host (Listen Server Only) [v1.0.1 | 31-May-2021]
    Reply With Quote #2

    Ayyy it’s finally here!
    __________________
    Psyk0tik is offline
    Tonblader
    Senior Member
    Join Date: Jul 2011
    Location: Peru
    Old 05-31-2021 , 14:16   Re: [L4D1 & L4D2] Console Cmd As Host (Listen Server Only) [v1.0.1 | 31-May-2021]
    Reply With Quote #3

    Good plugin, very useful to enter developer mode in Listen Server or map command in console.
    Tonblader is offline
    Maur0
    Senior Member
    Join Date: Aug 2020
    Old 05-31-2021 , 17:10   Re: [L4D1 & L4D2] Console Cmd As Host (Listen Server Only) [v1.0.1 | 31-May-2021]
    Reply With Quote #4

    You are our hero!!!

    Last edited by Maur0; 05-31-2021 at 17:10.
    Maur0 is offline
    Dragokas
    Veteran Member
    Join Date: Nov 2017
    Location: Ukraine on fire
    Old 06-01-2021 , 03:01   Re: [L4D1 & L4D2] Console Cmd As Host (Listen Server Only) [v1.0.1 | 31-May-2021]
    Reply With Quote #5

    Quote:
    Originally Posted by Marttt View Post
    [*]Vanilla game commands are read aswell (e.g. forward), since I didn't found a way to detect which cmd is by SM or not.
    It is a delta between GetCommandIterator() and FindFirstConCommand().
    You can see FillCmds() routine in my Command Eater, see the scope marked as "iCmdType = CMDType_Game;"

    BTW, nice job! Long time missed feature.
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
    [My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
    Dragokas is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 06-01-2021 , 14:43   Re: [L4D1 & L4D2] Console Cmd As Host (Listen Server Only) [v1.0.1 | 31-May-2021]
    Reply With Quote #6

    This is great well done. Could probably be extended to other games? Maybe using GameRules props to find listen server host? Or look at some other games like CSS/CSGO. They have something like CTerrorPlayerResource/terror_player_manager but their own entity which I think is the same for most other games, would only require a few changes and checks to validate.
    __________________
    Silvers is offline
    Kid_Bandes
    Member
    Join Date: May 2010
    Old 06-02-2021 , 11:30   Re: [L4D1 & L4D2] Console Cmd As Host (Listen Server Only) [v1.0.1 | 31-May-2021]
    Reply With Quote #7

    Hi Marttt, I tried this block in adminmenu_custom.txt, it's not work, but it's work in console
    Code:
    "Zoe"
    {
    			"cmd"			"sm_zoe; wait 1000; sm_3rdon; wait 1000; sm_3rdoff"
    }
    Kid_Bandes is offline
    Marttt
    Veteran Member
    Join Date: Jan 2019
    Location: Brazil
    Old 06-02-2021 , 11:58   Re: [L4D1 & L4D2] Console Cmd As Host (Listen Server Only) [v1.0.1 | 31-May-2021]
    Reply With Quote #8

    @Kid_Bandes,

    You can't use "adminmenu_custom.txt" like that (with ";"), at least in "PlayerCommands" section.

    It is the same as typing "sm_zoe;" in the chat. (doesn't work either)

    You can try to open this as an "issue" to SM github repo and request if they can implement it. (split ";" into different cmds as in console)

    I was able to make it working with "execute" key and by removing the console check from the commands, but I need check how are you doing it.
    __________________

    Last edited by Marttt; 12-08-2021 at 11:08.
    Marttt is offline
    Kid_Bandes
    Member
    Join Date: May 2010
    Old 06-02-2021 , 12:15   Re: [L4D1 & L4D2] Console Cmd As Host (Listen Server Only) [v1.0.1 | 31-May-2021]
    Reply With Quote #9

    Quote:
    Originally Posted by Marttt View Post
    Could you edit the post and share the full file? (please add in a spoiler tag...) Cause is missing some important parts like if you are using "execute" or "PlayerCommands" / "ServerCommands"

    You can't use "adminmenu_custom.txt" like that (with ";"), at least in "PlayerCommands" section.

    It is the same as typing "sm_zoe;" in the chat. (doesn't work either)

    You can try to open this as an "issue" to SM github repo and request if they can implement it. (split ";" into different cmds as in console)

    I was able to make it working with "execute" key and by removing the console check from the commands, but I need check how are you doing it.
    I got it, thank for your quick reply Marttt!
    Kid_Bandes is offline
    Kid_Bandes
    Member
    Join Date: May 2010
    Old 06-02-2021 , 12:19   Re: [L4D1 & L4D2] Console Cmd As Host (Listen Server Only) [v1.0.1 | 31-May-2021]
    Reply With Quote #10

    Here it is, I cut off some cmds
    Edit: Ah, I should edit the previous post instead of creating new one...
    Spoiler

    Last edited by Kid_Bandes; 06-02-2021 at 12:21.
    Kid_Bandes 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 15:14.


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