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

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 03-23-2023 , 19:48   [Any] How can I send keyboard inputs to clients?
Reply With Quote #1

3/24/2023: I gave up on this. My brain is fried. I can't make the original plugin that I wanted to because I don't know how to code.
If you're interested in what I was trying to do just read down below.
Feel free to take on what I was trying to do I don't care.

Original post:
Hi.
Is it possible to send keyboard inputs (such as +attack) to clients?
I'm working on a plugin which requires the user (or a bot) to press +attack at very specific points for it to work properly.

Any and all help would be greatly appreciated.
TotalChaos.

Last edited by TotalChaos SourcePawner; 03-29-2023 at 17:27. Reason: Coding isn't hard, it's nearly impossible. Fair play and applause to anybody who knows how to code. You're incredibly smart.
TotalChaos SourcePawner is offline
little_froy
Senior Member
Join Date: May 2021
Old 03-24-2023 , 09:09   Re: [Any] How can I send keyboard inputs to clients?
Reply With Quote #2

https://sm.alliedmods.net/new-api/sd...OnPlayerRunCmd

the "buttons" parameter.

buttons |= IN_ATTACK;
little_froy is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 03-24-2023 , 09:50   Re: [Any] How can I send keyboard inputs to clients?
Reply With Quote #3

Quote:
Originally Posted by little_froy View Post
https://sm.alliedmods.net/new-api/sd...OnPlayerRunCmd

the "buttons" parameter.

buttons |= IN_ATTACK;
I'm not very good with coding, at all. But from what I can tell, that's for finding out when the user (or bot) presses a button, not for sending a command to the client.
Again, I am very bad with coding, so for all I know this is the solution (I'm not even sure how to set it up).

Remember, I'm looking for a solution that works with both human players, and bots. I don't want just one or the other.

Sorry if this comes off as rude, that's not my intention.
TotalChaos SourcePawner is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 03-24-2023 , 11:32   Re: [Any] How can I send keyboard inputs to clients?
Reply With Quote #4

change it on OnPlayerRunCmd or PreThink, but usually doesn't works well because of prediction issues
for bots you can try calling CommandABot vscript command.
__________________
Marttt is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 03-24-2023 , 11:42   Re: [Any] How can I send keyboard inputs to clients?
Reply With Quote #5

Quote:
Originally Posted by Marttt View Post
change it on OnPlayerRunCmd or PreThink, but usually doesn't works well because of prediction issues
for bots you can try calling CommandABot vscript command.
Sorry, having a hard time understanding.
Like I said above, I'm not that good with coding. Even if I understood that, I have absolutely no idea how to set it up.

That's one of my many problems with the SourcePawn documentation. There's no examples on how to set it up.
How are newbies like me supposed to learn without any examples?
And, knowing Google, how am I supposed to search for examples?

If any of this comes off as rude, I'm sorry. That's not my intention.
TotalChaos SourcePawner is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 03-24-2023 , 12:54   Re: [Any] How can I send keyboard inputs to clients?
Reply With Quote #6

Alright, I'm going to go into a bit more detail with what I'm trying to do.

I want to force-trigger the Charger's pummeling ability in Left 4 Dead 2, on command.
I already have a plugin that I'm modifying that gets me most of the way there, but there's one small piece of the puzzle that I'm missing. And that's the pummeling thing.
+attack triggers the pummeling while you're holding a Survivor, but it only works on the player's input. That's why I want to send that input to a human player/bot, so that I can force them to start pummeling the Survivor.
I tried using Left 4 DHooks, but I'm not sure how to use some of that stuff.
EDIT: If there's a better way to trigger this, please let me know.
I've tried absolutely everything I can think of. Nothing is working. The +attack thing was my last guess, outside of forcing a charge (neither of which I know how to do).

Sorry if this is too much information, or if it strays too far from my original question.

Last edited by TotalChaos SourcePawner; 03-24-2023 at 13:59.
TotalChaos SourcePawner is offline
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 #7

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 #8

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
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 03-24-2023 , 15:16   Re: [Any] How can I send keyboard inputs to clients?
Reply With Quote #9

is basically a copy+paste, has a lot of examples in the forum

https://www.google.com/search?q=OnPl...alliedmods.net

https://forums.alliedmods.net/showthread.php?t=315053
__________________

Last edited by Marttt; 03-24-2023 at 15:17.
Marttt is offline
TotalChaos SourcePawner
Senior Member
Join Date: Feb 2023
Location: IN PINEAPPLE, UNDER SEA
Old 03-24-2023 , 15:57   Re: [Any] How can I send keyboard inputs to clients?
Reply With Quote #10

Quote:
Originally Posted by Marttt View Post
Thank you very much Marttt.
But I think I fried my brain trying to figure out why my original attempts weren't working, and I just realized that there's a ton of other stuff I would have to do to get this working.
So I think I'm just gonna stop working on the plugin for now.

For anyone who's curious, this is the plugin I was modifying: https://forums.alliedmods.net/showthread.php?p=2605254
It was originally a recreation of the pre-release Charger (+attack = charge, don't grab Survivors, send them flying, +attack2 = instantly pummel the Survivor instead of using the claw attack). But it seems like the creator went in a bit of a different direction with the plugin, for whatever reason.
I wanted to finish the original idea with the plugin. But this is proving to be far too difficult for me. And, seeing as the original creator doesn't want to work on it anymore, I don't think this would be happening anytime soon.

Thanks for all the help.

Last edited by TotalChaos SourcePawner; 03-24-2023 at 15:59.
TotalChaos SourcePawner 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 02:17.


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