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

[L4D2] Register extra Actions on GameME plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
diorfo
Member
Join Date: Dec 2013
Old 10-26-2016 , 16:11   [L4D2] Register extra Actions on GameME plugin
Reply With Quote #1

Hello,

I have a L4D2 10vs10 versus server with a bunch of plugins and I'm began using the gameME rank.

But unfortunately, it don't register all actions to compute points that I want to the extra plugins I have.

By myself, I improved some actions like register points to charge when hit survivors while charging and also for infected when incapacite survivor.

But I want 2 more things to let it perfect to my server:

1 - Register points to charger player when it hit survivor with car
(I'm using the plugin "Charger Power" https://forums.alliedmods.net/showthread.php?t=126831)

2 - Register points to charger and jockey when you make instant kill (ex: on c1m1_hotel grab the survivor and put it down from top to 1st floor).
I'm using the Karma Charge plugin https://forums.alliedmods.net/showthread.php?p=1239108
and also Jockey Jump https://forums.alliedmods.net/showthread.php?p=1127386

For the 1st request, charger it's not triggering the hookevent "player_incapacited_start" that I updated to register log of incapacited survivors for infected.
For tank when it hit car and incapacite survivor, it's registering normaly points to tank player but for charger when incapacite player with car, no.
I believe it's because car it's set like a weapon for tank but not for charger originally, but I don't have clue how set cars or forklifts to charge in plugin like it's set for tank in versus game.

For the 2nd request, I have no clue how can I catch this event of player die of instant kill (seems like a bug on plugin you grab a player, jump with jockey from high height and don't register kill for jockey player).
diorfo is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-26-2016 , 16:16   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #2

From my knowledge I thought you needed to rent out a database from gameme and their server-side plugins handled all of the events, meaning you would need to contact GameMe developers in order to get anything fixed or added within your stats. Either that or use a different ranking system.
Mitchell is offline
diorfo
Member
Join Date: Dec 2013
Old 10-26-2016 , 16:54   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #3

Quote:
Originally Posted by Mitchell View Post
From my knowledge I thought you needed to rent out a database from gameme and their server-side plugins handled all of the events, meaning you would need to contact GameMe developers in order to get anything fixed or added within your stats. Either that or use a different ranking system.
This situation works for all events registred in plugin only.

And in plugin, you have only the basic events registred.

Specific events like "survivor hit by car" don't exist in l4d2.

That's the problem.

I know it's possible register this kind of action because in past I already saw l4d2 server in HLstatsX that you gained points with hit by car with charger and also instant kills.

I already contacted GameME and didn't receive an answer that I expected, that's why I'm asking help here.
diorfo is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-26-2016 , 17:25   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #4

Quote:
Originally Posted by diorfo View Post
This situation works for all events registred in plugin only.

And in plugin, you have only the basic events registred.

Specific events like "survivor hit by car" don't exist in l4d2.

That's the problem.

I know it's possible register this kind of action because in past I already saw l4d2 server in HLstatsX that you gained points with hit by car with charger and also instant kills.

I already contacted GameME and didn't receive an answer that I expected, that's why I'm asking help here.
Then use HLstatsX....
I'm not saying it's not possible.
I'm saying that it's not how GameMe works as a system.
Mitchell is offline
diorfo
Member
Join Date: Dec 2013
Old 10-26-2016 , 18:36   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #5

Quote:
Originally Posted by Mitchell View Post
Then use HLstatsX....
I'm not saying it's not possible.
I'm saying that it's not how GameMe works as a system.
Sorry buddy, I appreciate your concern with subject but your answers are out of topic.

I'm here not asking what Rank I should use.

If HLstatsX had what I need, sure I'll move to it, but don't have also.

I only want help with codes I should use in plugin to be able to catch the right logs I need.

That's all.

Thanks anyway for trying to help me.
diorfo is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 10-27-2016 , 04:53   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #6

In order for those points to be registered, you will need CreateEvent function in those plugins. I'm really good at it, examples are my brutal hunter pounce and charger jump modified plugins in the plugins section.

Last edited by cravenge; 10-27-2016 at 04:54.
cravenge is offline
diorfo
Member
Join Date: Dec 2013
Old 10-27-2016 , 23:44   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #7

Quote:
Originally Posted by cravenge View Post
In order for those points to be registered, you will need CreateEvent function in those plugins. I'm really good at it, examples are my brutal hunter pounce and charger jump modified plugins in the plugins section.
Following your sugestion, i tried to create the event "player_incapacited_start" right after the moment the survivor is hit by car (i_Health > 0) in plugin "charger power" but i don't know why it's not triggering the event (maybe the cell packs SurvivorID and ChargerID are not taking the rights IDs of attacker and victims???)

Below what i did but seems no effect.

I apreciate any help or directions.

PHP Code:
/*

    Created by DJ_WEST
    
    Web: http://amx-x.ru
    AMX Mod X and SourceMod Russian Community
    
*/

#include <sourcemod>
#include <sdktools>

#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

public Plugin:myinfo 
{
    
name "Charger Power",
    
author "DJ_WEST",
    
description "Allows charger to move objects (containers, cars, trucks) by hitting them when using own 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("Charger Power supports Left 4 Dead 2 only!")
    
    
LoadTranslations("charger_power.phrases")
    
    
h_Version CreateConVar("charger_power_version"PLUGIN_VERSION"Charger Power version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY)
    
g_h_CvarChargerPower CreateConVar("l4d2_charger_power""500.0""Charger hit power"FCVAR_PLUGIN|FCVAR_NOTIFYtrue0.0true5000.0)
    
g_h_CvarChargerCarry CreateConVar("l4d2_charger_power_carry""1""Can move objects if charger carry the player"FCVAR_PLUGIN|FCVAR_NOTIFYtrue0.0true1.0)
    
g_h_CvarMessageType CreateConVar("l4d2_charger_power_message_type""3""Message type (0 - disable, 1 - chat, 2 - hint, 3 - instructor hint)"FCVAR_PLUGIN|FCVAR_NOTIFYtrue0.0true3.0)
    
g_h_CvarObjects CreateConVar("l4d2_charger_power_objects""15""Can move objects this type (1 - car, 2 - car alarm, 4 - container, 8 - truck)"FCVAR_PLUGIN|FCVAR_NOTIFYtrue1.0true15.0)
    
g_h_CvarPushLimit CreateConVar("l4d2_charger_power_push_limit""3""How many times object can be moved"FCVAR_PLUGIN|FCVAR_NOTIFYtrue1.0true100.0)
    
g_h_CvarRemoveObject CreateConVar("l4d2_charger_power_remove""0""Remove moved object after some time (in seconds)"FCVAR_PLUGIN|FCVAR_NOTIFYtrue0.0true100.0)
    
g_h_CvarChargerDamage CreateConVar("l4d2_charger_power_damage""10""Additional damage to charger from moving objects"FCVAR_PLUGIN|FCVAR_NOTIFYtrue0.0true100.0)

    
HookEvent("charger_charge_end"EventChargeEnd)
    
HookEvent("player_spawn"EventPlayerSpawn)

    
SetConVarString(h_VersionPLUGIN_VERSION)
}

public 
Action:EventChargeEnd(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")
    new 
Handle:ChargerID CreateDataPack()
    
WritePackCell(ChargerIDGetClientUserId(i_UserID))
    
i_Client GetClientOfUserId(i_UserID)
    
    
    if (!
i_Client || !IsClientInGame(i_Client))
        return 
Plugin_Handled
        
    
if (!GetConVarInt(g_h_CvarChargerCarry) && GetEntProp(i_ClientProp_Send"m_carryVictim") > 0)
        return 
Plugin_Handled

    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_Handled
                
            i_PushCount 
GetEntProp(i_TargetProp_DataPUSH_COUNT)
            
            if (
i_PushCount >= GetConVarInt(g_h_CvarPushLimit))
                return 
Plugin_Handled
                
            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_physics") || StrEqual(s_ClassName"prop_car_alarm"))
            {
                if (
StrEqual(s_ClassName"prop_car_alarm") && !(i_Type PROP_CAR_ALARM))
                    return 
Plugin_Handled
                
else if (StrContains(s_ModelName"car") != -&& !(i_Type PROP_CAR) && !(i_Type PROP_CAR_ALARM))
                    return 
Plugin_Handled
                
else if (StrContains(s_ModelName"dumpster") != -&& !(i_Type PROP_CONTAINER))
                    return 
Plugin_Handled
                
else if (StrContains(s_ModelName"forklift") != -&& !(i_Type PROP_TRUCK))
                    return 
Plugin_Handled
                    
                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)
                
                
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)
                        new 
Handle:SurvivorID CreateDataPack()
                        
WritePackCell(SurvivorIDGetClientUserId(i_Client))
                        
                        
ResetPack(ChargerID)
                        
ResetPack(SurvivorID)
                            
                        new 
charger GetClientOfUserId(ReadPackCell(ChargerID))
                        new 
survivor GetClientOfUserId(ReadPackCell(SurvivorID))
                        new 
Handle:OnPlayerIncap CreateEvent("player_incapacited_start"true)
                        
SetEventInt(OnPlayerIncap"userid"GetClientUserId(survivor))
                        
SetEventInt(OnPlayerIncap"attacker"GetClientUserId(charger))
                        
FireEvent(OnPlayerIncapfalse)
                        }

                    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:RemoveEntity(Handle:h_Timerany:i_Ent)
{
    if (
IsValidEnt(i_Ent))
        
RemoveEdict(i_Ent)
}

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 (
IsValidEdict(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})
    }
}

public 
Action:EventPlayerSpawn(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 (
IsClientInGame(i_Client) && !IsFakeClient(i_Client) && GetClientTeam(i_Client) == TEAM_INFECTED && GetInfectedClass(i_Client) == CLASS_CHARGER)
    {
        
        
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)
}

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)
        }
    }
}

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))
        return 
Plugin_Handled
    
    
if (IsValidEntity(i_Ent))
            
RemoveEdict(i_Ent)
    
    
ClientCommand(i_Client"gameinstructor_enable 0")
        
    
DispatchKeyValue(i_Client"targetname""")
        
    return 
Plugin_Continue
}

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 diorfo; 10-28-2016 at 00:09.
diorfo is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 10-28-2016 , 01:13   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #8

How about this?

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

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 
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:OnPlayerHurt CreateEvent("player_hurt"true); // because the event we created is not being hooked so it's true, otherwise it's false
                        
SetEventInt(OnPlayerHurt"userid"GetClientUserId(victim));
                        
SetEventInt(OnPlayerHurt"attacker"GetClientUserId(charger));
                        
SetEventInt(OnPlayerHurt"dmg_health"realDmg); // record the damage
                        
SetEventString(OnPlayerHurt"weapon"inflictor); // make the entities the weapon that the charger used to attack
                        
FireEvent(OnPlayerHurtfalse);
                        
                        new 
Handle:incapFix CreateDataPack();
                        
WritePackCell(incapFixGetClientUserId(victim));
                        
WritePackCell(incapFixGetClientUserId(charger));
                        
CreateTimer(1.0CheckForIncapsincapFixTIMER_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:incapFix)
{
        
ResetPack(incapFix);
        
        new 
client GetClientOfUserId(ReadPackCell(incapFix));
        if (
client <= || !IsClientInGame(client) || GetClientTeam(client) != || !IsPlayerAlive(client) || !IsPlayerIncapped(client))
        {
                return 
Plugin_Continue;
        }
        
        new 
attacker GetClientOfUserId(ReadPackCell(incapFix));
        if (
attacker <= || !IsClientInGame(attacker) || GetClientTeam(attacker) != TEAM_INFECTED || GetEntProp(attackerProp_Send"m_zombieClass") != CLASS_CHARGER)
        {
                return 
Plugin_Continue;
        }
        
        new 
Handle:OnPlayerIncapacitated CreateEvent("player_incapacitated"true);
        
SetEventInt(OnPlayerIncapacitated"userid"GetClientUserId(client));
        
SetEventInt(OnPlayerIncapacitated"attacker"GetClientUserId(attacker));
        
FireEvent(OnPlayerIncapacitatedfalse);
        
        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 00:49.
cravenge is offline
diorfo
Member
Join Date: Dec 2013
Old 10-28-2016 , 11:48   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #9

Quote:
Originally Posted by cravenge View Post
How about this?
Wow! too more complicated than i thought.

Trying to compile it show the warnings and errors below:

// C:\l4d2\left4dead2\addons\sourcemod\scripting \l4d2_charger_power.sp(80) : warning 217: loose indentation - if (i_Owner[inflictor] == charger) // since the game never makes the charger the attacker, we force it to do so.
// C:\l4d2\left4dead2\addons\sourcemod\scripting \l4d2_charger_power.sp(88 ) : error 035: argument type mismatch (argument 3) - SetEventString(OnPlayerHurt, "weapon", inflictor); // make the entities the weapon that the charger used to attack
// C:\l4d2\left4dead2\addons\sourcemod\scripting \l4d2_charger_power.sp(220) : warning 217: loose indentation - i_Owner[i_Target] = i_Client; // make the charger the owner of the entity.
// C:\l4d2\left4dead2\addons\sourcemod\scripting \l4d2_charger_power.sp(223) : warning 217: loose indentation - h_Pack = CreateDataPack();


All looks right on code but happens loose identification with i_Owner and h_Pack and also cars looks like can't be set like weapon.
diorfo is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 10-28-2016 , 18:59   Re: [L4D2] Register extra Actions on GameME plugin
Reply With Quote #10

Don't worry about the loose indentations but for the SetEventString, just change inflictor to "charger_claw" (with quotes).
cravenge 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 19:34.


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