AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   button pushing plugin (https://forums.alliedmods.net/showthread.php?t=29139)

SSJ2GOKU 05-30-2006 14:07

button pushing plugin
 
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

Greenberet 05-30-2006 14:53

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

SSJ2GOKU 06-01-2006 06:56

:shock:
err
:shock:

can u explain the code a bit :D 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 :D


All times are GMT -4. The time now is 16:22.

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