AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [Any] How can I send keyboard inputs to clients? (https://forums.alliedmods.net/showthread.php?t=342269)

TotalChaos SourcePawner 03-23-2023 19:48

[Any] How can I send keyboard inputs to clients?
 
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.

little_froy 03-24-2023 09:09

Re: [Any] How can I send keyboard inputs to clients?
 
https://sm.alliedmods.net/new-api/sd...OnPlayerRunCmd

the "buttons" parameter.

buttons |= IN_ATTACK;

TotalChaos SourcePawner 03-24-2023 09:50

Re: [Any] How can I send keyboard inputs to clients?
 
Quote:

Originally Posted by little_froy (Post 2801714)
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.

Marttt 03-24-2023 11:32

Re: [Any] How can I send keyboard inputs to clients?
 
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.

TotalChaos SourcePawner 03-24-2023 11:42

Re: [Any] How can I send keyboard inputs to clients?
 
Quote:

Originally Posted by Marttt (Post 2801719)
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 03-24-2023 12:54

Re: [Any] How can I send keyboard inputs to clients?
 
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.

PC Gamer 03-24-2023 14:12

Re: [Any] How can I send keyboard inputs to clients?
 
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.

TotalChaos SourcePawner 03-24-2023 14:27

Re: [Any] How can I send keyboard inputs to clients?
 
Quote:

Originally Posted by PC Gamer (Post 2801732)
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.

Marttt 03-24-2023 15:16

Re: [Any] How can I send keyboard inputs to clients?
 
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

TotalChaos SourcePawner 03-24-2023 15:57

Re: [Any] How can I send keyboard inputs to clients?
 
Quote:

Originally Posted by Marttt (Post 2801734)

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.


All times are GMT -4. The time now is 21:05.

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