#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <colors>
#include <zombiereloaded>
new g_list[65][3][2]; //stores how many grenades of what type have exploded for every client - 0 grenades used, 1 kills
new String: weaponlist[][] = { "hegrenade", "flashbang"};
new neededlist[3] = {3,5}; //needed kills to get another item of the type listed above
new nademode = 1;
new me_enable = 1;
new HpAdd = 100;
new MaxHp = 1000;
new Announce = 1;
new Handle:cv_Enabled;
new Handle:cv_HpAdd;
new Handle:cv_MaxHp;
new Handle:cv_Announce;
new Handle:cv_needed_HE;
new Handle:cv_needed_flash;
//new Handle:cv_needed_smoke;
new Handle:cv_nademode;
#define PLUGIN_VERSION "1.0.5"
public Plugin:myinfo =
{
name = "Kill Bonus",
author = "",
description = "Gives someone Hp & Grenade on a kill",
version = PLUGIN_VERSION,
url = "www.hlmod.ru"
}
public OnPluginStart()
{
CreateConVar("kb_version", PLUGIN_VERSION, "Kill Bonus Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
cv_Enabled = CreateConVar("kb_enabled", "1", "Enables - Disables the Kill bonus plugin", FCVAR_NOTIFY);
cv_HpAdd = CreateConVar("kb_hp", "100", " when the someone kills someone", FCVAR_NOTIFY);
cv_MaxHp = CreateConVar("kb_maxhp", "1000", "the max hp that", FCVAR_NOTIFY);
cv_needed_HE = CreateConVar("kb_needed_HE", "3", "Kills needed to recieve hegrenade, 0 = disable", FCVAR_NOTIFY);
cv_needed_flash = CreateConVar("kb_needed_flash", "5", "Kills needed to recieve flashbang, 0 = disable", FCVAR_NOTIFY);
//cv_needed_smoke = CreateConVar("kb_needed_smoke", "0", "Kills needed to recieve smokegrenade, 0 = disable", FCVAR_NOTIFY);
cv_nademode = CreateConVar("kb_nademode", "1", "0 = replenish used nades only, 1 = always give nade /n(useful in conjunction with SM plugin 'Grenade Pack')", FCVAR_NOTIFY);
cv_Announce = CreateConVar("kb_announce", "1", "Enables - Disables announce", FCVAR_NOTIFY);
if(me_enable)
{
HookEvent("player_death", Event_PlayerDeath);
HookEvent("round_start", Event_RoundStart);
//HookEvent("weapon_fire", EventWeaponFire);
}
LoadTranslations("plugin.killbonus");
HpAdd = GetConVarInt(cv_HpAdd);
MaxHp = GetConVarInt(cv_MaxHp);
nademode = GetConVarInt(cv_nademode);
Announce = GetConVarInt(cv_Announce);
neededlist[0] = GetConVarInt(cv_needed_HE);
neededlist[1] = GetConVarInt(cv_needed_flash);
//neededlist[2] = GetConVarInt(cv_needed_smoke);
me_enable = GetConVarInt(cv_Enabled);
AutoExecConfig(true, "Kill_Bonus");
}
public OnConfigsExecuted()
{
me_enable = GetConVarInt(cv_Enabled);
//HsAdd = GetConVarInt(cv_HsAdd);
//HgAdd = GetConVarInt(cv_HgAdd);
//HkAdd = GetConVarInt(cv_HkAdd);
HpAdd = GetConVarInt(cv_HpAdd);
MaxHp = GetConVarInt(cv_MaxHp);
nademode = GetConVarInt(cv_nademode);
Announce = GetConVarInt(cv_Announce);
neededlist[0] = GetConVarInt(cv_needed_HE);
neededlist[1] = GetConVarInt(cv_needed_flash);
//neededlist[2] = GetConVarInt(cv_needed_smoke);
}
public EnableChanged(Handle:convar, const String:oldValue[], const String:newValue[])
{
new iNew = StringToInt(newValue);
new iOld = StringToInt(oldValue);
if (iNew == iOld)
return;
if (iNew == 1)
{
me_enable = 1;
ResetAll();
}
else
me_enable = 0;
}
get_weapon_index(const String: weapon_name[])
{
new loop_break = 0;
new index = 0;
while ((loop_break == 0) && (index < sizeof(weaponlist)))
{
if (strcmp(weapon_name, weaponlist[index], true) == 0)
loop_break++;
index++;
}
if (loop_break == 0)
return -1;
else
return index - 1;
}
public Action:EventWeaponFire(Handle:event, const String:name[], bool:dontBroadcast)
{
if (me_enable == 0 || nademode == 1)
return Plugin_Continue;
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (client < 1)
return Plugin_Continue;
new String:weapon[64];
GetEventString(event, "weapon", weapon, 64);
new weapon_index = get_weapon_index(weapon);
if (weapon_index == -1)
return Plugin_Continue;
g_list[client][weapon_index][0]++;
return Plugin_Continue;
}
public OnClientPutInServer(client)
{
if(me_enable == 0)
return;
ResetClient(client);
}
ResetAll()
{
for (new i = 1; i <= MaxClients; i++)
{
ResetClient(i);
}
}
ResetClient(client)
{
for (new j = 0; j < 3; j++)
{
g_list[client][j][0] = 0;
g_list[client][j][1] = 0;
}
}
public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
if(me_enable == 0)
return;
ResetAll();
}
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
if(attacker == 0)
{
return;
}
new Max = MaxHp;
new CurrentHp = GetClientHealth(attacker);
new adverts = Announce;
new client = GetClientOfUserId(GetEventInt(event, "attacker"));
if(IsPlayerAlive(client) && ZR_IsClientZombie(client))
{
new Hp = HpAdd;
if((CurrentHp + Hp) > Max)
{
SetEntProp(attacker, Prop_Send, "m_iHealth", Max);
}
else
{
SetEntProp(attacker, Prop_Send, "m_iHealth", Hp + CurrentHp);
if (adverts)
CPrintToChat(attacker, "%t", "killhp", Hp);
}
}
//new client = attacker;
//new client = GetClientOfUserId(GetEventInt(event, "attacker"));
if(IsPlayerAlive(client) && ZR_IsClientHuman(client))
{
for (new j = 0; j < 3; j++)
{
if(neededlist[j] == 0)
continue;
g_list[client][j][1]++;
if(g_list[client][j][1] >= neededlist[j])
{
if((g_list[client][j][0] > 0 && nademode == 0) || nademode == 1)
{
g_list[client][j][1] = 0;
if(nademode == 0)
g_list[client][j][0]--;
new String:ent_weapon[64];
Format(ent_weapon, sizeof(ent_weapon), "weapon_%s", weaponlist[j]);
GivePlayerItem(client, ent_weapon);
if (adverts)
{
CPrintToChat(attacker, "%t", "Giving Grenade", weaponlist[j]);
}
}
}
}
}
ResetClient(victim);
}