Raised This Month: $ Target: $400
 0% 

Solved [Any] How can I send keyboard inputs to clients?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 03-24-2023 , 14:12   Re: [Any] How can I send keyboard inputs to clients?
Reply With Quote #1

You'll probably want to do something similar to this:
PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if (
client == somevalue && client == someothercondition)
    {
        
buttons &= IN_ATTACK;
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;

This code by itself would cause a disaster. I only posted it to show how to force an attack. The OnPlayerRunCmd is always running so the code above will fire constantly while the conditions are met. You'll probably want to put a timer on it to regulate when the attack will stop and start again.

Another option is to use OnTakeDamage which fires when damage is taken.

Note: I'm a TF2 guy so I can't help with specifics regarding L4D2.
PC Gamer is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 03-24-2023 , 14:27   Re: [Any] How can I send keyboard inputs to clients?
Reply With Quote #2

Quote:
Originally Posted by PC Gamer View Post
You'll probably want to do something similar to this:
PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if (
client == somevalue && client == someothercondition)
    {
        
buttons &= IN_ATTACK;
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;

This code by itself would cause a disaster. I only posted it to show how to force an attack. The OnPlayerRunCmd is always running so the code above will fire constantly while the conditions are met. You'll probably want to put a timer on it to regulate when the attack will stop and start again.

Another option is to use OnTakeDamage which fires when damage is taken.

Note: I'm a TF2 guy so I can't help with specifics regarding L4D2.
Thank you very much for the reply, PC Gamer. This helps a bit, but I'm not sure how to integrate it into my code for testing.
As I've said before, I'm a massive noob when it comes to coding. I'm much better with other parts of Source.

I would offer to post my plugin here (or the part of the code I'm working on) in its current state, but it is only a slightly modified version of another plugin that's already available on AlliedModders. And because of that, I don't know if the original creator would be ok with me essentially reuploading their plugin, with minor changes (which, for the most part, remove or break certain features).

My plan was to strip out most of the plugin's features, and make one change to what happens when you press +attack2. So it was just the bare minimum. I could strip out most of the plugin, but it's the pummeling thing that's causing me problems. I just don't know how to start it.

Last edited by TotalChaos SourcePawner; 03-24-2023 at 14:28.
TotalChaos SourcePawner 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 21:05.


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