AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Finding out how long button is pressed & + command (https://forums.alliedmods.net/showthread.php?t=13525)

LynX 05-19-2005 13:11

Finding out how long button is pressed & + command
 
1. How the heck I can see how long a button is pressed?
I need to get time how long button is pressed, anyone ? :stupid:
2. When I make + client command, so like this :
Code:
register_clcmd("+something","something") register_clcmd("-something","something_deactivate")

I want to do that every second I press, a task is performed. So every second task should be performed... How can I do taht thing?

Thnx :stupid:

xeroblood 05-19-2005 22:28

Try something like this, not sure exactly what you want tho..
Code:
#include <amxmodx> #define UNIQUE_TASK_ID 7656 public plugin_init() {     register_clcmd( "+command","PlusCommand" )     register_clcmd( "-command","MinusCommand" ) } public PlusCommand( id ) {     new args[2]     args[1] = id     set_task(1.0, "LoopFunction", UNIQUE_TASK_ID + id, args, 1, "b" );     return PLUGIN_HANDLED } public MinusCommand( id ) {     if( task_exists( UNIQUE_TASK_ID + id ) )         remove_task( UNIQUE_TASK_ID + id )     return PLUGIN_HANDLED } public LoopFunction( args[] ) {     new id = args[0];     // do stuff with player id here...     client_print( id, print_chat, "Test Message.." )     return PLUGIN_HANDLED }

LynX 05-20-2005 01:44

I just want that every second you got increasement in privateData ( offset ). So,
Code:
set_pdata_int(id, offset, currentvalue + value )

xeroblood 05-20-2005 10:55

Did you even try what I posted? Just pop your code in the comment spot..

LynX 05-20-2005 12:03

I tried... It works ^^
Now I need to know how to check how long button is pressed.

WaZZeR++ 05-21-2005 09:08

cant you make a holdtime[id]++ every loop in the loopfunction and count them later?

LynX 05-21-2005 09:22

Can you show a snippet ? :lol:

WaZZeR++ 05-21-2005 10:15

dont know if this will work, someone better have to take a look....

Code:
#include <amxmodx> #define UNIQUE_TASK_ID 7656 new g_holdtime[33] public plugin_init() {     register_clcmd( "+command","PlusCommand" )     register_clcmd( "-command","MinusCommand" ) } public PlusCommand( id ) {     new args[2]     args[1] = id     set_task(1.0, "LoopFunction", UNIQUE_TASK_ID + id, args, 1, "b" );     return PLUGIN_HANDLED } public MinusCommand( id ) {     if( task_exists( UNIQUE_TASK_ID + id ) )         remove_task( UNIQUE_TASK_ID + id )     client_print( id, print_chat, "You helt the button %s secunds",g_holdtime[id] )     g_holdtime[id] = 0 //reset the timer     return PLUGIN_HANDLED } public LoopFunction( args[] ) {     new id = args[0];     // do stuff with player id here...     client_print( id, print_chat, "Test Message.." )     g_holdtime[id]++     return PLUGIN_HANDLED }

v3x 05-21-2005 14:48

Try it.

LynX 05-21-2005 14:51

I'll try it in next few hours


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

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