Raised This Month: $51 Target: $400
 12% 

Give he nade when crouched


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FuZ!on
Senior Member
Join Date: Aug 2007
Old 11-08-2011 , 11:35   Give he nade when crouched
Reply With Quote #1

I've been trying to code something for a while now and it's just not working out for me so I'm just going to ask it here.

I think it should be a fairly simple plugin but I just don't have the knowledge right now to do it.

Request:

When a player is crouching and holding attack2 (usually right click) after three seconds or so, they receive a HE nade. And if possible, some sort of countdown or defuse bar showing how much time is left until the nade is given. (A HUD countdown would be just as good)

No cvars need to be added if you don't want.

Thanks in advanced.
FuZ!on is offline
Old 11-08-2011, 11:55
kramesa
This message has been deleted by kramesa.
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-08-2011 , 13:12   Re: Give he nade when crouched
Reply With Quote #2

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(PLUGINVERSION"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_Postid )
{
    if( 
g_flEndProcessGameTime[id] )
    {
        
reset(id)
    }
}

public 
CBasePlayer_Spawn_Postid )
{
    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(idpev_button)
    if( 
iButtons BUTTONS_REQUIRED == BUTTONS_REQUIRED && !user_has_weapon(idCSW_HEGRENADE) )
    {
        if(  !
g_flEndProcessGameTime[id] )
        {
            new 
Float:flTime get_pcvar_float(g_pCvarTime)
            
g_flEndProcessGameTime[id] = get_gametime() + flTime
            Make_BarTime2_f
(idflTime)
        }
        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(idFloat:flSeconds)
{
    new 
iSeconds floatround(flSecondsfloatround_ceil)
    
Make_BarTime2(idiSeconds100 floatround( (flSeconds/iSeconds) * 100 ))
}

Make_BarTime2(idiSeconds=0iPercent=0)
{
    static 
msgBarTime2
    message_begin
(MSG_ONE_UNRELIABLEmsgBarTime2 msgBarTime2 : (msgBarTime2 get_user_msgid("BarTime2")), .player=id)
    
write_short(iSeconds)
    
write_short(iPercent)
    
message_end()

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
FuZ!on
Senior Member
Join Date: Aug 2007
Old 11-08-2011 , 14:36   Re: Give he nade when crouched
Reply With Quote #3

Thank you Connor.

Works like a charm.
FuZ!on is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:20.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode