Код: Выделить всё
#include <sourcemod>
#include <sdktools_functions>
#include <sdktools>
#include <hacks>
#define VERSION "1.0"
#define GREEN 0x04
new Handle:pistol_Switch;
new String:Weapon[60];
new Handle:kLIMIT;
new gRestrict[MAXPLAYERS+1];
new zRestrict[MAXPLAYERS+1];
new Count[MAXPLAYERS+1];
new bool: pistol_aRestrict[MAXPLAYERS+1];
public Plugin:myinfo =
{
name = "Pistols for zombie",
author = "TPOLI,KUU[B/IKCM]",
description = "Give pistols zombie",
version = VERSION,
url = "www.sourcemod.net"
};
public OnPluginStart()
{
pistol_Switch = CreateConVar("pistols_on","1","Turns the plugin on and off 1/0",FCVAR_NOTIFY);
kLIMIT = CreateConVar("limit_for_pistols", "3", "Max amount of kill for pistol");
HookEvent("player_death",DeathEvent);
HookEvent("weapon_fire",WeaponEvent);
HookEvent("player_spawn", PlayerSpawn);
}
public DeathEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
GetEventString(event,"weapon",Weapon,60);
new clientid = GetEventInt(event,"attacker");
new client = GetClientOfUserId(clientid);
if(StrEqual(Weapon,"zombie_claws_of_death")== true && GetConVarInt(pistol_Switch)== 1)
{
new count = Count[client];
new limit = GetConVarInt(kLIMIT);
if (count < limit)
{
Count[client]++;
}
else
{
ClientHookUse(client);
ClientHookUse2(client);
GivePlayerItem(client, "weapon_elite");
ClientUnHookUse(client);
Count[client] = 0;
pistol_aRestrict[client] = true;
}
}
}
public WeaponEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
GetEventString(event,"weapon",Weapon,30);
new clientid = GetEventInt(event,"userid");
new client = GetClientOfUserId(clientid);
if(StrEqual(Weapon,"elite")== true && pistol_aRestrict[client] == true)
{
FakeClientCommandEx(client, "drop");
pistol_aRestrict[client] = false;
ClientUnHookUse2(client);
GivePlayerItem(client, "weapon_knife");
}else if(StrEqual(Weapon,"elite")== true && GetClientHealth(client) > 100)
{
FakeClientCommandEx(client, "drop");
pistol_aRestrict[client] = false;
ClientUnHookUse2(client);
GivePlayerItem(client, "weapon_knife");
}
}
public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new index = GetClientOfUserId(GetEventInt(event, "userid"));
Count[index] = 1;
pistol_aRestrict[index] = false;
}
//*****************************************************************************************************************************
public Weapon_CanUse(client, weapon, dummy1, dummy2, dummy3, dummy4)
{
new String:weaponname[32];
GetEdictClassname(weapon, weaponname, sizeof(weaponname));
ReplaceString(weaponname, sizeof(weaponname), "weapon_", "");
if (StrEqual(weaponname, "elite"))
{
return 1;
}
return Hacks_Continue;
}
ClientHookUse(client)
{
gRestrict[client] = Hacks_Hook(client, HACKS_HTYPE_WEAPON_CANUSE, Weapon_CanUse, false);
}
ClientHookUse2(client)
{
zRestrict[client] = Hacks_Hook(client, HACKS_HTYPE_WEAPON_CANSWITCHTO, Weapon_CanUse, false);
}
ClientUnHookUse(client)
{
Hacks_Unhook(gRestrict[client]);
}
ClientUnHookUse2(client)
{
Hacks_Unhook(zRestrict[client]);
}
public OnClientDisconnect(client)
{
if(IsClientInGame(client)== true)
{
ClientHookUse2(client);
}
}
public bool:OnClientConnect(client)
{
if(IsClientInGame(client)== true)
{
ClientHookUse2(client);
}
return true;
}