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

Reload bar (how to?)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
newb1e
Junior Member
Join Date: Feb 2016
Old 02-09-2016 , 22:22   Reload bar (how to?)
Reply With Quote #1

https://forums.alliedmods.net/showthread.php?p=220167
can't understand the source of that plugin, but can anyone explaine how can i create an reload bar?
If i press and hold "E" (3 seconds/cvar) while aiming to player, the bar will appear and after that 3 seconds do some stuff. but if i stop pressing the bar will dissapear (cancel).

Last edited by newb1e; 02-09-2016 at 22:44.
newb1e is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-10-2016 , 03:25   Re: Reload bar (how to?)
Reply With Quote #2

You have to send a BarTime message. To clear the message send another one with 0 as duration.
__________________
HamletEagle is offline
newb1e
Junior Member
Join Date: Feb 2016
Old 02-10-2016 , 06:21   Re: Reload bar (how to?)
Reply With Quote #3

none of thiose functions is working

PHP Code:
#include < amxmodx >
//#include < hamsandwich >

new g_iBarTimeg_iBarTime2 

public plugin_init( )
{
    
//RegisterHam( Ham_Use, "func_button", "FwdUseButton" );
    
    
g_iBarTime get_user_msgid("BarTime"
    
g_iBarTime2 get_user_msgid("BarTime2")
    
    
register_clcmd("say /bar""Bar_Test")
}

public 
Bar_Test(id)
{
 if(
is_user_alive(id))
  {
    
Make_BarTime(id)
   }
   return 
PLUGIN_CONTINUE
  
}

Make_BarTime(idiSeconds

    
message_begin(MSG_ONE_UNRELIABLEg_iBarTime, .player=id
    
write_short(iSeconds
    
message_end() 


Make_BarTime2(idFloat:flSeconds

    new 
iRoundedSeconds floatround(flSecondsfloatround_ceil
    new 
iStartPercent floatround((1.0-(flSeconds iRoundedSeconds))*100
    
message_begin(MSG_ONE_UNRELIABLEg_iBarTime2, .player=id
    
write_short(iRoundedSeconds
    
write_short(iStartPercent
    
message_end() 
}

/*

public FwdUseButton( iEntity, iPlayer, iActivator, iUseType, Float:flValue )
{
    if( !is_user_alive( iPlayer )
    ||  iUseType != 2
    ||  flValue != 1.0 )
    {
        return HAM_IGNORED;
    }
    
    client_print( iPlayer, print_chat, "Button Entity: %i", iEntity );
    
    return HAM_IGNORED;
}
*/ 
newb1e is offline
Old 02-10-2016, 06:47
Arkshine
This message has been deleted by Arkshine. Reason: nvm
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 02-10-2016 , 07:18   Re: Reload bar (how to?)
Reply With Quote #4

Find lasermine plugin's setlaser function, it has the reload bar.

Last edited by siriusmd99; 02-10-2016 at 07:19.
siriusmd99 is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 02-10-2016 , 07:30   Re: Reload bar (how to?)
Reply With Quote #5

PHP Code:
#include <amxmodx>

new g_iBarTime

public plugin_init( )
{   
    
register_clcmd"say /bar""Make_BarTime" )
    
    
g_iBarTime get_user_msgid"BarTime" 


public 
Make_BarTimeid 

    
message_begin(MSG_ONE_UNRELIABLEg_iBarTime,_id 
    
write_short// This is the duration. 
    
message_end() 

__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
newb1e
Junior Member
Join Date: Feb 2016
Old 02-10-2016 , 12:14   Re: Reload bar (how to?)
Reply With Quote #6

Quote:
Originally Posted by wickedd View Post
PHP Code:
#include <amxmodx>

new g_iBarTime

public plugin_init( )
{   
    
register_clcmd"say /bar""Make_BarTime" )
    
    
g_iBarTime get_user_msgid"BarTime" 


public 
Make_BarTimeid 

    
message_begin(MSG_ONE_UNRELIABLEg_iBarTime,_id 
    
write_short// This is the duration. 
    
message_end() 

Exatly! Thank you!
But what is the correct way to make this?:
pressing the +use key when aiming a player?
I want to press E and do some stuff
newb1e is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 02-10-2016 , 14:47   Re: Reload bar (how to?)
Reply With Quote #7

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

new g_iBarTime

public plugin_init( )
{   
    
register_forwardFM_PlayerPreThink"test" )
    
register_clcmd"say /bar""Make_BarTime" )
    
    
g_iBarTime get_user_msgid"BarTime" )


public 
testid )
{
    new 
newidbody
    get_user_aiming
idnewidbody )
    
    new 
zButton get_user_buttonid )
    
    if( 
is_user_connectednewid ) && ( zButton IN_USE )  )
    {
        
Make_BarTimeid )
    }
}

public 
Make_BarTimeid 

    
message_begin(MSG_ONE_UNRELIABLEg_iBarTime,_id 
    
write_short// This is the duration.
    
message_end() 

Here's a way, this will show the bar when you're aiming at a player and pressing the +use key.

P.S. Don't just copy and paste that into your plugin because it can be optimized.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-10-2016 , 14:56   Re: Reload bar (how to?)
Reply With Quote #8

You could get rid of PreThink, probably by using Ham_ObjectCaps.
__________________
HamletEagle is offline
newb1e
Junior Member
Join Date: Feb 2016
Old 02-10-2016 , 15:54   Re: Reload bar (how to?)
Reply With Quote #9

So if i press the button E when aiming a player for 3 seconds i will steal his money, but what if player starts moving? How to cancel the event?

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>

new g_iBarTime

public plugin_init( )
{   
    
register_forwardFM_PlayerPreThink"test" )
    
g_iBarTime get_user_msgid"BarTime" )


public 
testid )
{
    new 
newidbody
    get_user_aiming
idnewidbody )
    
    new 
zButton get_user_buttonid )
        new 
iKiller read_data(1)
        new 
iVictim read_data(2)
    
    if( 
is_user_connectednewid ) && ( zButton IN_USE )  )
    {
        
cs_set_user_money(iKillercs_get_user_money(iKiller) + cs_get_user_money(iVictim))
        
cs_set_user_money(iVictim0)
        
Make_BarTimeid )
    }
else
{
// ?
return PLUGIN_HANDLED
}
}

// this bar whil appear when  you press E aiming a player for 3 seconds
public Make_BarTimeid 

    
message_begin(MSG_ONE_UNRELIABLEg_iBarTime,_id 
    
write_short// This is the duration.
    
message_end() 


Last edited by newb1e; 02-10-2016 at 15:55.
newb1e is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-10-2016 , 20:58   Re: Reload bar (how to?)
Reply With Quote #10

Oww hell no... prethink? seriously?

Just hook the T button instead of E so you will not need cmd start or prethink
Then use get_user_aiming(id, Target, Body, Distance)
Create a bool to tell if the action is in progress, and if it is in progress and you press again T remove the task and the bar aka cancel the action
__________________

Last edited by Depresie; 02-10-2016 at 21:02.
Depresie 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 19:21.


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