Allo mes amis/hola me amigos/yo homeys!!
Yo! I want know how i can do this without losing my muind!!!!!!!!!!11!!
When my mouse is over a certain button aand is pressed down, i want to have a textbox show us all how long the mouse is over it and pressed down on that button with numbers going up and up and up, starting at ZERO. when the mouse is finally let go, woops!! the text is reset back tio nothing a.ka --> ZERO! tajht way when i reclick and hold down on that button, the counting starts all over again from ZERO.this will show us all how long a player holds down the mouse on that certain button! YESSSSSSSS
i tried and tried and cried and cried: me is super dumbo := :o
???
thats twhy ui come here to ask :)
Hey Joseph!
This is the first time I actually feel I can answer a question, unless someone has a better solution :P
int iLMclick; //put that at the top of your global script
//Put this in your rep_exec:
overGuiControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (mouse.IsButtonDown(eMouseLeft) && overGuiControl == yourButtonName)
{
while (mouse.IsButtonDown(eMouseLeft))
{
textboxName.Text = String.Format("%d", iLMclick);
Wait(1);
iLMclick = (iLMclick + 1);
}
lblHotspot.Text = "0";
iLMclick = 0;
}
I tested in my game and it works!
While general_knox method will work as expected, it can be problematic since it will prevent other stuff from happening while the mouse button is pressed (animations etc).
In order to solve that, we need to remove the "while" from the repeatedly_execute, so that only one check will run for each game loop.
Something like this (didn't test it, though):
int iLMclick; //put that at the top of your global script
//Put this in your rep_exec:
overGuiControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
if (mouse.IsButtonDown(eMouseLeft) && overGuiControl == yourButtonName)
{
iLMclick++;
}
else
{
iLMclick = 0;
}
textboxName.Text = String.Format("%d", iLMclick);
Kewl works := := :=