Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
I always wanted to find out how do you know to make your bot know it someone double pressed an arrow key.
I tried doing like the basics and do something simple like this.
The point of this code is double press right arrow key and a block will appear right next to them
switch (e.KeyCode)
{
if case e.DoublePress.Right;
{
con.Send(bldatam, 0, 1-x, y, 12);
}
}
break;
It did not work at all!
I don't know if this code is simply or anything, can you help?
Offline
Are you pressing the keys in the application or in the world?
Either way you're going to need timestamps - so you can chose the variation of how quickly a double press is.
Thank you eleizibeth ^
I stack my signatures rather than delete them so I don't lose them
Offline
As said, you need to know the time between 2 times the same key have been consecutively pressed, check if that time is rather short and you know if it's a double tap.
Offline
Offline
# m - UserID is moving around
[0] <Integer> UserID
[1] <Double> PlayerPosX
[2] <Double> PlayerPosY
[3] <Double> SpeedX
[4] <Double> SpeedY
[5] <Integer> ModifierX
[6] <Integer> ModifierY
[7] <Integer> Horizontal
[8] <Integer> Vertical
[9] <Boolean> SpaceDown
[10] <Boolean> SpaceJustDown
If m[7] == 1, the right key is pressed, and if it is -1, the left key is pressed.
You essentially need to receive 4 messages with certain amounts of time between each, to detect a double-tap: player presses a key, lets go, presses it again, and lets go. The messages would look like:
m[7] == 1 --> Player presses right
- Short amount of time passes (e.g. < 1 sec)
m[7] == 0 --> Player lets go of right key
- Short amount of time
m[7] == 1 --> Player presses right again
- Short amount of time
m[7] == 0 --> Player lets go of right
After that, you would do whatever action is triggered by that key combo. To check the amount of time between key presses, you would check the amount of time that passes between received "m" packets, using a Stopwatch object - see http://www.dotnetperls.com/stopwatch.
However, I think you'd find that players would trigger that combo quite often without meaning to, while just bouncing around. It would be better to have a more obscure combo, like Up + Left + Up, that normal movement would be less likely to trigger. To detect an Up key press, you would need m[8] -> m[8] == 1 if player presses Down, and -1 if player presses Up.
^^ Up, Up, Down, Down, Left, Right, A, B, A, B, Start.
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
# m - UserID is moving around
[0] <Integer> UserID
[1] <Double> PlayerPosX
[2] <Double> PlayerPosY
[3] <Double> SpeedX
[4] <Double> SpeedY
[5] <Integer> ModifierX
[6] <Integer> ModifierY
[7] <Integer> Horizontal
[8] <Integer> Vertical
[9] <Boolean> SpaceDown
[10] <Boolean> SpaceJustDownIf m[7] == 1, the right key is pressed, and if it is -1, the left key is pressed.
You essentially need to receive 4 messages with certain amounts of time between each, to detect a double-tap: player presses a key, lets go, presses it again, and lets go. The messages would look like:
m[7] == 1 --> Player presses right
- Short amount of time passes (e.g. < 1 sec)
m[7] == 0 --> Player lets go of right key
- Short amount of time
m[7] == 1 --> Player presses right again
- Short amount of time
m[7] == 0 --> Player lets go of rightAfter that, you would do whatever action is triggered by that key combo. To check the amount of time between key presses, you would check the amount of time that passes between received "m" packets, using a Stopwatch object - see http://www.dotnetperls.com/stopwatch.
However, I think you'd find that players would trigger that combo quite often without meaning to, while just bouncing around. It would be better to have a more obscure combo, like Up + Left + Up, that normal movement would be less likely to trigger. To detect an Up key press, you would need m[8] -> m[8] == 1 if player presses Down, and -1 if player presses Up.
^^ Up, Up, Down, Down, Left, Right, A, B, A, B, Start.
Add a timestamp to the player class so you don't end up with a new thread every time someone moves.
Thank you eleizibeth ^
I stack my signatures rather than delete them so I don't lose them
Offline
After that, you would do whatever action is triggered by that key combo. To check the amount of time between key presses, you would check the amount of time that passes between received "m" packets, using a Stopwatch object - see http://www.dotnetperls.com/stopwatch.
I would highly recommend not using a Stopwatch for non-diagnostic purposes. Stopwatches are great and accurate for seeing how long a code segment takes to execute, but not so efficient to use in finished programs.
I would recommend using a TimeSpan or a Timer to check the time between presses.
Good luck!
Offline
Tomahawk wrote:After that, you would do whatever action is triggered by that key combo. To check the amount of time between key presses, you would check the amount of time that passes between received "m" packets, using a Stopwatch object - see http://www.dotnetperls.com/stopwatch.
I would highly recommend not using a Stopwatch for non-diagnostic purposes. Stopwatches are great and accurate for seeing how long a code segment takes to execute, but not so efficient to use in finished programs.
I would recommend using a TimeSpan or a Timer to check the time between presses.
Good luck!
cite ur src plz
Offline
switch (e.KeyCode) { if case e.DoublePress.Right; { con.Send(bldatam, 0, 1-x, y, 12); } } break;
I just realised what you wrote, switch statements are for a list of answers not a list of if statements, you don't say `if case` - you say `case var:` inside `switch`
switch(VAR) {
case var1:
//Do something
break;
case var2:
case var3:
//Do something if var2 or var3 match VAR
break;
default:
//If the result doesn't match anything else
case;
}
Thank you eleizibeth ^
I stack my signatures rather than delete them so I don't lose them
Offline
[ Started around 1732428575.7837 - Generated in 0.065 seconds, 10 queries executed - Memory usage: 1.53 MiB (Peak: 1.69 MiB) ]