Little Assistance on a "SprintBind" Detection System
#1

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.
Reply
#2

https://sampwiki.blast.hk/wiki/OnPlayerK..._holding_a_key

hope that helps
Reply
#3

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?
Reply
#4

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?
Reply
#5

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.
Reply
#6

ahhh i understand. i will look into it aswell
Reply
#7

Anybody else know how this would look?
Reply
#8

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)