Raised This Month: $32 Target: $400
 8% 

[L4D2]Auto Thirdperson Melee


Post New Thread Reply   
 
Thread Tools Display Modes
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 05-12-2016 , 09:19   Re: [L4D2]Auto Thirdperson Melee
Reply With Quote #21

yes it is used for the scope on the sniper its default Mouse3 , it might be a while untill i check it out, im currently making another survivor and intercepting 2k scenes takes a while to do xD
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
Krufftys Killers
Senior Member
Join Date: Jan 2014
Old 05-12-2016 , 09:20   Re: [L4D2]Auto Thirdperson Melee
Reply With Quote #22

Hi MasterMind420 Love the plugin but can you add Added cookie support to save player's preference that way when players return to the server they won't have to type in the command all the time.
Thanks Krufftys Killers
Krufftys Killers is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 05-12-2016 , 09:24   Re: [L4D2]Auto Thirdperson Melee
Reply With Quote #23

Quote:
Originally Posted by Ludastar View Post
yes it is used for the scope on the sniper its default Mouse3 , it might be a while untill i check it out, im currently making another survivor and intercepting 2k scenes takes a while to do xD
ah yes that is what i thought so IN_ZOOM is what you want I believe, we cant actually hook specific buttons correct? Either way i'll probably get to it before you, and i will see about making it highly configurable, wether people want double tap, 2 button combo, all the good stuff.

Last edited by MasterMind420; 05-12-2016 at 09:27.
MasterMind420 is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 05-12-2016 , 09:26   Re: [L4D2]Auto Thirdperson Melee
Reply With Quote #24

Quote:
Originally Posted by Krufftys Killers View Post
Hi MasterMind420 Love the plugin but can you add Added cookie support to save player's preference that way when players return to the server they won't have to type in the command all the time.
Thanks Krufftys Killers
thats so funny you should mention that because its on my todo list, i myself am getting sick of typing it every time...lol
MasterMind420 is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 05-12-2016 , 09:30   Re: [L4D2]Auto Thirdperson Melee
Reply With Quote #25

Quote:
Originally Posted by MasterMind420 View Post
ah yes that is what i thought so IN_ZOOM is what you want I believe, we cant actually hook specific buttons correct? Either way i'll probably get to it before you, and i will see about making it highly configurable, wether people want double tap, 2 button combo, all the good stuff.
Ahh nice, just make a globle bool, true for double click false for button combo and remember to filter bots they dont have a screen xD

Or you can make a globle array for int's and make 1 = double tap or 0 = combo button, and with int's you can use a switch instead, but i prefer switch
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D

Last edited by Lux; 05-12-2016 at 09:32.
Lux is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 05-12-2016 , 10:22   Re: [L4D2]Auto Thirdperson Melee
Reply With Quote #26

Quote:
Originally Posted by MasterMind420 View Post
ah yes that is what i thought so IN_ZOOM is what you want I believe, we cant actually hook specific buttons correct? Either way i'll probably get to it before you, and i will see about making it highly configurable, wether people want double tap, 2 button combo, all the good stuff.
Hmmm, there is a way --> through OnPlayerRunCmd. You can hook there the buttons you need to activate the auto tpm. It can be done by:
PHP Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
       if(
client <= || !IsClientInGame(client) || IsFakeClient(client))
       {
               return 
Plugin_Continue;
       }
        
       if(
buttons IN_ZOOM// even if MMB is not the default setting for others. In other words, any keys that players selected to use scope will still be included.
       
{
               
// Add your code here..
       
}
       
       return 
Plugin_Continue;

Sorry if I gave you old syntax because I'm really used to it as the new one makes me all go dumb. Probably, if Sourcemod removes the old syntax, I'm gonna need some help with my friend.

Last edited by cravenge; 05-12-2016 at 10:25.
cravenge is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 05-12-2016 , 11:30   Re: [L4D2]Auto Thirdperson Melee
Reply With Quote #27

np cravenge, i actually screwed around with it last night, with something similar...my goal with it is to probably allow the server owner to set what they want to use, IN_ZOOM IN_DUCK IN_USE. Single tap, double tap(alittle more difficult to do but think i can manage)These are just examples, which would be provided with a convar, i'm all about people having options. One thing that always drove me nutz and actually got me to start learning sourcepawn is that people should have options for what to use as a trigger key, which is easily doable...what someone may think is a good thing to use, others may beg to differ, i'm all about options. Obviously certain trigger options won't work well, but i'll deal with that when it comes down to testing...granted IN_ZOOM was a good choice by ludastar, i can see minimal conflicts with this, but i may try to give other alternatives as well...we'll see when i get around to it....my priority at the moment is cookie support to save peoples preference...as always any help and examples are appreciated...
MasterMind420 is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 05-12-2016 , 12:21   Re: [L4D2]Auto Thirdperson Melee
Reply With Quote #28

If you want to add cookie support, how about this? I don't what cookie TPV uses but I'll try to Google it.
PHP Code:
#include <clientprefs>
#include <sdkhooks>
new bool:isCurrentlyInTPV;

public 
OnPluginStart()
{
        
isCurrentlyInTPV RegClientCookie("_____________""Is Player Currently Using Third Person View"CookieAccess_Private);
}

public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
}

public 
OnClientDisconnect(client)
{
       
SDKUnhook(clientSDKHook_WeaponSwitchOnWeaponSwitch);
       
       if(
PlayerWantsAutoTPV(client)) // I don't know what you used
       
{
               
SetClientCookie(clientisCurrentlyInTPV"1");
       }
       else
       {
               
SetClientCookie(clientisCurrentlyInTPV"0");
       }
}

public 
OnClientCookiesCached(client)
{
    new 
String:cookie[5];
    
GetClientCookie(clientHasLasercookie5);
        if(
StringToInt(cookie[0])
        {
                
CheckMeleeWeapon(client); // Maybe this or a repeating 1 second CreateTimer should be able to handle and do TPV checking.
        
}
}

CheckMeleeWeapon(client)
{
       new 
cWeap GetPlayerWeaponSlot(client1;
       if(
cWeap <= || !IsValidEntity(cWeap))
       {
                
FPVRevert(client);
       }
       
       
decl String:cWeapClass[128];

       if(
IsValidEdict(cWeap))
       {
                
GetEdictClassname(cWeapcWeapClasssizeof(cWeapClass));
                if(
StrEqual(cWeapClass"weapon_pistol") || StrEqual(cWeapClass"weapon_pistol_magnum"))
                {
                           
FPVRevert(client);
                }
                else
                {
                           
AutoTPV(client);
                }
       }
)

public 
Action:OnWeaponSwitch(clientweapon)
{
        
weapon GetEntPropEnt(clientProp_Send"m_hActiveWeapon");
        if(
AreMeleeWeapons(weapon))
    {
        
AutoTPV(client);
    }
    else
    {
        
FPVRevert(client);
    }
        return 
Plugin_Continue;
}

AutoTPV(client)
{
        
SetEntPropEnt(clientProp_Send"m_hObserverTarget"0);
    
SetEntProp(clientProp_Send"m_iObserverMode"1);
    
SetEntProp(clientProp_Send"m_bDrawViewmodel"0);
}

FPVRevert(client)
{
        
SetEntPropEnt(clientProp_Send"m_hObserverTarget", -1);
    
SetEntProp(clientProp_Send"m_iObserverMode"0);
    
SetEntProp(clientProp_Send"m_bDrawViewmodel"1);
}

AreMeleeWeapons(entity)
{
        new 
String:classname[128];
        if(
IsValidEntity(entity))
        {
                 
GetEntityClassname(entityclassname128);
             if (
StrContains(classname"chainsaw") > -|| StrContains(classname"fireaxe") > -|| StrContains(classname"katana") > -|| StrContains(classname"machete") > -|| StrContains(classname"frying_pan") > -|| StrContains(classname"tonfa") > -|| StrContains(classname"knife") > -|| StrContains(classname"hunting_knife") > -|| StrContains(classname"riotshield") > -|| StrContains(classname"baseball_bat") > -|| StrContains(classname"cricket_bat") > -|| StrContains(classname"electric_guitar") > -|| StrContains(classname"crowbar") > -1)
        {
            return 
true;
        }
        }
}

PlayerWantsAutoTPV(client)
{
        new 
cMWSlot GetPlayerWeaponSlot(client1);
        if(
bPluginOn && cMWSlot && IsValidEntity(cMWSlot) && (GetEntPropEnt(clientProp_Send"m_hObserverTarget") <= && GetEntProp(clientProp_Send"m_iObserverMode") > && GetEntProp(clientProp_Send"m_bDrawViewmodel",) <= 0)) // change this to whatever bool you used and not sure if this is right.
        
{
               return 
true// Still finding a right way for currently used weapon checking other than above.
        
}
        return 
false;


Last edited by cravenge; 05-12-2016 at 12:26.
cravenge is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 05-12-2016 , 13:44   Re: [L4D2]Auto Thirdperson Melee
Reply With Quote #29

Just a rough idea about how i would go about it

Code:
public Action:OnPlayerRunCmd(client, button, impulse, Float;vec[3],  Float:angles[3], weapon)/// what ever you want better to use public  Action:OnPlayerRunCmd()
{
    if(IsFakeClient(client) ||  !IsClientInGame(Client))/// no need to check if the client is connected  because he can't send cmds while he is not connected xD
        return Plugin_Continue;
        
    new Float:fTime = GetGameTime();
    
    if(button & IN_ZOOM)
    {
        if(fTime - g_fTime[client] <= 0.5)
        {
            if(Third_Melee[client])
            {
                Third_Melee[client] = false;
                SetEntPropFloat(client, Prop_Send, "m_TimeForceExternalView", 0.0);
            }
            else
            {
                Third_Melee[client] = true;
                SetEntPropFloat(client, Prop_Send, "m_TimeForceExternalView", 99999.3);
            }
            return Plugin_Continue;
        }
        
        fTime = g_fTime[client];
    }
}
But if your sticking with on gameframe your doing alot of everywhere try lighten the load about like addthing this = MAXFRAMECHECK

Code:
#define MAX_FRAMECHECK 10
new Frameskip = 0; 

public OnGameFrame()
{    
     if(Frameskip != MAX_FRAMECHECK || !IsServerProcessing())// no need to  do it every frame doing all these calls everyframe you can call it after  everyother frame or after 5frames xD saves cpu
    {
        FrameSkip += 1;
        return;
    }
    
    Frameskip = 0;
    
    for(new client=1; client<=MaxClients; client++)
    {
         if(!IsClientConnected(client) || IsFakeClient(client) ||  GetClientTeam(client) != 2)//no need to check bots for stuff or anyone  else who is not connected or anyone not on team 2 (This is cleaner and  faster and usees less cpu :D)
            return;
        
        if(IsPlayerAlive(client))// after this all we need to do is the check if the player is alive we did the rest above :3
        {
            if(Third_Melee[client] == true)
            {
                new String:sClassName[64];
                new WeaponSlot = GetPlayerWeaponSlot(client, GetConVarInt(l4d2_tm_slot));
                if (WeaponSlot == -1) { return; }
                new ActiveWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
                GetEdictClassname(WeaponSlot, sClassName, sizeof(sClassName));
                 if(StrEqual(sClassName, "weapon_melee") &&  WeaponSlot == ActiveWeapon || StrEqual(sClassName, "weapon_chainsaw")  && WeaponSlot == ActiveWeapon)
                {
                    SetEntPropFloat(client, Prop_Send, "m_TimeForceExternalView", 99999.3);
                }
                else
                {
                    SetEntPropFloat(client, Prop_Send, "m_TimeForceExternalView", 0.0);
                }
            }
        }
    }
}
Hope this helps
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D

Last edited by Lux; 05-12-2016 at 15:44.
Lux is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 05-21-2016 , 14:25   Re: [L4D2]Auto Thirdperson Melee
Reply With Quote #30

Sorry for the delay, havent forgotten about the requests, just been busy and lazy...
Anyway, later today i'll be releasing version 1.4 which adds client preferences cookie support
MasterMind420 is offline
Reply


Thread Tools
Display Modes

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 06:19.


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