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

[L4D2] TankDoorFix


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Captain Stubin
Member
Join Date: Jun 2017
Old 12-18-2018 , 05:59   [L4D2] TankDoorFix
Reply With Quote #1

Hello help with plugin. Below the tank is knocked out ( destroyed) all the doors including the freezer door.


PHP Code:
/* Plugin Template generated by Pawn Studio */

#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <entity_prop_stocks>

#define VERSION "1.4"

//Found ent 'prop_door_rotating', id: 163

/*
*
* -Member: m_hActiveWeapon (offset 2100) (type integer) (bits 21) 

* Sub-Class Table (2 Deep): DT_LocalActiveWeaponData
*-Member: m_flNextPrimaryAttack (offset 1156) (type float) (bits 0)
*-Member: m_flNextSecondaryAttack (offset 1160) (type float) (bits 0)


* Test 696.716674 697.950012
* Test 700.016723 697.966674

*/

new tankCount;

new 
Float:nextTankPunchAllowed[19];

new 
tankClassIndex;

public 
Plugin:myinfo 
{
    
name "TankDoorFix",
    
author "PP(R)TH: Dr. Gregory House",
    
description "This should at some point fix the case in which the tank misses the door he's supposed to destroy by using his punch",
    
version VERSION,
    
url "http://forums.alliedmods.net/showthread.php?t=225087"
}

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
decl String:gameName[32];
    
    
GetGameFolderName(gameNamesizeof(gameName));
    
    if(
StrEqual(gameName"left4dead"))
    {
        
tankClassIndex 5;
    }
    else
    {
        if(
StrContains(gameName"left4dead2") > -1)
        {
            
tankClassIndex 8;
        }
        else
        {
            
strcopy(errorerr_max"This plugin only supports L4D(2).");
            return 
APLRes_SilentFailure;
        }
    }
    return 
APLRes_Success;
}

public 
OnPluginStart()
{
    
HookEvent("tank_spawn"Event_TankSpawn);
    
HookEvent("tank_killed"Event_TankKilled);
    
    
CreateConVar("tankdoorfix_version"VERSION"TankDoorFix Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
}

public 
OnMapStart()
{
    
tankCount 0;
}

public 
Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if(
tankCount 0)
    {
        if(
GetClientTeam(client) == && GetEntProp(clientProp_Send"m_zombieClass") == tankClassIndex)
        {
            if(
buttons IN_ATTACK)
            {
                new 
tankweapon GetEntPropEnt(clientProp_Send"m_hActiveWeapon");
                
                if(
tankweapon 0)
                {
                    new 
Float:gameTime GetGameTime();
                    
                    if(
GetEntPropFloat(tankweaponProp_Send"m_flTimeWeaponIdle") <= gameTime && nextTankPunchAllowed[client] <= gameTime)
                    {
                        
nextTankPunchAllowed[client] = gameTime 2.0;
                        
                        
CreateTimer(1.0Timer_DoorCheckGetClientUserId(client));
                    }
                }
            }
        }
    }
    
    return 
Plugin_Continue;
}

public 
Action:Timer_DoorCheck(Handle:timerany:clientUserID)
{
    new 
client GetClientOfUserId(clientUserID);
    
    if(
client && IsClientInGame(client))
    {
        
decl Float:direction[3];
        
        new 
result IsLookingAtBreakableDoor(clientdirection);
        
        if(
result 0)
        {
            
LogMessage("Door bug circumvented.");
            
PrintToChat(client"Door bug circumvented.");
            
SDKHooks_TakeDamage(resultclientclient1200.0128_direction);
        }
    }
}

public 
Event_TankSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    
tankCount++;
    
    
nextTankPunchAllowed[GetClientOfUserId(GetEventInt(event"userid"))] = GetGameTime() + 0.8;
}

public 
Event_TankKilled(Handle:event, const String:name[], bool:dontBroadcast)
{
    
tankCount--;
}

stock IsLookingAtBreakableDoor(clientFloat:direction[3])
{
    new 
target GetClientAimTarget(clientfalse);
    
    if(
target 0)
    {
        
decl String:entName[MAX_NAME_LENGTH];
        
        
GetEntityClassname(targetentNamesizeof(entName));
        
        if(
StrContains(entName"prop_door_rotating") != -1
        {
            
//Compare distances, i.e. "is in range to destroy the door"
            
decl Float:clientPos[3];
            
decl Float:doorPos[3];
            
            
GetClientAbsOrigin(clientclientPos);
            
GetEntPropVector(targetProp_Send"m_vecOrigin"doorPos);
            
//90.0
            
if(GetVectorDistance(clientPosdoorPos) <= 90.0)
            {
                
SubtractVectors(doorPosclientPosdirection);
                return 
target;
            }
            else
            {
                return -
2;
            }
        }
        else
        {
            return 
0;
        }
    }
    else
    {
        return -
1;
    }


Last edited by Captain Stubin; 12-18-2018 at 06:03.
Captain Stubin is offline
Captain Stubin
Member
Join Date: Jun 2017
Old 12-18-2018 , 06:05   Re: [L4D2] TankDoorFix
Reply With Quote #2

here is that there is with freezer that need put or add ?
PHP Code:
models/props_doors/doorfreezer01.mdl
models
/props/cs_militia/refrigerator01.mdl
models
/props_interiors/refrigerator02_freezerdoor.mdl
models
/props_interiors/refrigerator02_lowerdoor.mdl
models
/props_interiors/refrigerator02_main.mdl
models
/props_interiors/refrigerator03.mdl
models
/props_interiors/refrigerator03_damaged_01.mdl
models
/props_interiors/refrigerator03_damaged_02.mdl
models
/props_interiors/refrigerator03_damaged_03.mdl
models
/props_interiors/refrigerator03_damaged_04.mdl
models
/props_interiors/refrigerator03_damaged_05.mdl
models
/props_interiors/refrigerator03_damaged_06.mdl
models
/props_interiors/refrigerator03_damaged_07.mdl
models
/props_interiors/refrigerator_industrial01.mdl 
Captain Stubin 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 08:28.


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