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

Player actions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Godis
Senior Member
Join Date: Jan 2014
Old 03-15-2014 , 11:47   Player actions
Reply With Quote #1

Hello, some time ago i was wondering how i would swap player actions with eachother, then Powerlord gave me an example wich looked kinda like this code:
PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if (
buttons IN_DUCK)
    {
        
buttons |= IN_JUMP;
        
buttons &= ~IN_DUCK;
    }

It's not exact but i have stripped some things to prevent anyone from stealing my plugin idéa.. Now to the problem, it dosen't work. Checking what action a player is currently in works fine, but removing an action and replacing it with something else does not work, might anyone know what the problem is?

Last edited by Godis; 03-15-2014 at 11:51.
Godis is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 03-15-2014 , 14:13   Re: Player actions
Reply With Quote #2

You need to return Plugin_Changed to register a change in buttons, and Plugin_Continue when you're not changing anything.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
Godis
Senior Member
Join Date: Jan 2014
Old 03-15-2014 , 14:25   Re: Player actions
Reply With Quote #3

Well,
PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if (
buttons IN_DUCK)
    {
        
buttons |= IN_JUMP;
        
buttons &= ~IN_DUCK;
    }
    return 
Plugin_Changed;

It didn't do anything now either, sorry for being a complete newbie but where should i put it? Putting it inside the if statement didn't do anything but to give me a compiling error, and adding it as above didn't give me an error but it did as much as it did before = nothing at all :/
Godis is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 03-15-2014 , 14:30   Re: Player actions
Reply With Quote #4

If you're only looking to do that with OnPlayerRunCmd, and nothing else, it'd be:
PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon
{
    if (
buttons IN_DUCK)
    {
        
buttons |= IN_JUMP;
        
buttons &= ~IN_DUCK;
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;

However, there are quite a few keys that are "read-only" and can only be checked, and not set, such as the basic movement keys (IN_FORWARD, IN_MOVELEFT, etc.)...IN_DUCK and IN_JUMP are probably among those keys.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
Godis
Senior Member
Join Date: Jan 2014
Old 03-15-2014 , 14:32   Re: Player actions
Reply With Quote #5

D: Well that just screwed my whole plugin idéa over, eeh, thanks for the help anyway..
Godis is offline
Godis
Senior Member
Join Date: Jan 2014
Old 03-15-2014 , 14:36   Re: Player actions
Reply With Quote #6

Hmm, is there any way at all to force a player do an action?

Last edited by Godis; 03-15-2014 at 14:37.
Godis is offline
MasterOfTheXP
Veteran Member
Join Date: Aug 2011
Location: Cloudbank
Old 03-15-2014 , 14:38   Re: Player actions
Reply With Quote #7

Keep in mind, though, there are ways to get around that for all of the keys I've mentioned. For movement, you can set the player's velocity, which is a bit hacky, but it works...although just forcing them to "jump" is a lot easier, and uses the same method (with vertical velocity). For crouching/not crouching, I believe the m_bDucked netprop controls that. Maybe. Probably not. But I'm fairly certain there's some way to control that.
__________________
Plugins / My Steam / TF2 Sandbox (plugin beta testing!)
MasterOfTheXP is offline
Godis
Senior Member
Join Date: Jan 2014
Old 03-15-2014 , 16:04   Re: Player actions
Reply With Quote #8

Okay, thanks, i will work my way around!
Godis 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 12:59.


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