Author
|
Message
|
Senior Member
Join Date: Jun 2019
Location: Peru
|
04-03-2020
, 17:13
L4D2 - What is the location to put a PHP code (Sorry for my ignorance)
|
#1
|
Good to all gamers, sorry for my ignorance but I would like someone to tell me exactly where a PHP code is written, since I see that they are solved by that. Example:
#pragma semicolon 1
#include <sourcemod>
#include <sdkhooks>
#define WITCH_DAMAGE_THRESHOLD 799.0
new Float:inflictedDamage[MAXPLAYERS + 1];
public OnEntityCreated(entity, const String:classname[])
{
if (StrEqual(classname, "witch"))
{
SDKHook(entity, SDKHook_OnTakeDamage, OnWitchTakeDamage);
}
}
public Action:OnWitchTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damageType, &weapon, Float:damageForce[3], Float:damagePosition[3])
{
if (!IsWitch(victim) || !IsSurvivor(attacker) || IsFakeClient(attacker))
return Plugin_Continue;
if (IsMelee(weapon))
{
inflictedDamage[attacker] += damage;
if (inflictedDamage[attacker] >= WITCH_DAMAGE_THRESHOLD)
{
damage = GetConVarFloat(FindConVar("z_witch_health")) - inflictedDamage[attacker] + damage;
inflictedDamage[attacker] = 0.0;
return Plugin_Changed;
}
}
CreateTimer(0.1, ResetDamageCounter);
return Plugin_Continue;
}
public Action:ResetDamageCounter(Handle:timer)
{
for (new i = 1; i <= MaxClients; i++)
{
inflictedDamage[i] = 0.0;
}
}
bool:IsSurvivor(client)
{
return (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2);
}
bool:IsWitch(entity)
{
if (entity > 0 && IsValidEntity(entity) && IsValidEdict(entity))
{
decl String:strClassName[64];
GetEdictClassname(entity, strClassName, sizeof(strClassName));
return StrEqual(strClassName, "witch");
}
return false;
}
bool:IsMelee(weapon)
{
decl String:classname[64];
GetEdictClassname(weapon, classname, sizeof(classname));
return (StrEqual(classname, "weapon_melee"));
}
|
|
|
|