#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#define VERSION_NUM "1.3DelChick"
public Plugin:myinfo =
{
name = "Zombie Chicken",
author = "SenatoR",
description="Description what is it? :D",
version=VERSION_NUM
};
new Handle:h_zch,Handle:h_zcm,Handle:h_zct;
new String:zcm[PLATFORM_MAX_PATH],zch,zct;
public OnPluginStart()
{
h_zcm = CreateConVar("zc_model", "models/chicken/chicken_zombie.mdl", "Модель зомбо курицы");
h_zch = CreateConVar("zc_health", "1000", "Кол-во хп зомбо курицы");
h_zct= CreateConVar("zc_type", "2", "Где будет появлятся курица (1 = На месте смерти игрока, 2 = на месте смерти курицы,3 = все вместе)");
HookEvent("player_death", OnPlayerDeath);
HookEvent("round_prestart", Event_RoundStart, EventHookMode_PostNoCopy);
AutoExecConfig(true, "Zombie_Chicken");
}
public OnMapStart()
{
GetConVarString(h_zcm, zcm, sizeof zcm);
if(!PrecacheModel(zcm,true))
{
zcm[0] = '\0';
zch = 0;
}
else{
zch = GetConVarInt(h_zch);
zct = GetConVarInt(h_zct);
}
}
public OnEntityCreated(entity, const String:classname[])
{
if ( StrEqual( classname, "chicken" ) )
{
SDKHook( entity, SDKHook_OnTakeDamage, Chicken_TakeDamage);
}
}
public Action:Chicken_TakeDamage(entity, &attacker, &inflictor, &Float:damage, &damagetype)
{
if(attacker>0 && IsValidEdict(entity))
{
decl String:classname[65];
GetEntPropString(entity, Prop_Data, "m_iClassname", classname, sizeof(classname));
if ( StrEqual( classname, "chicken" ))
{
GetEntPropString(entity, Prop_Data, "m_iName", classname, sizeof(classname));
if (!StrEqual( classname, "zombie_chicken" ) && zch >0)
{
new Float:Pos[3];
GetEntPropVector(entity, Prop_Send, "m_vecOrigin", Pos);
ZchSpawn(Pos);
}
}
}
}
public Event_RoundStart(Handle:event, String:name[], bool:dontBroadcast)
{
new entity = MaxClients + 1;
while ((entity = FindEntityByClassname(entity, "chicken")) != -1) AcceptEntityInput(entity, "Kill");
}
public Action:OnPlayerDeath(Handle:event, const String:strName[], bool:bBroadcast)
{
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
if(victim>0 && !IsFakeClient(victim))
if(zct == 1|| zct ==3)
{
new Float:Pos[3];
GetClientAbsOrigin(victim,Pos);
ZchSpawn(Pos);
}
}
ZchSpawn(Float:pos[3])
{
new zchicken = -1;
if ((zchicken = CreateEntityByName("chicken")) != -1)
{
DispatchKeyValue(zchicken, "targetname", "zombie_chicken");
DispatchSpawn(zchicken);
SetEntityModel(zchicken,zcm);
SetEntProp(zchicken, Prop_Data, "m_iHealth",zch);
TeleportEntity( zchicken, pos, NULL_VECTOR, NULL_VECTOR);
}
}