ScavengeSurvive/state-buffer
Captures a running buffer of player states for use in anti-cheat or statistical libraries.
This repository has no licence file. It is public to read, but that alone does not give permission to reuse it.
Install with sampctl
sampctl package install ScavengeSurvive/state-buffer
Run this in your project folder. sampctl downloads the package and what it depends on.
Adds its include files, with the libraries it depends on, to the Pawn compiler in your browser, ready to include in a script.
Depends on 2 packages
- sampctl/samp-stdlibnot in this directory
- pawn-lang/YSI-Includes★ 227
README.md
state-buffer
Captures a running buffer of player states for use in anti-cheat or statistical libraries.
No this is not an NPC-related library, it simply records a players actions into Pawn memory and provides an interface to access that data.
Installation
Simply install to your project:
sampctl package install Southclaws/state-buffer
Include in your code and begin using the library:
#include <state-buffer>
Usage
By including this library, OnScriptInit is hooked to start the frame capture
timer. This timer runs every STATE_BUFFER_GRANULARITY milliseconds with a
default value of 100. This means every 100ms, every connected player's state
(see the E_BUFFERED_STATE enumerator for what is stored in a frame) is stored.
The amount of history stored is controlled with MAX_STATE_BUFFER_SIZE with a
default value of 256. Meaning 256 * 100 / 1000 = 25.6 seconds of player state
history is stored with default settings.
You can use the function GetPlayerStateFrame to get the player's state from a
particular point in history, as long as it's within the buffer history.
This can be used to "re-play" a player's actions over the previous 25 seconds, very useful for administrative work.
Example - Positional Data
To get historical position data from a player:
new frames[MAX_STATE_BUFFER_SIZE][E_BUFFERED_STATE];
GetPlayerStateFrames(playerid, frames);
new next;
new Float:distance;
for(new i; i < MAX_STATE_BUFFER_SIZE - 1; ++i) {
next = i + 1; // the next frame
// add up distance of the past 25 seconds
distance += GetDistance3D(
frames[next][posPedX], frames[next][posPedY], frames[next][posPedZ],
frames[i][posPedX], frames[i][posPedY], frames[i][posPedZ]
);
}
printf("Over the last 25.6 seconds, player moved %fm", distance);
Development
The library is currently in an early stage and more states can be added easily to record a more accurate representation of a player's history. An administrative tool may also be released that's built on top of this library providing rewind/replay features for administrators to investigate potential rule breakers.
Testing
To test, simply run the package:
sampctl package run
And connect to localhost:7777 to see a demo.
This page is built from what GitHub publishes about the repository. samp.directory does not host the code. Report a problem with this listing