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

Can you detect mouse click time..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
swobj
Junior Member
Join Date: Jun 2004
Old 06-26-2006 , 01:45   Can you detect mouse click time..
Reply With Quote #1

Well the title probably sounds funny, but is there a way to detect how long you hold down your mouse click. For example if your mouse click is "+attack" and you hold it down, is there a way to detect how long you hold the mouse click before you release it and return the value? Thanks much for you help.
swobj is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 06-26-2006 , 02:25   Re: Can you detect mouse click time..
Reply With Quote #2

Moving this to Scripting Help from Support/Help.
__________________
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
Peli
Veteran Member
Join Date: Mar 2004
Location: San Diego, CA
Old 06-26-2006 , 02:41   Re: Can you detect mouse click time..
Reply With Quote #3

Maybe... if you started a countdown from the +attack action, but I don't know if there is any action that represents the mouse un-clicking... So I guess not...
Peli is offline
Send a message via MSN to Peli
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 06-26-2006 , 03:11   Re: Can you detect mouse click time..
Reply With Quote #4

-attack ;)
Lee is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 06-26-2006 , 03:21   Re: Can you detect mouse click time..
Reply With Quote #5

Well if you want to calculate it in seconds I would do something like this:
Code:
Code:
#include <amxmodx> #include <engine> new g_iSecs[33]; public client_putinserver(id) {     g_iSecs[id] = 0;     if(!task_exists(id))         set_task(1.0 , "count" , id , _ , _ , "b"); } public count(id) {     if(!is_user_alive(id))     {         g_iSecs[id] = 0;         return;     }     if(get_user_button(id) & IN_ATTACK)         g_iSecs[id]++;     else if(!(get_user_button(id) & IN_ATTACK) && g_iSecs[id])     {         client_print(id , print_chat , "* You held the attack button for %d second%s" , g_iSecs[id] , (g_iSecs[id] == 1) ? "" : "s");         g_iSecs[id] = 0;     } }

__________________
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.

Last edited by v3x; 06-26-2006 at 03:24.
v3x is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 06-26-2006 , 08:57   Re: Can you detect mouse click time..
Reply With Quote #6

Quote:
Originally Posted by v3x
Well if you want to calculate it in seconds I would do something like this:
Code:
Code:
#include <amxmodx> #include <engine> new g_iSecs[33];

public client_putinserver(id) { g_iSecs[id] = 0;

if(!task_exists(id)) set_task(1.0 , "count" , id , _ , _ , "b");
} public count(id) { if(!is_user_alive(id)) { g_iSecs[id] = 0;
return;
} if(get_user_button(id) & IN_ATTACK) g_iSecs[id]++;
else if(!(get_user_button(id) & IN_ATTACK) && g_iSecs[id]) { client_print(id , print_chat , "* You held the attack button for %d second%s" , g_iSecs[id] , (g_iSecs[id] == 1) ? "" : "s");
g_iSecs[id] = 0;
} }



It are being memory leakish, add client_disconnect and remove_task(id)
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
VEN
Veteran Member
Join Date: Jan 2005
Old 06-26-2006 , 14:37   Re: Can you detect mouse click time..
Reply With Quote #7

set_task(1.0, ... makes this method potentially not able to detect mouse clicks between "count" function calls.
VEN is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 06-27-2006 , 23:54   Re: Can you detect mouse click time..
Reply With Quote #8

What about looping at 0.1 second intervals then doing secs = time[id] * 10?
__________________
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
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 00:14.


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