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

+Use for TF2, hooked to secondary fire?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cheddar
Member
Join Date: Sep 2015
Old 12-16-2015 , 13:42   +Use for TF2, hooked to secondary fire?
Reply With Quote #1

I'm trying to get a few plugins together that will make playing garrys mod maps in tf2 smooth.

One of the features that garry's mod has that TF2 doesn't is an abundance of +use functions. (Doors, levers etc.)

I know it's possible to hook into player actions to have it do alternate things. I'm wondering how to make a plugin that whenever you press your alt fire (right click) it also does +use.
This bind is called "+attack2"

Alternatively, it might work for this to be bound to whenever someone calls for medic. As in... look at a door, call medic... door opens.

-Ched

Last edited by cheddar; 12-16-2015 at 13:55.
cheddar is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 12-16-2015 , 13:59   Re: +Use for TF2, hooked to secondary fire?
Reply With Quote #2

you might be able to (Fake)ClientCommand +use
__________________
Chdata is offline
cheddar
Member
Join Date: Sep 2015
Old 12-16-2015 , 15:14   Re: +Use for TF2, hooked to secondary fire?
Reply With Quote #3

Thanks chdata for the response. I tried using FakeClientCommandEx() to send the command but I got a "Unknown command: +use" error message.

This is my code:

PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    
// Check if the player is secondary attacking (+attack2)
    
if ((buttons IN_ATTACK2) == IN_ATTACK2)
    {
        
// If so, add the button to use (+use)
        
FakeClientCommandEx(client"+use");
    }
    return 
Plugin_Continue;


Last edited by cheddar; 12-16-2015 at 16:54.
cheddar is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 12-16-2015 , 16:56   Re: +Use for TF2, hooked to secondary fire?
Reply With Quote #4

PHP Code:
public Action:OnPlayerRunCmd(client, &buttons){
    if ((
buttons IN_ATTACK2)){
        
buttons &= IN_USE;
    }
    return 
Plugin_Changed;

Plugin_Changed should alter the buttons variable.
thecount is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-16-2015 , 17:22   Re: +Use for TF2, hooked to secondary fire?
Reply With Quote #5

You might want to have you plugin verify that tf_allow_player_use is set to 1 so that the game server doesn't ignore +use.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
cheddar
Member
Join Date: Sep 2015
Old 12-16-2015 , 17:35   Re: +Use for TF2, hooked to secondary fire?
Reply With Quote #6

Thanks guys for your help and support. The following is my working code for the simple plugin:

Turns out I needed a '+=' instead of the '&='

PHP Code:
public void OnPluginStart()
{
       
//enable +use server side
    
decl String:enableuse[255];
    
enableuse="tf_allow_player_use 1";
    
ServerCommand("%s"enableuse);      
}

public 
Action:OnPlayerRunCmd(client, &buttons)

    
// Check if the player is secondary attacking (+attack2) 
    
if ((buttons IN_ATTACK2))
    { 
        
// If so, add the button to use (+use)
        
buttons += IN_USE
    } 
    return 
Plugin_Changed

Powerlord, does the modifications I made on the plugin start do what you suggested?

Last edited by cheddar; 12-16-2015 at 17:59.
cheddar is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 12-16-2015 , 18:48   Re: +Use for TF2, hooked to secondary fire?
Reply With Quote #7

Quote:
Originally Posted by cheddar View Post
does the modifications I made on the plugin start do what you suggested?
Sort of, but it can easily be done with one line of code instead of declaring strings for no reason. ServerCommand("tf_allow_player_use 1");
thecount is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 12-17-2015 , 00:07   Re: +Use for TF2, hooked to secondary fire?
Reply With Quote #8

Or you can use:

PHP Code:
SetConVarInt(FindConVar("tf_allow_player_use"), 1); 
(Assuming that's a cvar.)
Potato Uno is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-17-2015 , 00:33   Re: +Use for TF2, hooked to secondary fire?
Reply With Quote #9

Quote:
Originally Posted by Potato Uno View Post
Or you can use:

PHP Code:
SetConVarInt(FindConVar("tf_allow_player_use"), 1); 
(Assuming that's a cvar.)
It is a cvar, yes.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
cheddar
Member
Join Date: Sep 2015
Old 12-17-2015 , 09:08   Re: +Use for TF2, hooked to secondary fire?
Reply With Quote #10

Ok, so I just spent the night putting new things into this plugin. I've also changed it so it doesn't need a string.
I want it to be eventually released to the public. Very open to suggestions/advice.

I've added 3 new features to this plugin.

1) It now modifies your speed and jump height to approximately match a Garry's mod character.
----> This requires TF2 Attributes
2) It uses the the [ANY] Resize Players plugin to re-size players to approximately match a Garry's mod character.
3) It now has a cvar to enable/disable. <-- this only works if it's set BEFORE the map loads... best way to do this is through map.cfg settings

What do you guys think?

PHP Code:
#include <tf2>
#include <tf2attributes>

#define GMAPTF2_VERSION "0.5"

new Handle:gmaptf2_enabled;
new 
oldjoin;
new 
Float:oldscale;

public 
Plugin:myinfo 
{
    
name "Gmaptf2",
    
author "Cheddar",
    
description "Adapts maps from garry's mod",
    
version GMAPTF2_VERSION,
    
url "http://steamcommunity.com/groups/DumpsterBabyInc"
};

public 
void OnPluginStart()//When Plugin loads initialize the enable cvar
{
    
gmaptf2_enabled CreateConVar("gmaptf2_enabled""1""Enable or disable gmaptf2; 0 - disabled, 1 - enabled");
}

public 
OnAutoConfigsBuffered()//After the server.cfg has loaded
{    
    
//First save the values of what resizeme has
    
oldjoin=GetConVarInt(FindConVar("sm_resize_onjoin"));
    
oldscale=GetConVarFloat(FindConVar("sm_resize_defaultresize"));
    
    
//Then, if the plugin is enabled change the resizeme values    
    
if(GetConVarInt(gmaptf2_enabled) == 1)
    {
        
SetConVarInt(FindConVar("tf_allow_player_use"), 1); 
        
SetConVarFloat(FindConVar("sm_resize_defaultresize"), 0.84);
        
SetConVarInt(FindConVar("sm_resize_onjoin"), 2);    
    }
}

public 
void OnMapEnd()//On map end
{
    
//Change resizeme variables back to what they were.
    
SetConVarFloat(FindConVar("sm_resize_defaultresize"), oldscale);
    
SetConVarInt(FindConVar("sm_resize_onjoin"), oldjoin);
}

public 
OnClientPostAdminCheck(client// When player joins
{
    
AlterSpeedandJump(client1); //Alter their jump and speed    
}

public 
Action AlterSpeedandJump(clientargs)
{
    if(
GetConVarInt(gmaptf2_enabled) == 1// Check if gmaptf2 is enabled
    
{
        new 
Float:value=0.84;    
        {
            
TF2Attrib_SetByName(client"major increased jump height"value);
            
TF2Attrib_SetByName(client"major move speed bonus"value);
        }            
    }    
    return 
Plugin_Handled;
}

public 
Action:OnPlayerRunCmd(client, &buttons)

    if(
GetConVarInt(gmaptf2_enabled) == 1)
    {        
        
// Check if the player is secondary attacking (+attack2) 
        
if ((buttons IN_ATTACK2))
        { 
            
// If so, add the button to use (+use)
            
buttons += IN_USE;    
        } 
        return 
Plugin_Changed;     
    }
    return 
Plugin_Continue


Last edited by cheddar; 12-17-2015 at 11:43.
cheddar 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:39.


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