Little Assistance on a "SprintBind" Detection System -
Th3b3ast5 - 22.07.2013
So I've been wondering, how would this system work? What I've come to a conclusion with is that if the player presses a given Key more than a given amount of times per second, that this would send a message saying that they may be using a sprintbind, if this is the right direction of this system, let me know by posting down there.. I may have more inquiries.. Thanks if you respond and let me know.
Edit: If you can, give me a format of how this would be scripted, if a player clicks a key a certain amount of times in a second that it would send a message, not an advanced scripter. Thanks in advance.
Re: Little Assistance on a "SprintBind" Detection System -
Donvalley - 22.07.2013
https://sampwiki.blast.hk/wiki/OnPlayerK..._holding_a_key
hope that helps
Re: Little Assistance on a "SprintBind" Detection System -
Th3b3ast5 - 22.07.2013
I understand the whole "OnPlayerKeyStateChange" consept, but how would you make it check for How many times a given key in pressed in a given time period?
Re: Little Assistance on a "SprintBind" Detection System -
Donvalley - 22.07.2013
pawn Код:
// HOLDING(keys)
#define HOLDING(%0) \
((newkeys & (%0)) == (%0))
pawn Код:
if (HOLDING( KEY_SPRINT ))
{
SendClientMessageToAll(COLOR_YELLOW, "Someone is holding the sprint key");
return 1;
}
example.... is that what your after?
Re: Little Assistance on a "SprintBind" Detection System -
Th3b3ast5 - 22.07.2013
Not exactly.. I'm after if a player presses the Sprint Key 13+ times within a second, it would send a message to the Moderators/Admins that the player is using a bind.
Re: Little Assistance on a "SprintBind" Detection System -
Donvalley - 22.07.2013
ahhh i understand. i will look into it aswell
Re: Little Assistance on a "SprintBind" Detection System -
Th3b3ast5 - 22.07.2013
Anybody else know how this would look?
Re: Little Assistance on a "SprintBind" Detection System -
Pottus - 22.07.2013
Sure this is pretty easy.
pawn Код:
// PRESSED(keys)
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
// Amount of time between press
#define MINIMUM_PRESS_TIME 20
// Amount of times in a row to be considered sprint macro
#define EXCESSIVE_PRESS_COUNT 5
// Last time a player pressed sprint
new LastPressTime[MAX_PLAYERS];
// Amount of times in a row exccessively fast sprinting has been detected
new SprintPressCounter[MAX_PLAYERS];
//Pressed a key
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
// Sprint was pressed
if(PRESSED(KEY_SPRINT))
{
// Did the player press sprint too quickly ?
if(GetTickCount() - LastPressTime[playerid] < MINIMUM_PRESS_TIME)
{
// Increment press counter
SprintPressCounter[playerid]++;
// Happened too many times
if(SprintPressCounter[playerid] == EXCESSIVE_PRESS_COUNT)
{
// Write whatever you want the script to do here
}
}
// Make sure we keep the counter reset
else SprintPressCounter[playerid] = 0;
// Keep track of the last time sprint was pressed
LastPressTime[playerid] = GetTickCount();
}
return 1;
}