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

[L4D2] Register extra Actions on GameME plugin


Post New Thread Reply   
 
Thread Tools Display Modes
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 10-28-2016 , 19:47   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #11

Quote:
Originally Posted by cravenge View Post
Don't worry about the loose indentations
Well, instead of just telling him not to worry about it, you better tell him how to fix it and what it means.

Read this quickly and you'll understand how to fix and what the warning basically means: https://wiki.alliedmods.net/Scriptin...on_warnings.3F
__________________
xines is offline
diorfo
Member
Join Date: Dec 2013
Old 10-28-2016 , 23:41   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #12

Quote:
Originally Posted by cravenge View Post
Don't worry about the loose indentations but for the SetEventString, just change inflictor to "charger_claw" (with quotes).
It works!

You are really good on that!

Thank you very much!

PS: I noticed it's not triggering player death.

To make it, it's only add player_death event right after player_incapacited event, right?

I make it but in game appeared that i killed survivor with car but didn't compute the death on rank (seems to me bug on game/rank)

PHP Code:

        
new Handle:OnPlayerIncapacitated CreateEvent("player_incapacitated"true); 
        
SetEventInt(OnPlayerIncapacitated"userid"GetClientUserId(client)); 
        
SetEventInt(OnPlayerIncapacitated"attacker"GetClientUserId(attacker)); 
        
FireEvent(OnPlayerIncapacitatedfalse); 

        new 
Handle:OnPlayerDeath CreateEvent("player_death"true); 
        
SetEventInt(OnPlayerDeath"userid"GetClientUserId(client)); 
        
SetEventInt(OnPlayerDeath"attacker"GetClientUserId(attacker)); 
        
FireEvent(OnPlayerDeathfalse); 

Last edited by diorfo; 10-28-2016 at 23:46.
diorfo is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 10-29-2016 , 01:16   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #13

That's because the timer I created checks only for alive players, so creating the "player_death" event would make the game detect that it's just falsed. What it needs is an alteration of the timer.

PHP Code:
#pragma semicolon 1 
#include <sourcemod> 
#include <sdktools> 
#include <sdkhooks> 

#define PLUGIN_VERSION "1.2" 

#define TEAM_INFECTED 3 
#define CLASS_CHARGER 6 

#define PROP_CAR (1<<0) 
#define PROP_CAR_ALARM (1<<1) 
#define PROP_CONTAINER (1<<2) 
#define PROP_TRUCK (1<<3) 

#define PUSH_COUNT "m_iHealth" 

new Handle:g_h_CvarChargerPowerHandle:g_h_CvarChargerCarryHandle:g_h_CvarMessageTypeHandle:g_h_CvarObjectsHandle:g_h_CvarPushLimitHandle:g_h_CvarRemoveObject
    
Handle:g_h_CvarChargerDamage
        
i_Owner[2048+1]; // to store the entities' owner

new bool:incapChecked[MAXPLAYERS+1];

public 
Plugin:myinfo =  

    
name "[L4D2] Super Charge"
    
author "DJ_WEST, cravenge"
    
description "Provides Chargers To Move Cars With Ability."
    
version PLUGIN_VERSION
    
url "http://amx-x.ru" 
}; 

public 
OnPluginStart() 

    
decl String:s_Game[12], Handle:h_Version
     
    
GetGameFolderName(s_Gamesizeof(s_Game)); 
    if (!
StrEqual(s_Game"left4dead2")) 
    { 
        
SetFailState("[SM] Plugin Supports L4D2 Only!"); 
    } 
     
    
LoadTranslations("super_charge-l4d2.phrases"); 
     
    
h_Version CreateConVar("super_charge-l4d2_version"PLUGIN_VERSION"Super Charge Version"FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY); 
    
g_h_CvarChargerPower CreateConVar("super_charge-l4d2""750.0""Power Applied To Super Charge"FCVAR_NOTIFYtrue0.0true5000.0); 
    
g_h_CvarChargerCarry CreateConVar("super_charge-l4d2_carry""1""Enable/Disable Super Charge If Carrying"FCVAR_NOTIFYtrue0.0true1.0); 
    
g_h_CvarMessageType CreateConVar("super_charge-l4d2_message_type""3""Notification Type: 0=Disable, 1=Chat Text, 2=Hint Box, 3=Instructor Hint"FCVAR_NOTIFYtrue0.0true3.0); 
    
g_h_CvarObjects CreateConVar("super_charge-l4d2_objects""7""Objects: 1=Cars, 2=Car Alarms, 4=Containers, 8=Truck"FCVAR_NOTIFYtrue1.0true15.0); 
    
g_h_CvarPushLimit CreateConVar("super_charge-l4d2_push_limit""10""Super Charge Push Limit"FCVAR_NOTIFYtrue1.0true100.0); 
    
g_h_CvarRemoveObject CreateConVar("super_charge-l4d2_remove""30""Delay Before Charged Objects Disappear"FCVAR_NOTIFYtrue0.0true100.0); 
    
g_h_CvarChargerDamage CreateConVar("super_charge-l4d2_damage""10""Damage Applied To Charger"FCVAR_NOTIFYtrue0.0true100.0); 

    
HookEvent("charger_charge_end"OnChargerChargeEnd); 
    
HookEvent("player_spawn"OnPlayerSpawn); 
     
    
SetConVarString(h_VersionPLUGIN_VERSION); 


public 
OnClientPostAdminCheck(client

    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage); // Gotcha, damage!! 
}

public 
OnMapStart()
{
    for (new 
1<= MaxClientsi++)
    {
          if (
IsClientInGame(i))
          {
                
incapChecked[i] = false// reset the check so the event can be created and fired again.
          
}
    }
}

public 
Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damageType

    if (
victim <= || victim MaxClients || !IsClientInGame(victim) || GetClientTeam(victim) != || !IsPlayerAlive(victim)) 
    { 
        return 
Plugin_Continue
    } 
     
    if (
inflictor <= || !IsValidEntity(inflictor) || !IsValidEdict(inflictor)) 
    { 
        return 
Plugin_Continue
    } 
     
    
decl String:sClass[64]; 
    
GetEdictClassname(inflictorsClasssizeof(sClass)); 
    if (
StrEqual(sClass"prop_physics") || StrEqual(sClass"prop_car_alarm")) 
    { 
        new 
charger CheckForChargers(); 
        if (
i_Owner[inflictor] == charger// since the game never makes the charger the attacker, we force it to do so. 
        

              new 
realDmg RoundToZero(damage); // we convert the damage from float to int.
              
              
new Handle:stateFix CreateDataPack(); 
              
WritePackCell(stateFixGetClientUserId(victim)); 
              
WritePackCell(stateFixGetClientUserId(charger));
              
WritePackCell(stateFixrealDmg);
              
CreateTimer(1.0CheckForStatesstateFixTIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT|TIMER_DATA_HNDL_CLOSE); // we create a repeating timer to check the victim's state, if this returns errors, just use CreateDataTimer instead.
              
              
return Plugin_Changed
        } 
    } 
     
    return 
Plugin_Continue


public 
Action:CheckForIncaps(Handle:timerHandle:stateFix

        
ResetPack(stateFix); 
         
        new 
client GetClientOfUserId(ReadPackCell(stateFix)); 
        if (
client <= || !IsClientInGame(client) || GetClientTeam(client) != 2
        { 
                return 
Plugin_Continue
        } 
         
        new 
attacker GetClientOfUserId(ReadPackCell(stateFix)); 
        if (
attacker <= || !IsClientInGame(attacker) || GetClientTeam(attacker) != TEAM_INFECTED || GetEntProp(attackerProp_Send"m_zombieClass") != CLASS_CHARGER
        { 
                return 
Plugin_Continue
        } 
        
        new 
dmgTaken ReadPackCell(stateFix);
        
        if (
IsPlayerAlive(client)) // if the player's still alive, apply damage and if incapacitated, create and fire the event
        
{
                new 
Handle:OnPlayerHurt CreateEvent("player_hurt"true); 
                
SetEventInt(OnPlayerHurt"userid"GetClientUserId(client)); 
                
SetEventInt(OnPlayerHurt"attacker"GetClientUserId(attacker)); 
                
SetEventInt(OnPlayerHurt"dmg_health"dmgTaken);
                
SetEventString(OnPlayerHurt"weapon""charger_claw");
                
FireEvent(OnPlayerHurtfalse);
                if (
IsPlayerIncapped(client) && !incapChecked[client]) // to prevent from firing the event all over again.
                
{
                        new 
Handle:OnPlayerIncapacitated CreateEvent("player_incapacitated"true); 
                        
SetEventInt(OnPlayerIncapacitated"userid"GetClientUserId(client)); 
                        
SetEventInt(OnPlayerIncapacitated"attacker"GetClientUserId(attacker)); 
                        
FireEvent(OnPlayerIncapacitatedfalse);
                        
                        
incapChecked[client] = true;
                }
        }
        else 
// if player died after being hit, create and fire the appropriate event.
        
{
                new 
Handle:OnPlayerDeath CreateEvent("player_death"true); 
                
SetEventInt(OnPlayerDeath"userid"GetClientUserId(client)); 
                
SetEventInt(OnPlayerDeath"attacker"GetClientUserId(attacker)); 
                
FireEvent(OnPlayerDeathfalse);
        }
        return 
Plugin_Stop


CheckForChargers() 

        new 
count 0
        for (new 
1<= MaxClientsi++) 
        { 
                if (
IsClientInGame(i) && GetClientTeam(i) == TEAM_INFECTED && GetEntProp(iProp_Send"m_zombieClass") == CLASS_CHARGER
                { 
                        
count++; 
                } 
        } 
        return 
count


stock bool:IsPlayerIncapped(client

        if (
GetEntProp(clientProp_Send"m_isIncapacitated"1)) 
        { 
                return 
true
        } 
        return 
false


public 
Action:OnChargerChargeEnd(Handle:h_Event, const String:s_Name[], bool:b_DontBroadcast

    
decl i_UserIDi_ClientFloat:f_Origin[3], Float:f_Angles[3], Float:f_EndOrigin[3], Float:f_Velocity[3], 
        
Handle:h_TraceHandle:h_Packi_TargetString:s_ClassName[16], Float:f_PowerString:s_ModelName[64], 
        
i_Typei_PushCounti_Healthi_Damagei_RemoveTime
     
    
i_UserID GetEventInt(h_Event"userid"); 
    
i_Client GetClientOfUserId(i_UserID); 
    if (!
i_Client || !IsClientInGame(i_Client) || GetClientTeam(i_Client) != || GetInfectedClass(i_Client) != CLASS_CHARGER
    { 
        return 
Plugin_Continue
    } 
     
    if (!
GetConVarInt(g_h_CvarChargerCarry) && GetEntProp(i_ClientProp_Send"m_carryVictim") > 0
    { 
        return 
Plugin_Continue
    } 
     
    
GetClientAbsOrigin(i_Clientf_Origin); 
    
GetClientAbsAngles(i_Clientf_Angles); 
    
f_Origin[2] += 20.0
     
    
h_Trace TR_TraceRayFilterEx(f_Originf_AnglesMASK_ALLRayType_InfiniteTraceFilterClientsi_Client); 
     
    if (
TR_DidHit(h_Trace)) 
    { 
        
i_Target TR_GetEntityIndex(h_Trace); 
        
TR_GetEndPosition(f_EndOriginh_Trace); 
         
        if (
i_Target && IsValidEdict(i_Target) && GetVectorDistance(f_Originf_EndOrigin) <= 100.0
        { 
            if (
GetEntityMoveType(i_Target) != MOVETYPE_VPHYSICS
            { 
                return 
Plugin_Continue
            } 
             
            
i_PushCount GetEntProp(i_TargetProp_DataPUSH_COUNT); 
            if (
i_PushCount >= GetConVarInt(g_h_CvarPushLimit)) 
            { 
                return 
Plugin_Continue
            } 
             
            
i_Type GetConVarInt(g_h_CvarObjects); 
             
            
GetEdictClassname(i_Targets_ClassNamesizeof(s_ClassName)); 
            
GetEntPropString(i_TargetProp_Data"m_ModelName"s_ModelNamesizeof(s_ModelName)); 
             
            if(
StrEqual(s_ClassName"prop_car_alarm") && !(i_Type PROP_CAR_ALARM)) 
            { 
                return 
Plugin_Continue
            } 
            else if (
StrEqual(s_ClassName"prop_physics")) 
            { 
                if ((
StrContains(s_ModelName"car") != -&& !(i_Type PROP_CAR) && !(i_Type PROP_CAR_ALARM)) || (StrContains(s_ModelName"dumpster") != -&& !(i_Type PROP_CONTAINER)) || (StrContains(s_ModelName"forklift") != -&& !(i_Type PROP_TRUCK))) 
                { 
                    return 
Plugin_Continue
                } 
            } 
             
            
i_PushCount++; 
            
SetEntProp(i_TargetProp_DataPUSH_COUNTi_PushCount); 
             
            
GetAngleVectors(f_Anglesf_VelocityNULL_VECTORNULL_VECTOR); 
                         
            
f_Power GetConVarFloat(g_h_CvarChargerPower); 
            
f_Velocity[0] *= f_Power
            
f_Velocity[1] *= f_Power
            
f_Velocity[2] *= f_Power
                         
            
TeleportEntity(i_TargetNULL_VECTORNULL_VECTORf_Velocity); 
                         
                        
i_Owner[i_Target] = i_Client// make the charger the owner of the entity. 
                        
CreateTimer(3.0ResetOwneri_Target); // reset the entity's owner. 
             
            
h_Pack CreateDataPack(); 
            
WritePackCell(h_Packi_Target); 
            
WritePackFloat(h_Packf_EndOrigin[0]); 
            
CreateTimer(0.5CheckEntityh_Pack); 
             
            
i_Damage GetConVarInt(g_h_CvarChargerDamage); 
            if (
i_Damage
            { 
                
i_Health GetClientHealth(i_Client); 
                
i_Health -= i_Damage
                if (
i_Health 0)  
                { 
                    
SetEntityHealth(i_Clienti_Health); 
                } 
                else 
                { 
                    
ForcePlayerSuicide(i_Client); 
                } 
            } 
             
            
i_RemoveTime GetConVarInt(g_h_CvarRemoveObject); 
            if (
i_RemoveTime
            { 
                
CreateTimer(float(i_RemoveTime), RemoveEntityi_TargetTIMER_FLAG_NO_MAPCHANGE); 
            } 
        } 
    } 
     
    return 
Plugin_Continue


public 
Action:ResetOwner(Handle:timerany:ent

        
i_Owner[ent] = 0// no matter if said entity was removed, just reset its owner to prevent bugs. 
        
return Plugin_Stop


public 
Action:RemoveEntity(Handle:h_Timerany:i_Ent

    if (
i_Ent && IsValidEnt(i_Ent)) 
    { 
        
RemoveEdict(i_Ent); 
    } 
     
    return 
Plugin_Stop


public 
bool:TraceFilterClients(i_Entityi_Maskany:i_Data

    if (
i_Entity == i_Data
    { 
        return 
false
    } 
     
    if (
<= i_Entity <= MaxClients
    { 
        return 
false
    } 
     
    return 
true


public 
Action:CheckEntity(Handle:h_TimerHandle:h_Pack

    
decl i_EntFloat:f_Origin[3], Float:f_LastOriginHandle:h_NewPack
     
    
ResetPack(h_Packfalse); 
    
i_Ent ReadPackCell(h_Pack); 
    
f_LastOrigin ReadPackFloat(h_Pack); 
    
CloseHandle(h_Pack); 
     
    if (
i_Ent && IsValidEnt(i_Ent)) 
    { 
        
GetEntPropVector(i_EntProp_Data"m_vecOrigin"f_Origin); 
         
        if (
f_Origin[0] != f_LastOrigin
        { 
            
h_NewPack CreateDataPack(); 
            
WritePackCell(h_NewPacki_Ent); 
            
WritePackFloat(h_NewPackf_Origin[0]); 
            
CreateTimer(0.1CheckEntityh_NewPack); 
        } 
        else 
        { 
            
TeleportEntity(i_EntNULL_VECTORNULL_VECTORFloat:{0.00.00.0}); 
        } 
    } 
     
    return 
Plugin_Stop


public 
Action:OnPlayerSpawn(Handle:h_Event, const String:s_Name[], bool:b_DontBroadcast

    
decl i_UserIDi_ClientHandle:h_Pack
     
    
i_UserID GetEventInt(h_Event"userid"); 
    
i_Client GetClientOfUserId(i_UserID); 
    if (
i_Client && IsClientInGame(i_Client) && GetClientTeam(i_Client) == TEAM_INFECTED && GetInfectedClass(i_Client) == CLASS_CHARGER  && !IsFakeClient(i_Client)) 
    { 
        
h_Pack CreateDataPack(); 
        
WritePackCell(h_Packi_Client); 
        
WritePackString(h_Pack"Move objects"); 
        
WritePackString(h_Pack"+attack"); 
        
CreateTimer(0.1DisplayHinth_Pack); 
    } 


public 
Action:DisplayHint(Handle:h_TimerHandle:h_Pack

    
decl i_Client
     
    
ResetPack(h_Packfalse); 
    
i_Client ReadPackCell(h_Pack); 
     
    if (
GetConVarInt(g_h_CvarMessageType) == && IsClientInGame(i_Client)) 
    { 
        
ClientCommand(i_Client"gameinstructor_enable 1"); 
    } 
     
    
CreateTimer(0.3DelayDisplayHinth_Pack); 
     
    return 
Plugin_Stop


public 
Action:DelayDisplayHint(Handle:h_TimerHandle:h_Pack

    
decl i_ClientString:s_LanguageKey[16], String:s_Message[256], String:s_Bind[10]; 

    
ResetPack(h_Packfalse); 
    
i_Client ReadPackCell(h_Pack); 
    
ReadPackString(h_Packs_LanguageKeysizeof(s_LanguageKey)); 
    
ReadPackString(h_Packs_Bindsizeof(s_Bind)); 
    
CloseHandle(h_Pack); 
     
    switch (
GetConVarInt(g_h_CvarMessageType)) 
    { 
        case 
1
        { 
            
FormatEx(s_Messagesizeof(s_Message), "\x03[%t]\x01 %t.""Information"s_LanguageKey); 
            
ReplaceString(s_Messagesizeof(s_Message), "\n"" "); 
            
PrintToChat(i_Clients_Message); 
        } 
        case 
2PrintHintText(i_Client"%t"s_LanguageKey); 
        case 
3
        { 
            
FormatEx(s_Messagesizeof(s_Message), "%t"s_LanguageKey); 
            
DisplayInstructorHint(i_Clients_Messages_Bind); 
        } 
    } 
     
    return 
Plugin_Stop


public 
DisplayInstructorHint(i_ClientString:s_Message[256], String:s_Bind[]) 

    
decl i_EntString:s_TargetName[32], Handle:h_RemovePack
     
    
i_Ent CreateEntityByName("env_instructor_hint"); 
    
FormatEx(s_TargetNamesizeof(s_TargetName), "hint%d"i_Client); 
    
ReplaceString(s_Messagesizeof(s_Message), "\n"" "); 
    
DispatchKeyValue(i_Client"targetname"s_TargetName); 
    
DispatchKeyValue(i_Ent"hint_target"s_TargetName); 
    
DispatchKeyValue(i_Ent"hint_timeout""5"); 
    
DispatchKeyValue(i_Ent"hint_range""0.01"); 
    
DispatchKeyValue(i_Ent"hint_color""255 255 255"); 
    
DispatchKeyValue(i_Ent"hint_icon_onscreen""use_binding"); 
    
DispatchKeyValue(i_Ent"hint_caption"s_Message); 
    
DispatchKeyValue(i_Ent"hint_binding"s_Bind); 
    
DispatchSpawn(i_Ent); 
    
AcceptEntityInput(i_Ent"ShowHint"); 
     
    
h_RemovePack CreateDataPack(); 
    
WritePackCell(h_RemovePacki_Client); 
    
WritePackCell(h_RemovePacki_Ent); 
    
CreateTimer(5.0RemoveInstructorHinth_RemovePack); 

     
public 
Action:RemoveInstructorHint(Handle:h_TimerHandle:h_Pack

    
decl i_Enti_Client
     
    
ResetPack(h_Packfalse); 
    
i_Client ReadPackCell(h_Pack); 
    
i_Ent ReadPackCell(h_Pack); 
    
CloseHandle(h_Pack); 
     
    if (!
i_Client || !IsClientInGame(i_Client) || GetClientTeam(i_Client) != TEAM_INFECTED || GetInfectedClass(i_Client) != CLASS_CHARGER
    { 
        return 
Plugin_Stop
    } 
     
    if (
i_Ent && IsValidEnt(i_Ent)) 
    { 
        
RemoveEdict(i_Ent); 
    } 
     
    
ClientCommand(i_Client"gameinstructor_enable 0"); 
    
DispatchKeyValue(i_Client"targetname"""); 
     
    return 
Plugin_Stop


stock GetInfectedClass(i_Client

    return 
GetEntProp(i_ClientProp_Send"m_zombieClass"); 

     
stock IsValidEnt(i_Ent

    return (
IsValidEdict(i_Ent) && IsValidEntity(i_Ent)); 


Last edited by cravenge; 10-29-2016 at 01:22.
cravenge is offline
diorfo
Member
Join Date: Dec 2013
Old 10-29-2016 , 09:50   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #14

Quote:
Originally Posted by cravenge View Post
That's because the timer I created checks only for alive players, so creating the "player_death" event would make the game detect that it's just falsed. What it needs is an alteration of the timer.
In fact to me still not triggering player_death on rank, dispite appears message in left upper corner that charger kill survivor with car.

I noticed it also with tank.

Sometimes it register player_death event on rank, sometimes no.

Seems like error on game.
Attached Files
File Type: zip charger power demo.zip (766.0 KB, 57 views)
diorfo is offline
diorfo
Member
Join Date: Dec 2013
Old 10-29-2016 , 11:10   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #15

Following the same idea of this modification, i tried update the Karma Charge plugin to catch hit/kill to charge also in instant kill.

But compiling, i'm having the error of function prototypes do not match on line SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); // Gotcha, damage!!

Could you please explain why?

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#define PLUGIN_VERSION                           "1.0.7"

#define TEST_DEBUG         0
#define TEST_DEBUG_LOG     0


static const Float:CHARGE_CHECKING_INTERVAL    0.4;
static const 
Float:ANGLE_STRAIGHT_DOWN[3]    = { 90.0 0.0 0.0 };
static const 
String:SOUND_EFFECT[]            = "./level/loud/climber.wav";

static 
Handle:cvarisEnabled                    INVALID_HANDLE;
static 
Handle:triggeringHeight                INVALID_HANDLE;
static 
Handle:chargerTimer                    INVALID_HANDLE;
static 
Handle:karmaTime                        INVALID_HANDLE;
static 
Handle:cvarNotify                    INVALID_HANDLE;
static 
Handle:cvarModeSwitch                INVALID_HANDLE;
static 
bool:isEnabled                        true;
static 
Float:lethalHeight                    475.0;

new 
bool:InstKillChecked[MAXPLAYERS+1];


public 
Plugin:myinfo 
{
    
name "L4D2 Karma Charge",
    
author " AtomicStryker",
    
description " Slows down time and displays stuff on Lethal Charges ",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net/showthread.php?p=1239108"
}

public 
OnPluginStart()
{
    
HookEvent("charger_carry_start"event_ChargerGrab);
    
HookEvent("charger_carry_end"event_GrabEnded);
    
    
CreateConVar("l4d2_karma_charge_version",                         PLUGIN_VERSION" L4D2 Karma Charge Plugin Version ",                                     FCVAR_PLUGIN|FCVAR_REPLICATED|FCVAR_DONTRECORD);
    
triggeringHeight =     CreateConVar("l4d2_karma_charge_height",    "475.0",         " What Height is considered karma ",                                     FCVAR_PLUGIN|FCVAR_REPLICATED);
    
karmaTime =            CreateConVar("l4d2_karma_charge_slowtime",     "1.5",             " How long does Time get slowed ",                                         FCVAR_PLUGIN|FCVAR_REPLICATED);
    
cvarisEnabled =     CreateConVar("l4d2_karma_charge_enabled",     "1",             " Turn Karma Charge on and off ",                                         FCVAR_PLUGIN|FCVAR_REPLICATED);
    
cvarNotify =         CreateConVar("l4d2_karma_charge_notify",     "1",             " Turn Chat Announcement on and off ",                                     FCVAR_PLUGIN|FCVAR_REPLICATED);
    
cvarModeSwitch =    CreateConVar("l4d2_karma_charge_slowmode",     "0",             " 0 - Entire Server gets slowed, 1 - Only Charger and Survivor do ",     FCVAR_PLUGIN|FCVAR_REPLICATED);
    
    
HookConVarChange(cvarisEnabled,     _cvarChange);
    
HookConVarChange(triggeringHeight,     _cvarChange);
}

public 
OnClientPostAdminCheck(client)  
{  
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage); // Gotcha, damage!!  


public 
OnMapStart()
{
    
PrefetchSound(SOUND_EFFECT);
    
PrecacheSound(SOUND_EFFECT);
    
chargerTimer INVALID_HANDLE;

    for (new 
1<= MaxClientsi++) 
        { 
                  if (
IsClientInGame(i)) 
                  { 
                            
InstKillChecked[i] = false// reset the check so the event can be created and fired again. 
                  

        } 
}

public 
Action:OnTakeDamage(victim, &attacker, &Float:damage, &damageType)  
{  
    if (
victim <= || victim MaxClients || !IsClientInGame(victim) || GetClientTeam(victim) != || !IsPlayerAlive(victim))  
    {  
        return 
Plugin_Continue;  
    }  
             
        new 
charger CheckForChargers();  
        if (
attacker == charger
        {  
              new 
realDmg RoundToZero(damage); // we convert the damage from float to int. 
               
              
new Handle:data CreateDataPack();  
              
WritePackCell(dataGetClientUserId(victim));  
              
WritePackCell(dataGetClientUserId(charger)); 
              
WritePackCell(datarealDmg); 
              
CreateTimer(1.0CheckForInstKilldataTIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT|TIMER_DATA_HNDL_CLOSE); // we create a repeating timer to check the victim's state, if this returns errors, just use CreateDataTimer instead. 
               
              
return Plugin_Changed;  
        }  
      
      
    return 
Plugin_Continue;  
}  

public 
Action:CheckForInstKill(Handle:timerHandle:data)  
{  
        
ResetPack(data);  
          
        new 
client GetClientOfUserId(ReadPackCell(data));  
        if (
client <= || !IsClientInGame(client) || GetClientTeam(client) != 2)  
        {  
                return 
Plugin_Continue;  
        }  
          
        new 
attacker GetClientOfUserId(ReadPackCell(data));  
        if (
attacker <= || !IsClientInGame(attacker) || GetClientTeam(attacker) != || GetEntProp(attackerProp_Send"m_zombieClass") != 6)  
        {  
                return 
Plugin_Continue;  
        }  
         
        new 
dmgTaken ReadPackCell(data); 
         
        if (
IsPlayerAlive(client)) 
        { 
                new 
Handle:OnPlayerHurt CreateEvent("player_hurt"true);  
                
SetEventInt(OnPlayerHurt"userid"GetClientUserId(client));  
                
SetEventInt(OnPlayerHurt"attacker"GetClientUserId(attacker));  
                
SetEventInt(OnPlayerHurt"dmg_health"dmgTaken); 
                
SetEventString(OnPlayerHurt"weapon""charger_claw"); 
                
FireEvent(OnPlayerHurtfalse); 
                
        } 
        else 
// if player died after being hit, create and fire the appropriate event. 
        

                new 
Handle:OnPlayerDeath CreateEvent("player_death"true);  
                
SetEventInt(OnPlayerDeath"userid"GetClientUserId(client));  
                
SetEventInt(OnPlayerDeath"attacker"GetClientUserId(attacker));  
                
FireEvent(OnPlayerDeathfalse); 
        } 
        return 
Plugin_Stop;  
}  

CheckForChargers()  
{  
        new 
count 0;  
        for (new 
1<= MaxClientsi++)  
        {  
                if (
IsClientInGame(i) && GetClientTeam(i) == && GetEntProp(iProp_Send"m_zombieClass") == 6)  
                {  
                        
count++;  
                }  
        }  
        return 
count;  
}  

public 
_cvarChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
    
isEnabled =     GetConVarBool(cvarisEnabled);
    
lethalHeight =     GetConVarFloat(triggeringHeight);
}

public 
Action:event_ChargerGrab(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (!
isEnabled
    
|| !client
    
|| !IsClientInGame(client))
    {
        return;
    }
    
    
DebugPrintToAll("Charger Carry event caught, initializing timer");
    
    if (
chargerTimer != INVALID_HANDLE)
    {
        
CloseHandle(chargerTimer);
        
chargerTimer INVALID_HANDLE;
    }
    
    
chargerTimer CreateTimer(CHARGE_CHECKING_INTERVAL_timer_CheckclientTIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
    
TriggerTimer(chargerTimertrue);
}

public 
Action:event_GrabEnded(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (
chargerTimer != INVALID_HANDLE)
    {
        
CloseHandle(chargerTimer);
        
chargerTimer INVALID_HANDLE;
    }
}

public 
Action:_timer_Check(Handle:timerany:client)
{
    if (!
client || !IsClientInGame(client) || !IsPlayerAlive(client))
    {
        
chargerTimer INVALID_HANDLE;
        return 
Plugin_Stop;
    }
    
    if (
GetEntityFlags(client) & FL_ONGROUND) return Plugin_Continue;
    
    new 
Float:height GetHeightAboveGround(client);
    
    
DebugPrintToAll("Karma Check - Charger Height is now: %f"height);
    
    if (
height lethalHeight)
    {
        
AnnounceKarmaCharge(client);
        
chargerTimer INVALID_HANDLE;
        return 
Plugin_Stop;
    }
    
    return 
Plugin_Continue;
}

static 
Float:GetHeightAboveGround(client)
{
    
decl Float:pos[3];
    
GetClientAbsOrigin(clientpos);
    
    
// execute Trace straight down
    
new Handle:trace TR_TraceRayFilterEx(posANGLE_STRAIGHT_DOWNMASK_SHOTRayType_Infinite_TraceFilter);
    
    if (!
TR_DidHit(trace))
    {
        
LogError("Tracer Bug: Trace did not hit anything, WTF");
    }
    
    
decl Float:vEnd[3];
    
TR_GetEndPosition(vEndtrace); // retrieve our trace endpoint
    
CloseHandle(trace);
    
    return 
GetVectorDistance(posvEndfalse);
}

public 
bool:_TraceFilter(entitycontentsMask)
{
    if (!
entity || !IsValidEntity(entity)) // dont let WORLD, or invalid entities be hit
    
{
        return 
false;
    }
    
    return 
true;
}

static 
AnnounceKarmaCharge(client)
{
    
EmitSoundToAll(SOUND_EFFECTclient);
    
    new 
victim GetCarryVictim(client);
    if (
victim == -1) return;
    
    
GetConVarBool(cvarModeSwitch) ? SlowChargeCouple(client) : SlowTime();
    
    if (
GetConVarBool(cvarNotify))
    {
        
PrintToChatAll("\x03%N\x01 Karma Charge'd %N, for great justice!!"clientvictim);
    }
}

static 
SlowChargeCouple(client)
{
    new 
target GetCarryVictim(client);
    if (
target == -1) return;
    
    
SetEntPropFloat(clientProp_Send"m_flLaggedMovementValue"0.2);
    
SetEntPropFloat(targetProp_Send"m_flLaggedMovementValue"0.2);
    
    new 
Handle:data CreateDataPack();
    
WritePackCell(dataclient);
    
WritePackCell(datatarget);
    
    
CreateTimer(GetConVarFloat(karmaTime), _revertCoupleTimeSlowdata);
}

public 
Action:_revertCoupleTimeSlow(Handle:timerHandle:data)
{
    
ResetPack(data);
    new 
client ReadPackCell(data);
    new 
target ReadPackCell(data);
    
CloseHandle(data);

    if (
IsClientInGame(client))
    {
        
SetEntPropFloat(clientProp_Send"m_flLaggedMovementValue"1.0);
    }
    
    if (
IsClientInGame(target))
    {
        
SetEntPropFloat(targetProp_Send"m_flLaggedMovementValue"1.0);
    }
    
CreateTimer(1.0CheckForInstKilldataTIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT|TIMER_DATA_HNDL_CLOSE);
}

static 
GetCarryVictim(client)
{
    new 
victim GetEntPropEnt(clientProp_Send"m_carryVictim");
    if (
victim 1
    
|| victim MaxClients
    
|| !IsClientInGame(victim))
    {
        return -
1;
    }
    
    return 
victim;
}

stock SlowTime(const String:desiredTimeScale[] = "0.2", const String:re_Acceleration[] = "2.0", const String:minBlendRate[] = "1.0", const String:blendDeltaMultiplier[] = "2.0")
{
    new 
ent CreateEntityByName("func_timescale");
    
    
DispatchKeyValue(ent"desiredTimescale"desiredTimeScale);
    
DispatchKeyValue(ent"acceleration"re_Acceleration);
    
DispatchKeyValue(ent"minBlendRate"minBlendRate);
    
DispatchKeyValue(ent"blendDeltaMultiplier"blendDeltaMultiplier);
    
    
DispatchSpawn(ent);
    
AcceptEntityInput(ent"Start");
    
    
CreateTimer(GetConVarFloat(karmaTime), _revertTimeSlowent);
}

public 
Action:_revertTimeSlow(Handle:timerany:ent)
{
    if(
IsValidEdict(ent))
    {
        
AcceptEntityInput(ent"Stop");
    }
}

stock DebugPrintToAll(const String:format[], any:...)
{
    
#if (TEST_DEBUG || TEST_DEBUG_LOG)
    
decl String:buffer[256];
    
    
VFormat(buffersizeof(buffer), format2);
    
    
#if TEST_DEBUG
    
PrintToChatAll("[KARMA] %s"buffer);
    
PrintToConsole(0"[KARMA] %s"buffer);
    
#endif
    
    
LogMessage("%s"buffer);
    
#else
    //suppress "format" never used warning
    
if(format[0])
        return;
    else
        return;
    
#endif

diorfo is offline
diorfo
Member
Join Date: Dec 2013
Old 10-29-2016 , 12:30   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #16

which entity belongs the Trash Can/dumpster?

prop_physics?

It's not triggering points to charger despite be moved.
diorfo is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 10-30-2016 , 09:59   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #17

Quote:
Originally Posted by diorfo View Post
In fact to me still not triggering player_death on rank, dispite appears message in left upper corner that charger kill survivor with car.

I noticed it also with tank.

Sometimes it register player_death event on rank, sometimes no.

Seems like error on game.
Saw the demo you attached. Looks to me that there's a bug with the rank plugin because from what I see, it only catches events one at a time.

What I am trying to say is if "player_incapacitated" at the same time "player_death" is fired, it only records the first event but not the second one.

Quote:
Originally Posted by diorfo View Post
Following the same idea of this modification, i tried update the Karma Charge plugin to catch hit/kill to charge also in instant kill.

But compiling, i'm having the error of function prototypes do not match on line SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); // Gotcha, damage!!

Could you please explain why?

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#define PLUGIN_VERSION                           "1.0.7"

#define TEST_DEBUG         0
#define TEST_DEBUG_LOG     0


static const Float:CHARGE_CHECKING_INTERVAL    0.4;
static const 
Float:ANGLE_STRAIGHT_DOWN[3]    = { 90.0 0.0 0.0 };
static const 
String:SOUND_EFFECT[]            = "./level/loud/climber.wav";

static 
Handle:cvarisEnabled                    INVALID_HANDLE;
static 
Handle:triggeringHeight                INVALID_HANDLE;
static 
Handle:chargerTimer                    INVALID_HANDLE;
static 
Handle:karmaTime                        INVALID_HANDLE;
static 
Handle:cvarNotify                    INVALID_HANDLE;
static 
Handle:cvarModeSwitch                INVALID_HANDLE;
static 
bool:isEnabled                        true;
static 
Float:lethalHeight                    475.0;

new 
bool:InstKillChecked[MAXPLAYERS+1];


public 
Plugin:myinfo 
{
    
name "L4D2 Karma Charge",
    
author " AtomicStryker",
    
description " Slows down time and displays stuff on Lethal Charges ",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net/showthread.php?p=1239108"
}

public 
OnPluginStart()
{
    
HookEvent("charger_carry_start"event_ChargerGrab);
    
HookEvent("charger_carry_end"event_GrabEnded);
    
    
CreateConVar("l4d2_karma_charge_version",                         PLUGIN_VERSION" L4D2 Karma Charge Plugin Version ",                                     FCVAR_PLUGIN|FCVAR_REPLICATED|FCVAR_DONTRECORD);
    
triggeringHeight =     CreateConVar("l4d2_karma_charge_height",    "475.0",         " What Height is considered karma ",                                     FCVAR_PLUGIN|FCVAR_REPLICATED);
    
karmaTime =            CreateConVar("l4d2_karma_charge_slowtime",     "1.5",             " How long does Time get slowed ",                                         FCVAR_PLUGIN|FCVAR_REPLICATED);
    
cvarisEnabled =     CreateConVar("l4d2_karma_charge_enabled",     "1",             " Turn Karma Charge on and off ",                                         FCVAR_PLUGIN|FCVAR_REPLICATED);
    
cvarNotify =         CreateConVar("l4d2_karma_charge_notify",     "1",             " Turn Chat Announcement on and off ",                                     FCVAR_PLUGIN|FCVAR_REPLICATED);
    
cvarModeSwitch =    CreateConVar("l4d2_karma_charge_slowmode",     "0",             " 0 - Entire Server gets slowed, 1 - Only Charger and Survivor do ",     FCVAR_PLUGIN|FCVAR_REPLICATED);
    
    
HookConVarChange(cvarisEnabled,     _cvarChange);
    
HookConVarChange(triggeringHeight,     _cvarChange);
}

public 
OnClientPostAdminCheck(client)  
{  
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage); // Gotcha, damage!!  


public 
OnMapStart()
{
    
PrefetchSound(SOUND_EFFECT);
    
PrecacheSound(SOUND_EFFECT);
    
chargerTimer INVALID_HANDLE;

    for (new 
1<= MaxClientsi++) 
        { 
                  if (
IsClientInGame(i)) 
                  { 
                            
InstKillChecked[i] = false// reset the check so the event can be created and fired again. 
                  

        } 
}

public 
Action:OnTakeDamage(victim, &attacker, &Float:damage, &damageType)  
{  
    if (
victim <= || victim MaxClients || !IsClientInGame(victim) || GetClientTeam(victim) != || !IsPlayerAlive(victim))  
    {  
        return 
Plugin_Continue;  
    }  
             
        new 
charger CheckForChargers();  
        if (
attacker == charger
        {  
              new 
realDmg RoundToZero(damage); // we convert the damage from float to int. 
               
              
new Handle:data CreateDataPack();  
              
WritePackCell(dataGetClientUserId(victim));  
              
WritePackCell(dataGetClientUserId(charger)); 
              
WritePackCell(datarealDmg); 
              
CreateTimer(1.0CheckForInstKilldataTIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT|TIMER_DATA_HNDL_CLOSE); // we create a repeating timer to check the victim's state, if this returns errors, just use CreateDataTimer instead. 
               
              
return Plugin_Changed;  
        }  
      
      
    return 
Plugin_Continue;  
}  

public 
Action:CheckForInstKill(Handle:timerHandle:data)  
{  
        
ResetPack(data);  
          
        new 
client GetClientOfUserId(ReadPackCell(data));  
        if (
client <= || !IsClientInGame(client) || GetClientTeam(client) != 2)  
        {  
                return 
Plugin_Continue;  
        }  
          
        new 
attacker GetClientOfUserId(ReadPackCell(data));  
        if (
attacker <= || !IsClientInGame(attacker) || GetClientTeam(attacker) != || GetEntProp(attackerProp_Send"m_zombieClass") != 6)  
        {  
                return 
Plugin_Continue;  
        }  
         
        new 
dmgTaken ReadPackCell(data); 
         
        if (
IsPlayerAlive(client)) 
        { 
                new 
Handle:OnPlayerHurt CreateEvent("player_hurt"true);  
                
SetEventInt(OnPlayerHurt"userid"GetClientUserId(client));  
                
SetEventInt(OnPlayerHurt"attacker"GetClientUserId(attacker));  
                
SetEventInt(OnPlayerHurt"dmg_health"dmgTaken); 
                
SetEventString(OnPlayerHurt"weapon""charger_claw"); 
                
FireEvent(OnPlayerHurtfalse); 
                
        } 
        else 
// if player died after being hit, create and fire the appropriate event. 
        

                new 
Handle:OnPlayerDeath CreateEvent("player_death"true);  
                
SetEventInt(OnPlayerDeath"userid"GetClientUserId(client));  
                
SetEventInt(OnPlayerDeath"attacker"GetClientUserId(attacker));  
                
FireEvent(OnPlayerDeathfalse); 
        } 
        return 
Plugin_Stop;  
}  

CheckForChargers()  
{  
        new 
count 0;  
        for (new 
1<= MaxClientsi++)  
        {  
                if (
IsClientInGame(i) && GetClientTeam(i) == && GetEntProp(iProp_Send"m_zombieClass") == 6)  
                {  
                        
count++;  
                }  
        }  
        return 
count;  
}  

public 
_cvarChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
    
isEnabled =     GetConVarBool(cvarisEnabled);
    
lethalHeight =     GetConVarFloat(triggeringHeight);
}

public 
Action:event_ChargerGrab(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (!
isEnabled
    
|| !client
    
|| !IsClientInGame(client))
    {
        return;
    }
    
    
DebugPrintToAll("Charger Carry event caught, initializing timer");
    
    if (
chargerTimer != INVALID_HANDLE)
    {
        
CloseHandle(chargerTimer);
        
chargerTimer INVALID_HANDLE;
    }
    
    
chargerTimer CreateTimer(CHARGE_CHECKING_INTERVAL_timer_CheckclientTIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
    
TriggerTimer(chargerTimertrue);
}

public 
Action:event_GrabEnded(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (
chargerTimer != INVALID_HANDLE)
    {
        
CloseHandle(chargerTimer);
        
chargerTimer INVALID_HANDLE;
    }
}

public 
Action:_timer_Check(Handle:timerany:client)
{
    if (!
client || !IsClientInGame(client) || !IsPlayerAlive(client))
    {
        
chargerTimer INVALID_HANDLE;
        return 
Plugin_Stop;
    }
    
    if (
GetEntityFlags(client) & FL_ONGROUND) return Plugin_Continue;
    
    new 
Float:height GetHeightAboveGround(client);
    
    
DebugPrintToAll("Karma Check - Charger Height is now: %f"height);
    
    if (
height lethalHeight)
    {
        
AnnounceKarmaCharge(client);
        
chargerTimer INVALID_HANDLE;
        return 
Plugin_Stop;
    }
    
    return 
Plugin_Continue;
}

static 
Float:GetHeightAboveGround(client)
{
    
decl Float:pos[3];
    
GetClientAbsOrigin(clientpos);
    
    
// execute Trace straight down
    
new Handle:trace TR_TraceRayFilterEx(posANGLE_STRAIGHT_DOWNMASK_SHOTRayType_Infinite_TraceFilter);
    
    if (!
TR_DidHit(trace))
    {
        
LogError("Tracer Bug: Trace did not hit anything, WTF");
    }
    
    
decl Float:vEnd[3];
    
TR_GetEndPosition(vEndtrace); // retrieve our trace endpoint
    
CloseHandle(trace);
    
    return 
GetVectorDistance(posvEndfalse);
}

public 
bool:_TraceFilter(entitycontentsMask)
{
    if (!
entity || !IsValidEntity(entity)) // dont let WORLD, or invalid entities be hit
    
{
        return 
false;
    }
    
    return 
true;
}

static 
AnnounceKarmaCharge(client)
{
    
EmitSoundToAll(SOUND_EFFECTclient);
    
    new 
victim GetCarryVictim(client);
    if (
victim == -1) return;
    
    
GetConVarBool(cvarModeSwitch) ? SlowChargeCouple(client) : SlowTime();
    
    if (
GetConVarBool(cvarNotify))
    {
        
PrintToChatAll("\x03%N\x01 Karma Charge'd %N, for great justice!!"clientvictim);
    }
}

static 
SlowChargeCouple(client)
{
    new 
target GetCarryVictim(client);
    if (
target == -1) return;
    
    
SetEntPropFloat(clientProp_Send"m_flLaggedMovementValue"0.2);
    
SetEntPropFloat(targetProp_Send"m_flLaggedMovementValue"0.2);
    
    new 
Handle:data CreateDataPack();
    
WritePackCell(dataclient);
    
WritePackCell(datatarget);
    
    
CreateTimer(GetConVarFloat(karmaTime), _revertCoupleTimeSlowdata);
}

public 
Action:_revertCoupleTimeSlow(Handle:timerHandle:data)
{
    
ResetPack(data);
    new 
client ReadPackCell(data);
    new 
target ReadPackCell(data);
    
CloseHandle(data);

    if (
IsClientInGame(client))
    {
        
SetEntPropFloat(clientProp_Send"m_flLaggedMovementValue"1.0);
    }
    
    if (
IsClientInGame(target))
    {
        
SetEntPropFloat(targetProp_Send"m_flLaggedMovementValue"1.0);
    }
    
CreateTimer(1.0CheckForInstKilldataTIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT|TIMER_DATA_HNDL_CLOSE);
}

static 
GetCarryVictim(client)
{
    new 
victim GetEntPropEnt(clientProp_Send"m_carryVictim");
    if (
victim 1
    
|| victim MaxClients
    
|| !IsClientInGame(victim))
    {
        return -
1;
    }
    
    return 
victim;
}

stock SlowTime(const String:desiredTimeScale[] = "0.2", const String:re_Acceleration[] = "2.0", const String:minBlendRate[] = "1.0", const String:blendDeltaMultiplier[] = "2.0")
{
    new 
ent CreateEntityByName("func_timescale");
    
    
DispatchKeyValue(ent"desiredTimescale"desiredTimeScale);
    
DispatchKeyValue(ent"acceleration"re_Acceleration);
    
DispatchKeyValue(ent"minBlendRate"minBlendRate);
    
DispatchKeyValue(ent"blendDeltaMultiplier"blendDeltaMultiplier);
    
    
DispatchSpawn(ent);
    
AcceptEntityInput(ent"Start");
    
    
CreateTimer(GetConVarFloat(karmaTime), _revertTimeSlowent);
}

public 
Action:_revertTimeSlow(Handle:timerany:ent)
{
    if(
IsValidEdict(ent))
    {
        
AcceptEntityInput(ent"Stop");
    }
}

stock DebugPrintToAll(const String:format[], any:...)
{
    
#if (TEST_DEBUG || TEST_DEBUG_LOG)
    
decl String:buffer[256];
    
    
VFormat(buffersizeof(buffer), format2);
    
    
#if TEST_DEBUG
    
PrintToChatAll("[KARMA] %s"buffer);
    
PrintToConsole(0"[KARMA] %s"buffer);
    
#endif
    
    
LogMessage("%s"buffer);
    
#else
    //suppress "format" never used warning
    
if(format[0])
        return;
    else
        return;
    
#endif

It should be: (removed debugs)
PHP Code:
#pragma semicolon 1 
#include <sourcemod> 
#include <sdktools> 

static const Float:CHARGE_CHECKING_INTERVAL 0.4
static const 
Float:ANGLE_STRAIGHT_DOWN[3] = { 90.0 0.0 0.0 }; 
static const 
String:SOUND_EFFECT[] = "./level/loud/climber.wav"

static 
Handle:cvarisEnabled INVALID_HANDLE
static 
Handle:triggeringHeight INVALID_HANDLE
static 
Handle:chargerTimer INVALID_HANDLE
static 
Handle:karmaTime INVALID_HANDLE
static 
Handle:cvarNotify INVALID_HANDLE
static 
Handle:cvarModeSwitch INVALID_HANDLE
static 
bool:isEnabled
static 
Float:lethalHeight

static 
Carried[MAXPLAYERS+1]; 

public 
Plugin:myinfo =  

    
name "[L4D2] Karma Charge"
    
author " AtomicStryker"
    
description " Slows down time and displays stuff on Lethal Charges "
    
version PLUGIN_VERSION
    
url "http://forums.alliedmods.net/showthread.php?p=1239108" 


public 
OnPluginStart() 

    
HookEvent("charger_carry_start"OnChargerCarryStart); 
    
HookEvent("charger_carry_end"OnChargerCarryEnd); 
    
    
CreateConVar("l4d2_karma_charge_version",                         PLUGIN_VERSION" L4D2 Karma Charge Plugin Version ",                                     FCVAR_NOTIFY|FCVAR_REPLICATED|FCVAR_DONTRECORD); 
    
triggeringHeight CreateConVar("l4d2_karma_charge_height""475.0"" What Height is considered karma "FCVAR_NOTIFY|FCVAR_REPLICATED); 
    
karmaTime CreateConVar("l4d2_karma_charge_slowtime""1.5"" How long does Time get slowed "FCVAR_NOTIFY|FCVAR_REPLICATED); 
    
cvarisEnabled CreateConVar("l4d2_karma_charge_enabled""1"" Turn Karma Charge on and off "FCVAR_NOTIFY|FCVAR_REPLICATED); 
    
cvarNotify CreateConVar("l4d2_karma_charge_notify""1"" Turn Chat Announcement on and off "FCVAR_NOTIFY|FCVAR_REPLICATED); 
    
cvarModeSwitch CreateConVar("l4d2_karma_charge_slowmode""0"" 0 - Entire Server gets slowed, 1 - Only Charger and Survivor do "FCVAR_NOTIFY|FCVAR_REPLICATED); 
    
    
HookConVarChange(cvarisEnabled_cvarChange); 
    
HookConVarChange(triggeringHeight_cvarChange); 
}

public 
OnMapStart() 

    
PrefetchSound(SOUND_EFFECT); 
    
PrecacheSound(SOUND_EFFECTtrue);
    
    
chargerTimer INVALID_HANDLE;
    
    for (new 
1<= MaxClientsi++)  
    {  
        if (
IsClientInGame(i))  
        {
            
Carried[i] = 0// remove all owners so the timer won't bug out.
        
}  
    }
}

public 
_cvarChange(Handle:convar, const String:oldValue[], const String:newValue[]) 

    
isEnabled GetConVarBool(cvarisEnabled); 
    
lethalHeight GetConVarFloat(triggeringHeight); 


public 
Action:OnChargerCarryStart(Handle:event, const String:name[], bool:dontBroadcast

    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (!
isEnabled || !client || !IsClientInGame(client)) 
    {
        return; 
    } 
    
    if (
chargerTimer != INVALID_HANDLE
    { 
        
CloseHandle(chargerTimer); 
        
chargerTimer INVALID_HANDLE
    } 
    
    
chargerTimer CreateTimer(CHARGE_CHECKING_INTERVAL_timer_CheckclientTIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE); 
    
TriggerTimer(chargerTimertrue); 


public 
Action:OnChargerCarryEnd(Handle:event, const String:name[], bool:dontBroadcast

    if (
chargerTimer != INVALID_HANDLE
    { 
        
CloseHandle(chargerTimer); 
        
chargerTimer INVALID_HANDLE
    } 


public 
Action:_timer_Check(Handle:timerany:client

    if (!
client || !IsClientInGame(client) || !IsPlayerAlive(client)) 
    { 
        
chargerTimer INVALID_HANDLE
        return 
Plugin_Stop
    } 
     
    if (
GetEntityFlags(client) & FL_ONGROUND)
    {
        return 
Plugin_Continue;
    }
     
    new 
Float:height GetHeightAboveGround(client);
    if (
height lethalHeight
    { 
        
AnnounceKarmaCharge(client); 
        
chargerTimer INVALID_HANDLE
        return 
Plugin_Stop
    } 
    
    return 
Plugin_Continue


static 
Float:GetHeightAboveGround(client

    
decl Float:pos[3]; 
    
GetClientAbsOrigin(clientpos); 
    
    new 
Handle:trace TR_TraceRayFilterEx(posANGLE_STRAIGHT_DOWNMASK_SHOTRayType_Infinite_TraceFilter);
     
    
decl Float:vEnd[3]; 
    
TR_GetEndPosition(vEndtrace); 
    
CloseHandle(trace); 
     
    return 
GetVectorDistance(posvEndfalse); 


public 
bool:_TraceFilter(entitycontentsMask

    if (!
entity || !IsValidEntity(entity)) 
    { 
        return 
false
    } 
     
    return 
true


static 
AnnounceKarmaCharge(client

    
EmitSoundToAll(SOUND_EFFECTclient); 
     
    new 
victim GetCarryVictim(client); 
    if (
victim == -1)
    {
        return;
    }
     
    
GetConVarBool(cvarModeSwitch) ? SlowChargeCouple(client) : SlowTime(clientvictim);
    
Carried[client] = victim// now we make sure the charger's carried victim here.
    
    
if (GetConVarBool(cvarNotify)) 
    { 
        
PrintToChatAll("\x03%N\x01 Karma Charge'd %N, for great justice!!"clientvictim); 
    } 


static 
SlowChargeCouple(client

    new 
target GetCarryVictim(client); 
    if (
target == -1)
    {
        return;
    }
     
    
SetEntPropFloat(clientProp_Send"m_flLaggedMovementValue"0.2); 
    
SetEntPropFloat(targetProp_Send"m_flLaggedMovementValue"0.2); 
     
    new 
Handle:data CreateDataPack(); 
    
WritePackCell(dataGetClientUserId(client)); 
    
WritePackCell(dataGetClientUserId(target));
    
CreateTimer(GetConVarFloat(karmaTime), _revertCoupleTimeSlowdataTIMER_FLAG_NO_MAPCHANGE|TIMER_DATA_HNDL_CLOSE); 
}

public 
Action:_revertCoupleTimeSlow(Handle:timerHandle:data
{
    
ResetPack(data);
    
    new 
client GetClientOfUserId(ReadPackCell(data)); 
    new 
target GetClientOfUserId(ReadPackCell(data));
    
    if (!
IsCharger(client) || !IsSurvivor(target)) 
    { 
        return 
Plugin_Stop;
    }
    
    
SetEntPropFloat(clientProp_Send"m_flLaggedMovementValue"1.0);
    
SetEntPropFloat(targetProp_Send"m_flLaggedMovementValue"1.0); 
    
    
// is this even possible? Creating a datapack inside another datapack?
    
new Handle:fallData CreateDataPack();
    
WritePackCell(fallDataGetClientUserId(client));
    
WritePackCell(fallDataGetClientUserId(target));
    
CreateTimer(1.0CheckForFallsfallDataTIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT|TIMER_DATA_HNDL_CLOSE);
    
    return 
Plugin_Stop;
}

public 
Action:CheckForFalls(Handle:timerHandle:fallEvent)
{
    
ResetPack(fallEvent);
    
    new 
carrier GetClientOfUserId(ReadPackCell(fallEvent)); 
    new 
carried GetClientOfUserId(ReadPackCell(fallEvent));
    
    if (!
IsCharger(carrier) || !IsSurvivor(carried) || IsPlayerAlive(carried)) 
    {
        return 
Plugin_Continue;
    }
    
    new 
Handle:OnPlayerDeath CreateEvent("player_death"true);
    
SetEventInt(OnPlayerDeath"userid"GetClientUserId(carried)); 
    
SetEventInt(OnPlayerDeath"attacker"GetClientUserId(carrier));
    
FireEvent(OnPlayerDeathfalse);
    
    
Carried[carrier] = 0// delete previous owner to prevent conflicts.
    
return Plugin_Stop;
}

static 
GetCarryVictim(client

    new 
victim GetEntPropEnt(clientProp_Send"m_carryVictim"); 
    if (
victim <= || victim MaxClients || !IsClientInGame(victim) || GetClientTeam(victim) != || !IsPlayerAlive(victim)) // (common problem) sometimes, there's a coincidence where the charger's carried victim suddenly dies and false alarming the slow motion function.
    

        return -
1
    } 
     
    return 
victim


stock SlowTime(clienttarget, const String:desiredTimeScale[] = "0.2", const String:re_Acceleration[] = "2.0", const String:minBlendRate[] = "1.0", const String:blendDeltaMultiplier[] = "2.0"

    new 
ent CreateEntityByName("func_timescale"); 
     
    
DispatchKeyValue(ent"desiredTimescale"desiredTimeScale); 
    
DispatchKeyValue(ent"acceleration"re_Acceleration); 
    
DispatchKeyValue(ent"minBlendRate"minBlendRate); 
    
DispatchKeyValue(ent"blendDeltaMultiplier"blendDeltaMultiplier); 
     
    
DispatchSpawn(ent); 
    
AcceptEntityInput(ent"Start"); 
     
    
CreateTimer(GetConVarFloat(karmaTime), _revertTimeSlowent);
    
    new 
Handle:fallFix CreateDataPack();
    
WritePackCell(fallFixGetClientUserId(client));
    
WritePackCell(fallFixGetClientUserId(target));
    
CreateTimer(1.0CheckForFallsfallFixTIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT|TIMER_DATA_HNDL_CLOSE);
}

public 
Action:_revertTimeSlow(Handle:timerany:ent

    if (!
IsValidEdict(ent)) 
    { 
        return 
Plugin_Stop;
    }
    
    
AcceptEntityInput(ent"Stop");
    return 
Plugin_Stop;
}

stock bool:IsCharger(client)
{
    return (
client && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == && GetEntProp(clientProp_Send"m_zombieClass") == 6);
}

stock bool:IsSurvivor(client)
{
    return (
client && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2);

Quote:
Originally Posted by diorfo View Post
which entity belongs the Trash Can/dumpster?

prop_physics?

It's not triggering points to charger despite be moved.
Hmmm, odd, now that I think about it. May I suggest you use the plugin I attached below to see if that solves the problem?
Attached Files
File Type: sp Get Plugin or Get Source (hittable_props_damage.sp - 190 views - 6.6 KB)

Last edited by cravenge; 10-30-2016 at 10:50.
cravenge is offline
diorfo
Member
Join Date: Dec 2013
Old 10-31-2016 , 10:19   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #18

Quote:
Originally Posted by cravenge View Post
Saw the demo you attached. Looks to me that there's a bug with the rank plugin because from what I see, it only catches events one at a time.

What I am trying to say is if "player_incapacitated" at the same time "player_death" is fired, it only records the first event but not the second one.



It should be: (removed debugs)


Hmmm, odd, now that I think about it. May I suggest you use the plugin I attached below to see if that solves the problem?
The only entity i found that still bugged, even with the plugin you posted, is the prop car alarm.

The strange thing is sometimes it count hit (incap or kill) sometimes count nothing.

I run over survivor about 10 times with same prop alarm car and it count hit about half of the times.

The rest entity i tested (other cars, dumpster, forklift) count hits right.

The modification you did in karma charger, works perfectly.

Thanks again for supporting.


PS: found another entity that doesn't count hits for charger.

The big woods.

In beginning of c12m4, there is a wood after barn that doesn't count hits.

Isn't it prop_physics entity?

Last edited by diorfo; 10-31-2016 at 11:28.
diorfo is offline
diorfo
Member
Join Date: Dec 2013
Old 11-01-2016 , 00:12   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #19

Tested again and now the big woods from c12m4 is counting hits for charger but not every time.

Making a test and decreasing the convar value of hittable_props_damage.sp "hpd-l4d2_overhit_time" to "0.5", seems that improve some hit catches.

I'm not sure about it but looks like how low you put the value of this cvar, more accurate will be the ability to catch hits.

Last edited by diorfo; 11-01-2016 at 00:16.
diorfo is offline
DonProof
Junior Member
Join Date: Jun 2021
Old 10-19-2021 , 14:11   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #20

Has anyone managed to make this add-on work so that it scores points for incapacitating with a car?
Charger Power
DonProof 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 11:39.


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