Member
|
02-01-2014
, 09:11
Team Flash Punish
|
#1
|
hy help with tis plugin seting
you throw flash grenade who take flash die )
what i pot rong
Code:
/* Formatright © 2010, ConnorMcLeod
Team Flash Punish is free software;
you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Team Flash Punish; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <nades_api>
#tryinclude <cstrike_pdatas>
#if !defined _cbaseentity_included
#assert Cstrike Pdatas and Offsets library required! Read the below instructions: \
1. Download it at forums.alliedmods.net/showpost.php?p=1712101#post1712101 \
2. Put it into amxmodx/scripting/include/ folder \
3. Compile this plugin locally, details: wiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29 \
4. Install compiled plugin, details: wiki.amxmodx.org/index.php/Configuring_AMX_Mod_X#Installing
#endif
#define VERSION "1.2.0"
const MAX_PLAYERS = 32
new g_iMaxPlayers
#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers )
enum ( <<= 1 ) {
CountSemiFlash = 1,
CountFullFlash,
CountDeadFlasher
}
enum ( <<= 1 ) {
PunishHealth = 1,
PunishMoney
}
new Float:g_flCurrentGameTime, g_iCurrentFlasher
new g_iFlashTeamCount[MAX_PLAYERS+1]
new g_pcvarTeamFlash, g_pcvarMax, g_pcvarHealth, g_pcvarPunish, g_pcvarMoney, g_pcvarCanKill
new g_iHudTextArgs, g_iTextMsg
public plugin_init()
{
register_plugin("Team Flash Punish", VERSION, "ConnorMcLeod")
g_pcvarTeamFlash = register_cvar("tfp_count", "3") // Additive values 0: don't count, 1:count semi flash, 2:count full flash, 4:count dead flasher
g_pcvarMax = register_cvar("tfp_max_count", "3") // disallow flashbang after X count
g_pcvarPunish = register_cvar("tfp_punish", "1") // Additive values 0: don't punish, 1:health, 2:money
g_pcvarHealth = register_cvar("tfp_health_amount", "50") // health reduction
g_pcvarCanKill = register_cvar("tfp_health_allow_kill", "1") // allow health reduction to trigger kill
g_pcvarMoney = register_cvar("tfp_money_amount", "2000") // cash taken
register_event("ScreenFade", "Event_ScreenFade", "be", "4=255", "5=255", "6=255", "7=200", "7=255")
RegisterHam(Ham_Touch, "armoury_entity", "CArmouryEntity_Touch")
RegisterHam(Ham_Touch, "weaponbox", "CWeaponBox_Touch")
register_clcmd("menuselect 3", "ClientCommand_MenuSelect_3")
g_iMaxPlayers = get_maxplayers()
g_iHudTextArgs = get_user_msgid("HudTextArgs")
g_iTextMsg = get_user_msgid("TextMsg")
}
public client_putinserver(id)
{
g_iFlashTeamCount[id] = 0
}
CantBuyFlashBang(id)
{
if( CantHaveFlashbangsAnymore(id) && cs_get_user_buyzone(id) )
{
message_begin(MSG_ONE, g_iTextMsg, .player=id)
{
write_byte(print_center)
write_string("#Weapon_Not_Available")
}
message_end()
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
CantHaveFlashbangsAnymore(id)
{
new iMax = get_pcvar_num(g_pcvarMax)
return (iMax && g_iFlashTeamCount[id] >= iMax)
}
public ClientCommand_MenuSelect_3( id )
{
const EQUIP_MENU = 10
if( is_user_alive(id)
&& get_pdata_int(id, m_iMenu) == EQUIP_MENU
&& cs_get_user_buyzone(id)
&& cs_get_user_money(id) >= 200 )
{
return CantBuyFlashBang(id)
}
return PLUGIN_CONTINUE
}
public client_command( id )
{
new szCommand[7]
const FLASH_BUYALIAS_STRLEN = 5
if( is_user_alive(id) && read_argv(0, szCommand, charsmax(szCommand)) == FLASH_BUYALIAS_STRLEN && equal(szCommand, "flash") )
{
return CantBuyFlashBang(id)
}
return PLUGIN_CONTINUE
}
public Cs_InternalCommand( id, szCommand[] )
{
if( is_user_alive(id) && equal(szCommand, "flash") )
{
return CantBuyFlashBang(id)
}
return PLUGIN_CONTINUE
}
public OnFlashNadeDetonate( iEnt )
{
g_flCurrentGameTime = get_gametime()
g_iCurrentFlasher = pev(iEnt, pev_owner)
}
public Event_ScreenFade(id)
{
new Float:flGameTime = get_gametime()
if( id != g_iCurrentFlasher
&& g_flCurrentGameTime == flGameTime
&& cs_get_user_team(id) == cs_get_user_team(g_iCurrentFlasher) )
{
new bAlive = is_user_alive(g_iCurrentFlasher)
new bitCountType = get_pcvar_num(g_pcvarTeamFlash)
if( ( bAlive || bitCountType & CountDeadFlasher )
&& bitCountType & (1<<_:(read_data(7) == 255)) )
{
g_iFlashTeamCount[g_iCurrentFlasher]++
new iPunish = get_pcvar_num(g_pcvarPunish)
if( iPunish & PunishHealth && bAlive )
{
new Float:flHealth
pev(g_iCurrentFlasher, pev_health, flHealth)
flHealth -= get_pcvar_float(g_pcvarHealth)
if( flHealth < 1.0 )
{
if( get_pcvar_num(g_pcvarCanKill) )
{
user_kill(id)
bAlive = false
}
else
{
set_pev(g_iCurrentFlasher, pev_health, 1.0)
}
}
else
{
set_pev(g_iCurrentFlasher, pev_health, flHealth)
}
}
if( iPunish & PunishMoney )
{
new iMoney = max(cs_get_user_money(g_iCurrentFlasher) - get_pcvar_num(g_pcvarMoney), 0)
cs_set_user_money(g_iCurrentFlasher, iMoney, 1)
}
}
const m_flNextHudTextArgsGameTime = 198
if( bAlive && get_pdata_float(id, m_flNextHudTextArgsGameTime) < flGameTime )
{
set_pdata_float(id, m_flNextHudTextArgsGameTime, flGameTime + 5.0)
message_begin(MSG_ONE, g_iHudTextArgs, .player=g_iCurrentFlasher)
{
write_string("#Hint_try_not_to_injure_teammates")
write_byte(1)
write_byte(0)
}
message_end()
}
}
}
public CArmouryEntity_Touch(iArmoury, id)
{
if( IsPlayer(id) && is_user_alive(id) && cs_get_armoury_type(iArmoury) == CSW_FLASHBANG && CantHaveFlashbangsAnymore(id) )
{
return HAM_SUPERCEDE
}
return HAM_IGNORED
}
public CWeaponBox_Touch(iWeaponBox, id)
{
if( IsPlayer(id) && is_user_alive(id) )
{
new iWeapon = get_pdata_cbase(iWeaponBox, m_rgpPlayerItems_CWeaponBox[4], XO_CWEAPONBOX)
if( iWeapon > 0 && cs_get_weapon_id(iWeapon) == CSW_FLASHBANG && CantHaveFlashbangsAnymore(id) )
{
return HAM_SUPERCEDE
}
}
return HAM_IGNORED
}
Nades Api i instal
Code:
#include <amxmodx>
#include <fakemeta_stocks>
#include <hamsandwich>
#tryinclude <cstrike_pdatas>
#if !defined _cbaseentity_included
#assert Cstrike Pdatas and Offsets library required! Read the below instructions: \
1. Download it at forums.alliedmods.net/showpost.php?p=1712101#post1712101 \
2. Put it into amxmodx/scripting/include/ folder \
3. Compile this plugin locally, details: wiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29 \
4. Install compiled plugin, details: wiki.amxmodx.org/index.php/Configuring_AMX_Mod_X#Installing
#endif
#define PLUGIN "Nades Api"
#define VERSION "0.0.1"
#define GetThink(%0) get_pdata_int(%0, m_pfnThink, 0)
#define GetTouch(%0) get_pdata_int(%0, m_pfnTouch, 1)
new const grenade[] = "grenade"
new TumbleThink, Detonate, Smoke, Detonate3, Smoke3_C, SG_TumbleThink, SG_Detonate, SG_Smoke
new BounceTouch
new Float:g_flTime
new g_iCurrentSetModelEntity
new g_iBot
new g_iReturn
const INVALID_FORWARD = -1
new g_iBounceTouch_He = INVALID_FORWARD,
g_iBounceTouch_Flash = INVALID_FORWARD,
g_iBounceTouch_Smoke = INVALID_FORWARD,
g_iTumbleThink_He = INVALID_FORWARD,
g_iTumbleThink_Flash = INVALID_FORWARD,
g_iDetonate = INVALID_FORWARD,
g_iSmoke = INVALID_FORWARD,
g_iDetonate3 = INVALID_FORWARD,
g_iSmoke3_C = INVALID_FORWARD,
g_iSG_TumbleThink = INVALID_FORWARD,
g_iSG_Detonate = INVALID_FORWARD,
g_iSG_Smoke = INVALID_FORWARD
public plugin_init()
{
register_plugin(PLUGIN, VERSION, "ConnorMcLeod")
set_task(1.0, "InitNades")
}
public plugin_natives()
{
register_library("nades_api")
register_native("Get_Nade_TumbleThink", "Get_Nade_TumbleThink")
register_native("Get_Nade_BounceTouch", "Get_Nade_BounceTouch")
register_native("Get_Nade_Detonate", "Get_Nade_Detonate")
register_native("Get_Nade_Smoke", "Get_Nade_Smoke")
register_native("Get_Nade_Detonate3", "Get_Nade_Detonate3")
register_native("Get_Nade_Smoke3_C", "Get_Nade_Smoke3_C")
register_native("Get_Nade_SG_TumbleThink", "Get_Nade_SG_TumbleThink")
register_native("Get_Nade_SG_Detonate", "Get_Nade_SG_Detonate")
register_native("Get_Nade_SG_Smoke", "Get_Nade_SG_Smoke")
}
public Get_Nade_TumbleThink() return TumbleThink
public Get_Nade_BounceTouch() return BounceTouch
public Get_Nade_Detonate() return Detonate
public Get_Nade_Smoke() return Smoke
public Get_Nade_Detonate3() return Detonate3
public Get_Nade_Smoke3_C() return Smoke3_C
public Get_Nade_SG_TumbleThink() return SG_TumbleThink
public Get_Nade_SG_Detonate() return SG_Detonate
public Get_Nade_SG_Smoke() return SG_Smoke
public InitNades()
{
new nade
new name[] = "player", reason[128]
g_iBot = EF_CreateFakeClient(name)
EF_FreeEntPrivateData(g_iBot)
DF_ClientConnect(g_iBot, name, "127.0.0.1", reason )
DF_ClientPutInServer(g_iBot)
g_flTime = get_gametime()
// FLASH
nade = CreateAndStoreWeapon("weapon_flashbang")
TumbleThink = GetThink( nade )
BounceTouch = GetTouch( nade )
set_pev(nade, pev_dmgtime, g_flTime)
ExecuteHam(Ham_Think, nade)
Detonate = GetThink( nade )
ExecuteHam(Ham_Think, nade)
Smoke = GetThink( nade )
set_pev(nade, pev_flags, FL_KILLME)
// HE
nade = CreateAndStoreWeapon("weapon_hegrenade")
set_pev(nade, pev_dmgtime, g_flTime)
ExecuteHam(Ham_Think, nade)
Detonate3 = GetThink( nade )
ExecuteHam(Ham_Think, nade)
Smoke3_C = GetThink( nade )
set_pev(nade, pev_flags, FL_KILLME)
// SMOKE
nade = CreateAndStoreWeapon("weapon_smokegrenade")
SG_TumbleThink = GetThink( nade )
set_pev(nade, pev_dmgtime, g_flTime)
set_pev(nade, pev_flags, pev(nade, pev_flags) | FL_ONGROUND)
ExecuteHam(Ham_Think, nade)
SG_Detonate = GetThink( nade )
ExecuteHam(Ham_Think, nade)
SG_Smoke = GetThink( nade )
server_cmd("kick #%d", get_user_userid(g_iBot))
Create_Forwards()
}
CreateAndStoreWeapon(const class[])
{
new weapon = EF_CreateNamedEntity(EF_AllocString(class))
set_pdata_float(weapon, m_flStartThrow, g_flTime, 4)
set_pdata_float(weapon, m_flTimeWeaponIdle, 0.0, XO_CBASEPLAYERWEAPON)
set_pdata_cbase(weapon, m_pPlayer, g_iBot, XO_CBASEPLAYERITEM)
new iSetModelHook = register_forward(FM_SetModel, "OnSetModel_Post", true)
ExecuteHam(Ham_Weapon_WeaponIdle, weapon)
unregister_forward(FM_SetModel, iSetModelHook, true)
if( pev_valid(weapon) )
{
EF_RemoveEntity(weapon)
}
return g_iCurrentSetModelEntity
}
public OnSetModel_Post(iEnt, szModel[])
{
g_iCurrentSetModelEntity = iEnt
}
Create_Forwards()
{
new OnFlashNadenadeBounceTouch[] = "OnFlashNadenadeBounceTouch"
new OnHeNadenadeBounceTouch[] = "OnHeNadenadeBounceTouch"
new OnSmokeNadenadeBounceTouch[] = "OnSmokeNadenadeBounceTouch"
new OnHeNadeTumbleThink[] = "OnHeNadeTumbleThink"
new OnFlashNadeTumbleThink[] = "OnFlashNadeTumbleThink"
new OnFlashNadeDetonate[] = "OnFlashNadeDetonate"
new OnFlashNadeSmoke[] = "OnFlashNadeSmoke"
new OnHeNadeDetonate[] = "OnHeNadeDetonate"
new OnHeNadeSmoke[] = "OnHeNadeSmoke"
new OnSmokeNadeTumbleThink[] = "OnSmokeNadeTumbleThink"
new OnSmokeNadeDetonate[] = "OnSmokeNadeDetonate"
new OnSmokeNadeSmoke[] = "OnSmokeNadeSmoke"
new pluginsNum = get_pluginsnum()
for(new pluginIndex; pluginIndex<pluginsNum; pluginIndex++)
{
if( g_iBounceTouch_He == INVALID_FORWARD && get_func_id(OnHeNadenadeBounceTouch, pluginIndex) != -1 )
{
g_iBounceTouch_He = CreateMultiForward(OnHeNadenadeBounceTouch, ET_CONTINUE, FP_CELL, FP_CELL)
RegisterNadeTouch()
}
if( g_iBounceTouch_Flash == INVALID_FORWARD && get_func_id(OnFlashNadenadeBounceTouch, pluginIndex) != -1 )
{
g_iBounceTouch_Flash = CreateMultiForward(OnFlashNadenadeBounceTouch, ET_CONTINUE, FP_CELL, FP_CELL)
RegisterNadeTouch()
}
if( g_iBounceTouch_Smoke == INVALID_FORWARD && get_func_id(OnSmokeNadenadeBounceTouch, pluginIndex) != -1 )
{
g_iBounceTouch_Smoke = CreateMultiForward(OnSmokeNadenadeBounceTouch, ET_CONTINUE, FP_CELL, FP_CELL)
RegisterNadeTouch()
}
if( g_iTumbleThink_He == INVALID_FORWARD && get_func_id(OnHeNadeTumbleThink, pluginIndex) != -1 )
{
g_iTumbleThink_He = CreateMultiForward(OnHeNadeTumbleThink, ET_CONTINUE, FP_CELL)
RegisterNadeThink()
}
if( g_iTumbleThink_Flash == INVALID_FORWARD && get_func_id(OnFlashNadeTumbleThink, pluginIndex) != -1 )
{
g_iTumbleThink_Flash = CreateMultiForward(OnFlashNadeTumbleThink, ET_CONTINUE, FP_CELL)
RegisterNadeThink()
}
if( g_iDetonate == INVALID_FORWARD && get_func_id(OnFlashNadeDetonate, pluginIndex) != -1 )
{
g_iDetonate = CreateMultiForward(OnFlashNadeDetonate, ET_CONTINUE, FP_CELL)
RegisterNadeThink()
}
if( g_iSmoke == INVALID_FORWARD && get_func_id(OnFlashNadeSmoke, pluginIndex) != -1 )
{
g_iSmoke = CreateMultiForward(OnFlashNadeSmoke, ET_CONTINUE, FP_CELL)
RegisterNadeThink()
}
if( g_iDetonate3 == INVALID_FORWARD && get_func_id(OnHeNadeDetonate, pluginIndex) != -1 )
{
g_iDetonate3 = CreateMultiForward(OnHeNadeDetonate, ET_CONTINUE, FP_CELL)
RegisterNadeThink()
}
if( g_iSmoke3_C == INVALID_FORWARD && get_func_id(OnHeNadeSmoke, pluginIndex) != -1 )
{
g_iSmoke3_C = CreateMultiForward(OnHeNadeSmoke, ET_CONTINUE, FP_CELL)
RegisterNadeThink()
}
if( g_iSG_TumbleThink == INVALID_FORWARD && get_func_id(OnSmokeNadeTumbleThink, pluginIndex) != -1 )
{
g_iSG_TumbleThink = CreateMultiForward(OnSmokeNadeTumbleThink, ET_CONTINUE, FP_CELL)
RegisterNadeThink()
}
if( g_iSG_Detonate == INVALID_FORWARD && get_func_id(OnSmokeNadeDetonate, pluginIndex) != -1 )
{
g_iSG_Detonate = CreateMultiForward(OnSmokeNadeDetonate, ET_CONTINUE, FP_CELL)
RegisterNadeThink()
}
if( g_iSG_Smoke == INVALID_FORWARD && get_func_id(OnSmokeNadeSmoke, pluginIndex) != -1 )
{
g_iSG_Smoke = CreateMultiForward(OnSmokeNadeSmoke, ET_CONTINUE, FP_CELL)
RegisterNadeThink()
}
}
}
RegisterNadeThink()
{
static bool:bRegistered = false
if( !bRegistered )
{
RegisterHam(Ham_Think, grenade, "OnCGrenade_Think", false)
bRegistered = true
}
}
RegisterNadeTouch()
{
static bool:bRegistered = false
if( !bRegistered )
{
RegisterHam(Ham_Touch, grenade, "OnCGrenade_Touch", false)
bRegistered = true
}
}
public OnCGrenade_Think( ent )
{
new iThink = GetThink( ent )
new iForward = INVALID_FORWARD
switch( GetGrenadeType(ent, false) )
{
case CSW_FLASHBANG:
{
if( iThink == TumbleThink ) iForward = g_iTumbleThink_Flash
else if( iThink == Detonate ) iForward = g_iDetonate
else if( iThink == Smoke ) iForward = g_iSmoke
}
case CSW_HEGRENADE:
{
if( iThink == TumbleThink ) iForward = g_iTumbleThink_He
else if( iThink == Detonate3 ) iForward = g_iDetonate3
else if( iThink == Smoke3_C ) iForward = g_iSmoke3_C
}
case CSW_SMOKEGRENADE:
{
if( iThink == SG_TumbleThink ) iForward = g_iSG_TumbleThink
else if( iThink == SG_Detonate ) iForward = g_iSG_Detonate
else if( iThink == SG_Smoke ) iForward = g_iSG_Smoke
}
}
if( iForward != INVALID_FORWARD )
{
ExecuteForward(iForward, g_iReturn, ent)
if( g_iReturn > PLUGIN_CONTINUE )
{
return HAM_SUPERCEDE
}
}
return HAM_IGNORED
}
public OnCGrenade_Touch( ent, pOther )
{
if( GetTouch(ent) == BounceTouch )
{
g_iReturn = 0
new iForward = INVALID_FORWARD
switch( GetGrenadeType(ent, false) )
{
case CSW_FLASHBANG: iForward = g_iBounceTouch_Flash
case CSW_HEGRENADE: iForward = g_iBounceTouch_He
case CSW_SMOKEGRENADE: iForward = g_iBounceTouch_Smoke
}
if( iForward != INVALID_FORWARD )
{
ExecuteForward(iForward, g_iReturn, ent, pOther)
if( g_iReturn )
{
return HAM_SUPERCEDE
}
}
}
return HAM_IGNORED
}
GetGrenadeType( ent, bool:bCheckClass = true )
{
if( bCheckClass )
{
new class[9]
pev(ent, pev_classname, class, charsmax(class))
// if( !equal(class, "grenade") )
if( !equal(class, grenade) )
{
return 0
}
}
if( get_pdata_bool(ent, m_bIsC4) )
{
return CSW_C4
}
new usEvent = get_pdata_short(ent, m_usEvent_Grenade)
if( !usEvent )
{
return CSW_FLASHBANG
}
static m_usHgrenExplo // , m_usSmokeExplo
if( !m_usHgrenExplo )
{
m_usHgrenExplo = EF_PrecacheEvent(1, "events/createexplo.sc")
// m_usSmokeExplo = EF_PrecacheEvent(1, "events/createsmoke.sc")
}
return usEvent == m_usHgrenExplo ? CSW_HEGRENADE : CSW_SMOKEGRENADE
}
Last edited by strikegino; 02-01-2014 at 09:13.
|
|