Raised This Month: $ Target: $400
 0% 

button pushing plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SSJ2GOKU
Senior Member
Join Date: Oct 2005
Location: Belgium
Old 05-30-2006 , 14:07   button pushing plugin
Reply With Quote #1

hello,

how do you make a plugin that has a LOAD time when you push a button

like you push the button K that is bound to "charge"
the longer you hold the button K, the stronger the effect

1 sec => 2 dmg
5 sec => 10 dmg
10 sec => 20 dmg
...

can anyone show me how to make such a plugin ?

greetz
ssj2goku
SSJ2GOKU is offline
Send a message via MSN to SSJ2GOKU
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 05-30-2006 , 14:53  
Reply With Quote #2

try this
Code:
#include <amxmodx> #include <fakemeta> #define DO_DAMAGE_AT_CHARGE_OFF public plugin_init() {     register_plugin( "ChargeDamage", "1.0", "core|Greenberet" );         register_clcmd( "+charge", "cmdChargeOn" );     register_clcmd( "-charge", "cmdChargeOff" );         register_forward( FM_PlayerPreThink, "PlayerPreThink" ); } enum charge_t {     chOn,     chPreFrame, #if defined DO_DAMAGE_AT_CHARGE_OFF     chDamage, #endif }; stock Charge[33][charge_t]; public cmdChargeOn( Client ) {     Charge[ Client ] [ chOn ] = 1;     Charge[ Client ] [ chPreFrame ] = _:get_gametime();     #if defined DO_DAMAGE_AT_CHARGE_OFF     Charge[ Client ] [ chDamage ] = 0; #endif } public cmdChargeOff( Client ) {     Charge[ Client ] [ chOn ] = 0;     #if defined DO_DAMAGE_AT_CHARGE_OFF       //Do damage here #endif } public PlayerPreThink( Client ) {     new Float:CurrentFrame = get_gametime( );     if ( Charge[ Client ] [ chOn ] && ( CurrentFrame - Float:Charge[ Client ] [ chPreFrame ] ) < ( 1.0 ) )         return 0;             Charge[ Client ] [ chPreFrame ] = _:CurrentFrame; #if defined DO_DAMAGE_AT_CHARGE_OFF         Charge[ Client ] [ chDamage ] += 2; #else     // Do damage here #endif     return 0; }


btw. you have to bind +charge and not charge.
there are better ways eg. register/unregister_forward in cmdChargeOn/cmdChargeOff so you don't have to check every PreThink if the client is charging or not.

undefine DO_DAMAGE_AT_CHARGE_OFF if you want to do the damage each second

BTW. i didn't test it, but it should work
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
SSJ2GOKU
Senior Member
Join Date: Oct 2005
Location: Belgium
Old 06-01-2006 , 06:56  
Reply With Quote #3


err


can u explain the code a bit i don't understand a word of it except the plugin_init

btw what must i modify to add other stuff then damage ?


btw THANKS for the fast reply
SSJ2GOKU is offline
Send a message via MSN to SSJ2GOKU
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 16:22.


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