Re: Single shot deagle
Quote:
Originally Posted by Depresie
(Post 2505790)
Hook the shooting event in post, then just set the user's clip to 0
|
EFFx's code, problem is I shoot infinite times without reloading
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <fakemeta>
#include <fun>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
#define set_deagle_single_clip(%1) set_pdata_int(%1, OFFSET_CLIPAMMO, DEAGLE_CLIP, OFFSET_LINUX_WEAPONS)
const CHANCE_REQUIRED = 5
const DEAGLE_CLIP = 1
const OFFSET_CLIPAMMO = 51
const OFFSET_LINUX_WEAPONS = 4
const m_pPlayer = 41
const m_pActiveItem = 373
new bool:g_bIsDeagleRound
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_TakeDamage, "player", "HamPlayerTakeDamage_Post", 0)
RegisterHam(Ham_Spawn, "player", "HamPlayerSpawn_Post", 1)
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_deagle", "HamDeaglePrimaryAttackPre", 0)
register_event("SendAudio", "event_CTWin", "a", "1=0", "2=%!MRAD_ctwin")
register_event("SendAudio", "event_TWin", "a", "1=0", "2=%!MRAD_terwin")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
}
public Dgl(id) {
g_bIsDeagleRound = true
}
public event_CTWin()
{
if(g_bIsDeagleRound)
{
g_bIsDeagleRound = false
client_print(0, print_chat, "[Deagle Round]: Counter-Terrorists has won the Deagle round. Finishing the event...")
}
}
public event_TWin()
{
if(g_bIsDeagleRound)
{
g_bIsDeagleRound = false
client_print(0, print_chat, "[Deagle Round]: Terrorists has won the Deagle round. Finishing the event...")
}
}
public HamPlayerTakeDamage_Post(iAttacker, iInflictor, iVictim)
{
if(!g_bIsDeagleRound)
return HAM_IGNORED
if(!is_user_connected(iAttacker) || !is_user_connected(iVictim))
return HAM_IGNORED
SetHamParamFloat(4, 999.9)
return HAM_IGNORED
}
public HamPlayerSpawn_Post(id)
{
if(g_bIsDeagleRound)
{
if(is_user_alive(id))
{
cs_set_user_money(id, 0)
strip_user_weapons(id)
give_item(id, "weapon_deagle")
cs_set_user_bpammo(id, CSW_DEAGLE, 0)
set_deagle_single_clip(get_pdata_cbase(id, m_pActiveItem))
}
}
}
public HamDeaglePrimaryAttackPre(iWeapon)
{
new id = get_pdata_cbase(iWeapon, m_pPlayer, OFFSET_LINUX_WEAPONS)
if(!is_user_connected(id))
return HAM_IGNORED
set_deagle_single_clip(get_pdata_cbase(id, m_pActiveItem))
return HAM_IGNORED
}
public event_round_start()
{
if(!g_bIsDeagleRound)
{
if(IsNecessaryChance(CHANCE_REQUIRED))
{
g_bIsDeagleRound = true
client_print(0, print_chat, "[Deagle Round]: Deagle round percent (%d%) was hit. Starting the Deagle Round...", CHANCE_REQUIRED)
server_cmd("sv_restart 3")
}
}
}
IsNecessaryChance(const Chance)
{
new iRandom = random_num(0, 100)
return (iRandom < Chance) ? true : false
}
|