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

Solved [Request] Plugin that binds things without changing player cfg


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
minimovz
Member
Join Date: Jan 2011
Old 11-25-2020 , 04:16   [Request] Plugin that binds things without changing player cfg
Reply With Quote #1

Hello, i need a plugin that executes a console command when someone presses g (drop gun)

example: I need the G key to open a deathmatch gun menu, the console command for the gun menu is sm_guns, without changing the player's configs

Last edited by minimovz; 12-02-2020 at 13:51. Reason: Solved
minimovz is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 11-25-2020 , 07:27   Re: [Request] Plugin that binds things without changing player cfg
Reply With Quote #2

If I remember well it was blocked by Valve some years ago, unless the client use some modified .dll/.so.
So, not possible. At least in L4D2, all plugins that does "bind" some key it outputs a console error
__________________
Marttt is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-25-2020 , 07:37   Re: [Request] Plugin that binds things without changing player cfg
Reply With Quote #3

He probably talking about OnPlayerRunCmd() without actually forcing clients to change they key bind. It mean use existing keybind like "G" key.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 11-25-2020 , 07:48   Re: [Request] Plugin that binds things without changing player cfg
Reply With Quote #4

In L4D2 there is no action from pressing "G" if I remember, I saw some plugins dropping pressing "R"(IN_RELOAD)

In this case, as GsiX said, you can't bind a key to the client, but you can use OnPlayerRunCmd to check some keys being pressed by the client (like reload [R], zoom [M3], flashlight [F], use [E]) and do some action based on it.
__________________
Marttt is offline
SSheriFF
AlliedModders Donor
Join Date: May 2020
Location: Israel
Old 11-25-2020 , 09:36   Re: [Request] Plugin that binds things without changing player cfg
Reply With Quote #5

Quote:
Originally Posted by minimovz View Post
Hello, i need a plugin that executes a console command when someone presses g (drop gun)

example: I need the G key to open a deathmatch gun menu, the console command for the gun menu is sm_guns, without changing the player's configs
Try that. Also you didnt mention which game.
PHP Code:
#include <cstrike>
public Action CS_OnCSWeaponDrop(int clientint weaponIndex)
{
    
FakeClientCommand(client"sm_guns");

__________________
Taking small private requests (Free) and big private requests (Paid).
Contact me via Discord: WilDick#1524

My Plugins:

Last edited by SSheriFF; 11-25-2020 at 09:38.
SSheriFF is offline
minimovz
Member
Join Date: Jan 2011
Old 11-25-2020 , 14:40   Re: [Request] Plugin that binds things without changing player cfg
Reply With Quote #6

Quote:
Originally Posted by SSheriFF View Post
Try that. Also you didnt mention which game.
PHP Code:
#include <cstrike>
public Action CS_OnCSWeaponDrop(int clientint weaponIndex)
{
    
FakeClientCommand(client"sm_guns");

it's for csgo, what if i wanted it to be another key like the buyammo1 ? is there a way to change the CS_OnCSWeaponDrop to actually be a command executed by a bind i choose ?
minimovz is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-25-2020 , 22:51   Re: [Request] Plugin that binds things without changing player cfg
Reply With Quote #7

I don't responsible for any bug introduce during/after multiple "sm_guns" command call.
You gun plugins should check not to open menu if it already open.

Spoiler


Edit: Really, this don't make any sense, it just introduce more bug. Just tell everyone bind F11"say /sm_guns" . Call they mobile phone if needed. Call they mom if you have to or just advertise it on motd or chat.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 11-26-2020 at 01:07.
GsiX is offline
minimovz
Member
Join Date: Jan 2011
Old 11-26-2020 , 07:25   Re: [Request] Plugin that binds things without changing player cfg
Reply With Quote #8

Quote:
Originally Posted by SSheriFF View Post
Try that. Also you didnt mention which game.
PHP Code:
#include <cstrike>
public Action CS_OnCSWeaponDrop(int clientint weaponIndex)
{
    
FakeClientCommand(client"sm_guns");

didn't work, OnCSWeaponDrop only gets called when the gun is actually dropped i think, the deathmatch plugin doesn't allow the guns to be dropped
minimovz is offline
minimovz
Member
Join Date: Jan 2011
Old 11-26-2020 , 07:39   Re: [Request] Plugin that binds things without changing player cfg
Reply With Quote #9

Ok, i was messing with some things and i was looking through the Weapons & Knives plugin sourcecode that uses the buyammo1 and buyammo2 keybinds to open menus and i tried something and it worked but i don't know if it can causes problem with it triggering the menu on other clients, can someone verify this work only for the client pressing the key ?

Code:
public OnPluginStart()
{
	RegConsoleCmd("drop", OpenMenu);
}

public Action OpenMenu(int client, int args)
{
    FakeClientCommand(client, "sm_guns");
}
minimovz is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-26-2020 , 07:41   Re: [Request] Plugin that binds things without changing player cfg
Reply With Quote #10

PHP Code:
 PrintToChatAll"%d"buttons); 
Place it inside the OnPlayerRunCmd(). What the value when you press "G"..?

I shouldn't ask you to do this without me testing it myself. But it should give you some idea.

Edit:
Quote:
Originally Posted by minimovz View Post
Ok, i was messing with some things and i was looking through the Weapons & Knives plugin sourcecode that uses the buyammo1 and buyammo2 keybinds to open menus and i tried something and it worked but i don't know if it can causes problem with it triggering the menu on other clients, can someone verify this work only for the client pressing the key ?

Code:
public OnPluginStart()
{
	RegConsoleCmd("drop", OpenMenu);
}

public Action OpenMenu(int client, int args)
{
    FakeClientCommand(client, "sm_guns");
}
They are the same command.. you just put command on top of another command.

Edit2: stop adding post. Just edit the old one.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 11-26-2020 at 07:52.
GsiX 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 04:55.


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