PHP Code:
/* Formatright © 2010, ConnorMcLeod
This plugin 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 this plugin; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#define VERSION "0.0.1"
#define PLUGIN "He Bonus"
#define MAX_PLAYERS 32
new Float:g_flEndProcessGameTime[MAX_PLAYERS+1]
new g_pCvarTime
public plugin_init()
{
register_plugin(PLUGIN, VERSION, "ConnorMcLeod")
RegisterHam(Ham_Spawn, "player", "CBasePlayer_Spawn_Post", true)
RegisterHam(Ham_Killed, "player", "CBasePlayer_Killed_Post", true)
g_pCvarTime = register_cvar("he_bonus_time", "3.5")
}
public CBasePlayer_Killed_Post( id )
{
if( g_flEndProcessGameTime[id] )
{
reset(id)
}
}
public CBasePlayer_Spawn_Post( id )
{
if( is_user_alive(id) && g_flEndProcessGameTime[id] )
{
reset(id)
}
}
reset(id)
{
g_flEndProcessGameTime[id] = 0.0
Make_BarTime2(id)
}
public client_PreThink(id)
{
if( !is_user_alive(id) )
{
return
}
static iButtons
static BUTTONS_REQUIRED = IN_ATTACK2|IN_DUCK
iButtons = pev(id, pev_button)
if( iButtons & BUTTONS_REQUIRED == BUTTONS_REQUIRED && !user_has_weapon(id, CSW_HEGRENADE) )
{
if( !g_flEndProcessGameTime[id] )
{
new Float:flTime = get_pcvar_float(g_pCvarTime)
g_flEndProcessGameTime[id] = get_gametime() + flTime
Make_BarTime2_f(id, flTime)
}
else if( get_gametime() >= g_flEndProcessGameTime[id] )
{
g_flEndProcessGameTime[id] = 0.0
give_item(id, "weapon_hegrenade")
}
}
else if( g_flEndProcessGameTime[id] )
{
reset(id)
}
}
Make_BarTime2_f(id, Float:flSeconds)
{
new iSeconds = floatround(flSeconds, floatround_ceil)
Make_BarTime2(id, iSeconds, 100 - floatround( (flSeconds/iSeconds) * 100 ))
}
Make_BarTime2(id, iSeconds=0, iPercent=0)
{
static msgBarTime2
message_begin(MSG_ONE_UNRELIABLE, msgBarTime2 ? msgBarTime2 : (msgBarTime2 = get_user_msgid("BarTime2")), .player=id)
write_short(iSeconds)
write_short(iPercent)
message_end()
}
__________________