Raised This Month: $ Target: $400
 0% 

Finding out how long button is pressed & + command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LynX
Veteran Member
Join Date: Oct 2004
Old 05-19-2005 , 13:11   Finding out how long button is pressed & + command
Reply With Quote #1

1. How the heck I can see how long a button is pressed?
I need to get time how long button is pressed, anyone ?
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
__________________
Current plugin : SoulPunisher anti-cheat
Percentage done : {||--------} 20%

If you think v3x is a PIMP, paste this into your sig!

If you think Bailopan is DA BOMB, paste this into your sig
LynX is offline
Send a message via ICQ to LynX
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 05-19-2005 , 22:28  
Reply With Quote #2

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 }
xeroblood is offline
Send a message via MSN to xeroblood
LynX
Veteran Member
Join Date: Oct 2004
Old 05-20-2005 , 01:44  
Reply With Quote #3

I just want that every second you got increasement in privateData ( offset ). So,
Code:
set_pdata_int(id, offset, currentvalue + value )
__________________
Current plugin : SoulPunisher anti-cheat
Percentage done : {||--------} 20%

If you think v3x is a PIMP, paste this into your sig!

If you think Bailopan is DA BOMB, paste this into your sig
LynX is offline
Send a message via ICQ to LynX
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 05-20-2005 , 10:55  
Reply With Quote #4

Did you even try what I posted? Just pop your code in the comment spot..
xeroblood is offline
Send a message via MSN to xeroblood
LynX
Veteran Member
Join Date: Oct 2004
Old 05-20-2005 , 12:03  
Reply With Quote #5

I tried... It works ^^
Now I need to know how to check how long button is pressed.
__________________
Current plugin : SoulPunisher anti-cheat
Percentage done : {||--------} 20%

If you think v3x is a PIMP, paste this into your sig!

If you think Bailopan is DA BOMB, paste this into your sig
LynX is offline
Send a message via ICQ to LynX
WaZZeR++
Veteran Member
Join Date: Mar 2005
Location: Sweden
Old 05-21-2005 , 09:08  
Reply With Quote #6

cant you make a holdtime[id]++ every loop in the loopfunction and count them later?
WaZZeR++ is offline
Send a message via MSN to WaZZeR++
LynX
Veteran Member
Join Date: Oct 2004
Old 05-21-2005 , 09:22  
Reply With Quote #7

Can you show a snippet ?
__________________
Current plugin : SoulPunisher anti-cheat
Percentage done : {||--------} 20%

If you think v3x is a PIMP, paste this into your sig!

If you think Bailopan is DA BOMB, paste this into your sig
LynX is offline
Send a message via ICQ to LynX
WaZZeR++
Veteran Member
Join Date: Mar 2005
Location: Sweden
Old 05-21-2005 , 10:15  
Reply With Quote #8

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 }
WaZZeR++ is offline
Send a message via MSN to WaZZeR++
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-21-2005 , 14:48  
Reply With Quote #9

Try it.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
LynX
Veteran Member
Join Date: Oct 2004
Old 05-21-2005 , 14:51  
Reply With Quote #10

I'll try it in next few hours
__________________
Current plugin : SoulPunisher anti-cheat
Percentage done : {||--------} 20%

If you think v3x is a PIMP, paste this into your sig!

If you think Bailopan is DA BOMB, paste this into your sig
LynX is offline
Send a message via ICQ to LynX
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 09:26.


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