Raised This Month: $29 Target: $400
 7% 

After Taunt


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ApoziX
Member
Join Date: Sep 2018
Old 12-25-2019 , 19:57   After Taunt
Reply With Quote #1

Crits being applied after taunt I want it to be only for ADMFLAG_CUSTOM6 Thanks for helpers+rep
PHP Code:
// http://steamcommunity.com/id/heme3ic it is my steamid, feel free to contact me if something important happened.

#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>

#define NULL_VALUE 9001
#define upgr_default "16-33"
#define status_taunting 1
#define status_taunting_upgr 2
#define status_finished 3
#define status_finished_upgr 4
#define status_interrupted 42



#define PLUGIN_VERSION "2.1"

public Plugin:myinfo 
{
    
name "Taunt Crits",
    
author "HeMe3iC",
    
description "Crits(or another award) for few seconds after taunting.",
    
version PLUGIN_VERSION,
    
url ""
};

new 
Handle:cvarVersion;
new 
Handle:cvarScout;
new 
Handle:cvarSoldier;
new 
Handle:cvarPyro;
new 
Handle:cvarDemoman;
new 
Handle:cvarHeavy;
new 
Handle:cvarEngineer;
new 
Handle:cvarMedic;
new 
Handle:cvarSniper;
new 
Handle:cvarSpy;
new 
Handle:cvarAward;
new 
Handle:cvarSwitch;
new 
Handle:cvarNotify;
new 
Handle:cvarHPcheck;
new 
Handle:cvarBuffUpg;

new 
Float:g_Scout;
new 
Float:g_Soldier;
new 
Float:g_Pyro;
new 
Float:g_Demoman;
new 
Float:g_Heavy;
new 
Float:g_Engineer;
new 
Float:g_Medic;
new 
Float:g_Sniper;
new 
Float:g_Spy;
new 
g_Mode;
//new g_cFlags[34];
//new g_Ticks[34];
new bool:g_bSwitch;
new 
Float:g_Notify;
new 
bool:g_bHPcheck;
new 
g_iPlayers[34][2];//[client][0-userid 1-status]

//weapons list can be found here: http://forums.alliedmods.net/showthread.php?p=1337899 (TF2 Give Weapon plugin)
new NoAwardWeapons[64]={42,46,159,163,311,433,NULL_VALUE}; //scout bonk(46) and cola(163) and HWG food
//open tf\addons\sourcemod\scripting\include\tf2.inc for TFConds list
new TFCond:NoAwardConds[64]={TFCond_BonkedTFCond_Dazed,TFCond:NULL_VALUE};

public 
OnPluginStart()
{
    
cvarVersion CreateConVar("tauntcrits_version","","Plugin version");
    
SetConVarString(cvarVersion,PLUGIN_VERSION);

    
cvarScout CreateConVar("tauntcrits_scout","2.0","Award duration(after finishing the taunt) for scout",_,true,0.00,true,360.00);
    
cvarSoldier CreateConVar("tauntcrits_soldier","1.4","Award duration(after finishing the taunt) for soldier",_,true,0.00,true,360.00);
    
cvarPyro CreateConVar("tauntcrits_pyro","1.8","Award duration(after finishing the taunt) for pyro",_,true,0.00,true,360.00);
    
cvarDemoman CreateConVar("tauntcrits_demoman","1.5","Award duration(after finishing the taunt) for demoman",_,true,0.00,true,360.00);
    
cvarHeavy CreateConVar("tauntcrits_heavy","2.0","Award duration(after finishing the taunt) for heavy",_,true,0.00,true,360.00);
    
cvarEngineer CreateConVar("tauntcrits_engineer","2","Award duration(after finishing the taunt) for engineer",_,true,0.00,true,360.00);
    
cvarMedic CreateConVar("tauntcrits_medic","2.0","Award duration(after finishing the taunt) for medic",_,true,0.00,true,360.00);
    
cvarSniper CreateConVar("tauntcrits_sniper","1.1","Award duration(after finishing the taunt) for sniper",_,true,0.00,true,360.00);
    
cvarSpy CreateConVar("tauntcrits_spy","2.0","Award duration(after finishing the taunt) for spy",_,true,0.00,true,360.00);
    
cvarAward CreateConVar("tauntcrits_award","1.0","Award for taunting. 1=crits 2=mini-crits 3=ubercharge 4=upgradable buff",_,true,1.0,true,4.0);
    
cvarSwitch CreateConVar("tauntcrits_switch","1.0","Taunt Crits plugin status  0.0=off else on",_,true,0.0,true,1.0);
    
cvarNotify CreateConVar("tauntcrits_notify","600.0","Delay between notifcations in chat about this plugin. 0.0=off ",_,true,0.0,true,2048.0);
    
cvarHPcheck CreateConVar("tauntcrits_hpcheck","1.0","Whether to check target hp or not.  If the targets max health(m_iMaxHealth) is below 500 then there will be no award for target. Useful for plugins like VS Saxton Hale.0.0=off else on",_,true,0.0,true,1.0);
    
cvarBuffUpg CreateConVar("tauntcrits_buffupgr","0","Two condition numbers with '-' between them, first condition will be upgraded to the second on taunt if tauntcrits_award==4; If is equal to 0 it will upgrade from minicrits to full crits(16-33). ");
    
    
    
HookConVarChange(cvarScoutCvarChange);
    
HookConVarChange(cvarSoldierCvarChange);
    
HookConVarChange(cvarPyroCvarChange);
    
HookConVarChange(cvarDemomanCvarChange);
    
HookConVarChange(cvarHeavyCvarChange);
    
HookConVarChange(cvarEngineerCvarChange);
    
HookConVarChange(cvarMedicCvarChange);
    
HookConVarChange(cvarSniperCvarChange);
    
HookConVarChange(cvarSpyCvarChange);
    
HookConVarChange(cvarAwardCvarChange);
    
HookConVarChange(cvarSwitchCvarChange);
    
HookConVarChange(cvarNotifyCvarChange);
    
HookConVarChange(cvarHPcheckCvarChange);

    
HookEvent("player_hurt"Event_PlayerHurt);
    
HookEvent("object_deflected"Event_DeflectedEventHookMode_Pre);

    
    
RegConsoleCmd("tauntcrits_help"help);
    
RegConsoleCmd("tauntcrits_info"help);
    
    
readCvars();
}

public 
OnMapStart()
{
    if (
g_Notify>0.0)
        
CreateTimer(g_NotifyChatNotify,_,TIMER_FLAG_NO_MAPCHANGE);
    else
        
CreateTimer(3.0ChatNotify,_,TIMER_FLAG_NO_MAPCHANGE);
}


public 
TF2_OnConditionAdded(clientTFCond:condition){ //detecting taunt start
    
if(g_bSwitch && condition==TFCond_Taunting){

        if(
g_Mode==4){
            
decl cond[2];
            
GetCondNums(cond);
            if(
TF2_IsPlayerInCondition(clientTFCond:cond[0]) || TF2_IsPlayerInCondition(clientTFCond:cond[1]))
                
g_iPlayers[client][1]=status_taunting_upgr;
            else
                
g_iPlayers[client][1]=status_taunting;
        }
        else
            
g_iPlayers[client][1]=status_taunting
        
CreateTimer(0.5CheckCond,client,TIMER_FLAG_NO_MAPCHANGE);
    }
}
public 
Action:CheckCond(Handle:hTimerany:client){//checking if player still taunting. If player slides over the edge taont condition stiil will be added and removed.
    
if(TF2_IsPlayerInCondition(clientTFCond_Taunting)){
        if(
g_iPlayers[client][1]==status_taunting){
            
g_iPlayers[client][1]=status_finished;}
        else if(
g_iPlayers[client][1]==status_taunting_upgr){
            
g_iPlayers[client][1]=status_finished_upgr;}
    }
    else
        
g_iPlayers[client][1]=status_interrupted;
}

public 
TF2_OnConditionRemoved(clientTFCond:condition){ //detecting taunt end
    
if(condition==TFCond_Taunting && (g_iPlayers[client][1]==status_finished_upgr || g_iPlayers[client][1]==status_finished) && IsValidEdict(client) && IsClientInGame(client) && IsPlayerAlive(client)){
        
Award(client);
        
g_iPlayers[client][1]=0
    }
}

public 
Action:Award(client)
{
    if(
CheckCommandAccess(client"sm_vip"ADMFLAG_CUSTOM6))
    {
    if (!(
client && IsValidEdict(client) &&  IsClientInGame(client) && IsPlayerAlive(client) && (GetEntProp(clientProp_Data"m_iMaxHealth")<500|| !g_bHPcheck)))
        return 
Plugin_Stop;

    new 
Float:dur=2.0;
    new class=
int:TF2_GetPlayerClass(client);
    switch(class)
    {
        case 
TFClass_Scout:
            
dur=g_Scout;
        case 
TFClass_Soldier:
            
dur=g_Soldier
        case 
TFClass_Pyro:
            
dur=g_Pyro
        case 
TFClass_DemoMan:
            
dur=g_Demoman
        case 
TFClass_Heavy:
            
dur=g_Heavy
        case 
TFClass_Engineer:
            
dur=g_Engineer
        case 
TFClass_Medic:
            
dur=g_Medic
        case 
TFClass_Sniper:
            
dur=g_Sniper
        case 
TFClass_Spy:
            
dur=g_Spy
    }
    
    if (
dur>0.0 && ValidConds(client) && ValidWeapons(client))
    {
        switch(
g_Mode)
        {
            case 
1:        
                
TF2_AddCondition(clientTFCond_HalloweenCritCandydur);
            case 
2:
                
TF2_AddCondition(clientTFCond_Buffeddur);
            case 
3:
                
TF2_AddCondition(clientTFCond_Uberchargeddur);
            case 
4:{
                
decl cond[2];
                
GetCondNums(cond);
                
UpgradeBuff(client,dur,cond[0],cond[1]);
                }
            default:
                
LogMessage("TauntCrits ERROR: g_Mode have a wrong value. It never really was on your side.Ahem.");
        }
    }
    }
    
    return 
Plugin_Stop;
}
UpgradeBuff(client,Float:dur,CondA,CondB){//for tauntcrits_award == 4
    
if(g_iPlayers[client][1]==status_finished_upgr)
        
TF2_AddCondition(clientTFCond:CondBdur);
    else if(
g_iPlayers[client][1]==status_finished)
        
TF2_AddCondition(clientTFCond:CondA,dur);
}

/////////////////////////////////////////////////
///////////////ADDITIONAL FUNCIONS///////////////
/////////////////////////////////////////////////
public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    
    new 
client=GetClientOfUserId(GetEventInt(event"userid"));
    
//PrintToChat(client,"dmg taken status=%i",g_iPlayers[client][1]);
    
if(g_iPlayers[client][1]!=0)
    {
        
//PrintToChat(client,"interrupted by dmg");
        
g_iPlayers[client][1]=status_interrupted;
    }
}
public 
Event_Deflected(Handle:event, const String:name[], bool:dontBroadcast){
    new 
client=GetClientOfUserId(GetEventInt(event"ownerid"));
    if(
GetEventInt(event"weaponid")==&& g_iPlayers[client][1]!=0)
        
g_iPlayers[client][1]=status_interrupted;
}
public 
Action:help(clientargs)
{
    
decl String:award[64];
    switch(
g_Mode)
    {
        case 
1:        
            
award="crits";
        case 
2:
            
award="mini-crits";
        case 
3:
            
award="ubercharge";
        case 
4:{
            
decl String:s[8];
            
decl String:s2[3][3];
            
GetConVarString(cvarBuffUpg,s,8);
            if(
StrEqual(s,"0")){
                
award="mini-crits, upgradable to full crits";}
            else{
                
ExplodeString(s"-"s23,3);
                
Format(award64"upgradable conds '%s-%s'",s2[0],s2[1]);
                }
            }
        default:
            
award="nothing. Someone broke the plugin.";
    }
    
decl String:status[10];
    if(
g_bSwitch)
        
status="enabled";
    else
        
status="disabled";

    
PrintToConsole(client"############################");
    
PrintToConsole(client"       Taunt Crits info     ");
    
PrintToConsole(client"############################");
    
PrintToConsole(client"Plugin version:%s",PLUGIN_VERSION);
    
PrintToConsole(client"Plugin status:%s",status);
    
PrintToConsole(client"Award:%s",award);
    
PrintToConsole(client"Durations:");
    
PrintToConsole(client"     Scout:%f, Soldier:%f, Pyro:%f",g_Scout,g_Soldier,g_Pyro);
    
PrintToConsole(client"     Demoman:%f, Heavy:%f, Engineer:%f",g_Demoman,g_Heavy,g_Engineer);
    
PrintToConsole(client"     Medic:%f, Sniper:%f, Spy:%f",g_Medic,g_Sniper,g_Spy);
    
PrintToConsole(client"cvar list: tauntcrits_[classname], tauntcrits_award, tauntcrits_switch, tauntcrits_notify, tauntcrits_hpcheck, tauntcrits_buffupgr");
    
PrintToConsole(client"############################");
}

public 
CvarChange(Handle:convar, const String:oldValue[], const String:newValue[]){
    if (
convar==cvarScout)
        
g_Scout=StringToFloat(newValue);
        
    if (
convar==cvarSoldier)
        
g_Soldier=StringToFloat(newValue);
    
    if (
convar==cvarPyro)
        
g_Pyro=StringToFloat(newValue); 
    
    if (
convar==cvarDemoman)
        
g_Demoman=StringToFloat(newValue); 
    
    if (
convar==cvarHeavy)
        
g_Heavy=StringToFloat(newValue); 
    
    if (
convar==cvarEngineer)
        
g_Engineer=StringToFloat(newValue); 
    
    if (
convar==cvarMedic)
        
g_Medic=StringToFloat(newValue); 
    
    if (
convar==cvarSniper)
        
g_Sniper=StringToFloat(newValue); 
    
    if (
convar==cvarSpy)
        
g_Spy=StringToFloat(newValue);
    
    if (
convar==cvarAward)
    {     
        if(
StringToInt(newValue)!=&& StringToInt(newValue)!=&& StringToInt(newValue)!=&& StringToInt(newValue)!=4
        {
            
SetConVarInt(convar,StringToInt(oldValue));
            
LogMessage("tauntcrits_award set to wrong value. Changing it back to %i..",StringToInt(oldValue));//im not sure it can happen at all, but...
            
g_Mode=StringToInt(oldValue);
        }
        else {
            
g_Mode=StringToInt(newValue);
        }
    }
    if (
convar==cvarSwitch)
    { 
        if(
StringToFloat(newValue)==0.0)
            
g_bSwitch=bool:false;
        else 
            
g_bSwitch=bool:true;
    }
    
    if (
convar==cvarNotify)
        
g_Notify=StringToFloat(newValue);
    
    if (
convar==cvarHPcheck)
    { 
        if(
StringToFloat(newValue)==0.0)
            
g_bHPcheck=bool:false;
        else
            
g_bHPcheck=bool:true;
    }
}

readCvars()
{
    
g_Scout=GetConVarFloat(cvarScout);
    
g_Soldier=GetConVarFloat(cvarSoldier);
    
g_Pyro=GetConVarFloat(cvarPyro); 
    
g_Demoman=GetConVarFloat(cvarDemoman); 
    
g_Heavy=GetConVarFloat(cvarHeavy);
    
g_Engineer=GetConVarFloat(cvarEngineer);
    
g_Medic=GetConVarFloat(cvarMedic);     
    
g_Sniper=GetConVarFloat(cvarSniper);
    
g_Spy=GetConVarFloat(cvarSpy);
    
g_Mode=GetConVarInt(cvarAward);
    
g_bSwitch=GetConVarBool(cvarSwitch);
    
g_Notify=GetConVarFloat(cvarNotify);
    
g_bHPcheck=GetConVarBool(cvarHPcheck);
}
public 
Action:ChatNotify(Handle:timer)
{
    if (
g_Notify>0.0 && g_bSwitch)
    {
        
decl String:award[64];
        switch(
g_Mode)
            {
                case 
1:        
                    
award="crits";
                case 
2:
                    
award="mini-crits";
                case 
3:
                    
award="ubercharge";
                case 
4:{
                    
decl String:s[8];
                    
decl String:s2[3][3];
                    
GetConVarString(cvarBuffUpg,s,8);
                    if(
StrEqual(s,"0")){
                        
award="mini-crits, upgradable to full crits";}
                    else{
                        
ExplodeString(s"-"s23,3);
                        
Format(award64"upgradable conds '%s-%s'",s2[0],s2[1]);
                        }
                    }
                default:
                    
award="nothing. Someone broke the plugin.";
            }
        
PrintToChatAll("[Taunt Crits] Taunting will be awarded with few seconds of %s",award);
        
CreateTimer(g_NotifyChatNotify,_,TIMER_FLAG_NO_MAPCHANGE);
        return 
Plugin_Stop;
    }
    else
    {
        
CreateTimer(3.0ChatNotify,_,TIMER_FLAG_NO_MAPCHANGE); //timer idle mode
        
return Plugin_Stop;
    }
}

/////////////////////////////////////////////////
///////////////PROCESSING FUNCIONS///////////////
/////////////////////////////////////////////////

GetCondNums(output[2]){
    
decl String:s[8];
    
GetConVarString(cvarBuffUpg,s,8);
    if(
StrEqual(s,"0"))
        
s=upgr_default;
    
decl String:s2[3][3];
    
ExplodeString(s"-"s23,3);
    
output[0]=StringToInt(s2[0]); output[1]=StringToInt(s2[1]);
}

stock bool:ValidConds(client)
{
    for (new 
i=0;i<=64;i++)
    {
        if (
NoAwardConds[i]==TFCond:NULL_VALUE)
            return 
bool:true;
        if (
TF2_IsPlayerInCondition(clientNoAwardConds[i]))
            return 
bool:false;
    }
    return 
bool:true;
}

stock bool:ValidWeapons(client)
{    
    if (!(
client && IsValidEdict(client) && IsClientInGame(client) && IsPlayerAlive(client)))
        return 
bool:false;
        
    new 
weaponent=GetEntPropEnt(clientProp_Send"m_hActiveWeapon");
    if (!(
weaponentMaxClients && IsValidEdict(weaponent)))
        return 
bool:false;
        
    new 
weaponind=GetEntProp(weaponentProp_Send"m_iItemDefinitionIndex");
    for (new 
i=0;i<=64;i++)
    {
        if (
NoAwardWeapons[i]==NULL_VALUE)
            return 
bool:true;
        if (
weaponind == NoAwardWeapons[i])
            return 
bool:false;
    }
    return 
bool:true;
}

////taunt interrupted 
__________________
Looking To Start A TF2 Community
My Discord | My Steam
ApoziX 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 23:19.


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