AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   +Use for TF2, hooked to secondary fire? (https://forums.alliedmods.net/showthread.php?t=276171)

cheddar 12-16-2015 13:42

+Use for TF2, hooked to secondary fire?
 
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

Chdata 12-16-2015 13:59

Re: +Use for TF2, hooked to secondary fire?
 
you might be able to (Fake)ClientCommand +use

cheddar 12-16-2015 15:14

Re: +Use for TF2, hooked to secondary fire?
 
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;



thecount 12-16-2015 16:56

Re: +Use for TF2, hooked to secondary fire?
 
PHP Code:

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


Plugin_Changed should alter the buttons variable.

Powerlord 12-16-2015 17:22

Re: +Use for TF2, hooked to secondary fire?
 
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.

cheddar 12-16-2015 17:35

Re: +Use for TF2, hooked to secondary fire?
 
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?

thecount 12-16-2015 18:48

Re: +Use for TF2, hooked to secondary fire?
 
Quote:

Originally Posted by cheddar (Post 2373077)
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");

Potato Uno 12-17-2015 00:07

Re: +Use for TF2, hooked to secondary fire?
 
Or you can use:

PHP Code:

SetConVarInt(FindConVar("tf_allow_player_use"), 1); 

(Assuming that's a cvar.)

Powerlord 12-17-2015 00:33

Re: +Use for TF2, hooked to secondary fire?
 
Quote:

Originally Posted by Potato Uno (Post 2373146)
Or you can use:

PHP Code:

SetConVarInt(FindConVar("tf_allow_player_use"), 1); 

(Assuming that's a cvar.)

It is a cvar, yes.

cheddar 12-17-2015 09:08

Re: +Use for TF2, hooked to secondary fire?
 
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




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

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