samp.directory
← Скрипты и библиотеки

roseeast/qte

Customizable Quick Time Event (QTE) & moving-pointer Skill-Check library for open.mp & SA-MP.

Библиотека★ 1обновлён сент. 2026 г.MITPawnsampctl
Открыть на GitHub

Установка через sampctl

sampctl package install roseeast/qte

Выполните в папке проекта. sampctl скачает пакет и его зависимости.

Зависит от 1 пакета

README.md

qte

qte is a compact Quick Time Event and skill-check include for SA-MP 0.3.7 and open.mp. It creates a PlayerTextDraw timing bar, moves a pointer across the track, and reports success or failure through callbacks.

The include is designed for roleplay interactions such as lockpicking, fishing, repair jobs, crafting checks, medical actions, and other short timing-based tasks.

Preview

Features

FeatureDescription
Timing barDisplays a track, moving pointer, success zone, key prompt, and stage counter.
Multi-stage checksRequires one or more successful hits before the QTE completes.
PlayerTextDraw lifecycleCreates, updates, and destroys all QTE textdraws per player.
Framework compatibilitySupports SA-MP 0.3.7 and open.mp, including tagged KEY, textdraw font, and alignment arguments.
Callback integrationReports stage success, stage failure, cancellation, and final result through public callbacks.
Runtime state gettersExposes active stage, total stages, pointer position, and extra_id for surrounding systems.
Runtime stylingAllows each player or feature to set its own layout, colors, text, and sounds before starting a QTE.
Default macrosProvides compile-time defaults for servers that want one shared style.
Hook compatibilityUses y_hooks when present and falls back to ALS-style callback chaining otherwise.

Installation

StepAction
1Place qte.inc in your pawno/include directory.
2Include <open.mp> or <a_samp> before qte.
3Start a QTE with StartPlayerQTE and handle the result in callbacks.

sa-mp :

#include <a_samp>
#include <qte>

open.mp:

#include <open.mp>
#include <qte>

Quick Start

#include <open.mp>
#include <zcmd>
#include <qte>

#define QTE_LOCKPICK (101)

CMD:lockpick(playerid, params[])
{
    if(IsPlayerInQTE(playerid))
    {
        return SendClientMessage(playerid, 0xE74C3CFF, "You are already doing a skill check.");
    }

    QTE_ResetPlayerStyle(playerid);
    SetPlayerQTEColors(playerid, 0x111827FF, 0x38BDF8FF, 0xF97316FF, 0xFFFFFFFF, 0xE5E7EBFF);
    SetPlayerQTEText(playerid, "~w~LOCKPICK ~y~[%s] ~w~ON GREEN", "~y~PIN ~w~%d/%d");

    StartPlayerQTE(playerid, KEY_WALK, 3.0, 20.0, 3, QTE_LOCKPICK);
    SendClientMessage(playerid, 0xF1C40FFF, "Press ALT/WALK when the pointer enters the green zone.");
    return 1;
}

public OnPlayerQTEComplete(playerid, bool:success, stages_cleared, total_stages, extra_id)
{
    if(extra_id != QTE_LOCKPICK)
    {
        return 1;
    }

    if(success)
    {
        SendClientMessage(playerid, 0x2ECC71FF, "Lockpick completed.");
    }
    else
    {
        SendClientMessage(playerid, 0xE74C3CFF, "Lockpick failed.");
    }
    return 1;
}

public OnPlayerQTEResult(playerid, result, stages_cleared, total_stages, extra_id)
{
    if(extra_id == QTE_LOCKPICK && result == QTE_RESULT_CANCELLED)
    {
        SendClientMessage(playerid, 0xAAAAAAFF, "Lockpick cancelled.");
    }
    return 1;
}

API

Functions

FunctionReturnsDescription
StartPlayerQTE(playerid, KEY:key = KEY_SPRINT, Float:speed = 2.5, Float:zone_size = 20.0, stages = 1, extra_id = 0)1 on start, 0 for invalid playerStarts or replaces a player's active QTE.
StopPlayerQTE(playerid)1 when stopped, 0 when inactive or invalidCancels the active QTE, kills its timer, destroys its UI, and emits cancellation callbacks.
bool:IsPlayerInQTE(playerid)true or falseChecks whether the player currently has an active QTE.
GetPlayerQTEStage(playerid)intReturns the player's current stage, or 0 for invalid players.
GetPlayerQTETotalStages(playerid)intReturns the configured stage count, or 0 for invalid players.
GetPlayerQTEExtraID(playerid)intReturns the custom identifier passed to StartPlayerQTE.
KEY:GetPlayerQTEKey(playerid)KEY:Returns the key assigned to the active QTE.
Float:GetPlayerQTEZoneSize(playerid)Float:Returns the success zone width percentage.
Float:GetPlayerQTEPosition(playerid)Float:Returns the current pointer position from 0.0 to 100.0.
QTE_GetResultName(result, dest[], size = sizeof(dest))1Writes success, failed, cancelled, or unknown into dest.
QTE_ResetPlayerStyle(playerid)1 on successResets a player's style to the macro defaults.
SetPlayerQTELayout(playerid, orientation, Float:left, Float:top, Float:length, Float:thickness)1 on successSets horizontal or vertical layout for one player.
SetPlayerQTEColors(playerid, track_color, zone_color, pointer_color, prompt_color = -1, stage_color = -1)1 on successSets bar, zone, pointer, prompt, and stage colors for one player.
SetPlayerQTEText(playerid, const prompt_format[], const stage_format[])1 on successSets prompt and stage formats for one player.
SetPlayerQTETextDrawStyle(playerid, Float:prompt_offset_y, Float:stage_offset_y, Float:prompt_letter_x = QTE_PROMPT_LETTER_X, Float:prompt_letter_y = QTE_PROMPT_LETTER_Y, Float:stage_letter_x = QTE_STAGE_LETTER_X, Float:stage_letter_y = QTE_STAGE_LETTER_Y)1 on successSets text offsets and letter sizes for one player.
SetPlayerQTESounds(playerid, success_sound, fail_sound)1 on successSets success and failure sounds for one player.

StartPlayerQTE Parameters

ParameterTypeDefaultNotes
playeridintRequiredTarget player.
keyKEY:KEY_SPRINTKey that must be pressed to pass a stage. Prefer KEY_YES, KEY_NO, KEY_SPRINT, or KEY_ACTION for Android-friendly public features. Use KEY_WALK for ALT/WALK prompts on desktop clients.
speedFloat:2.5Pointer movement per tick. Higher values make the QTE harder.
zone_sizeFloat:20.0Success zone width as a percentage of the track. Clamped between QTE_ZONE_MIN_SIZE and QTE_ZONE_MAX_SIZE.
stagesint1Number of successful hits required. Values below 1 are clamped to 1.
extra_idint0Custom identifier passed back to callbacks. Useful when multiple systems use QTEs.

Callbacks

CallbackWhen It Runs
OnPlayerQTESuccessStage(playerid, current_stage, total_stages, extra_id)After a player hits the correct key inside the success zone.
OnPlayerQTEFailedStage(playerid, current_stage, total_stages, extra_id)After a player hits the correct key outside the success zone.
OnPlayerQTEComplete(playerid, bool:success, stages_cleared, total_stages, extra_id)After the QTE succeeds completely or fails.
OnPlayerQTECancel(playerid, stages_cleared, total_stages, extra_id)After StopPlayerQTE cancels an active QTE. Also runs when an active QTE is replaced or the player disconnects.
OnPlayerQTEResult(playerid, result, stages_cleared, total_stages, extra_id)After success, failure, or cancellation. Use this when one callback should handle every end state.

Example callback signatures:

forward OnPlayerQTEComplete(playerid, bool:success, stages_cleared, total_stages, extra_id);
forward OnPlayerQTESuccessStage(playerid, current_stage, total_stages, extra_id);
forward OnPlayerQTEFailedStage(playerid, current_stage, total_stages, extra_id);
forward OnPlayerQTECancel(playerid, stages_cleared, total_stages, extra_id);
forward OnPlayerQTEResult(playerid, result, stages_cleared, total_stages, extra_id);

Result Values

ConstantValueMeaning
QTE_RESULT_SUCCESS1All required stages were completed.
QTE_RESULT_FAILED2The player pressed the target key outside the success zone.
QTE_RESULT_CANCELLED3The QTE was stopped before success or failure.

Configuration

Use the runtime style functions when different systems need different QTE looks. This works well in gamemodes where lockpicking, fishing, repair jobs, and other features live in separate script modules.

Call QTE_ResetPlayerStyle(playerid) before applying a feature-specific style if you do not want the player to inherit the style from the previous QTE.

#define QTE_FISHING (201)

StartFishingQTE(playerid)
{
    QTE_ResetPlayerStyle(playerid);
    SetPlayerQTELayout(playerid, QTE_ORIENTATION_VERTICAL, 585.0, 170.0, 170.0, 12.0);
    SetPlayerQTEColors(playerid, 0x082F49FF, 0x22C55EFF, 0xF8FAFCFF, 0xFFFFFFFF, 0xE5E7EBFF);
    SetPlayerQTEText(playerid, "~w~FISHING ~y~[%s] ~w~ON GREEN", "~y~FISH ~w~%d/%d");
    SetPlayerQTETextDrawStyle(playerid, -22.0, 6.0);

    return StartPlayerQTE(playerid, KEY_SPRINT, 2.4, 24.0, 2, QTE_FISHING);
}

Runtime Style Reference

FunctionNotes
QTE_ResetPlayerStyleCopies the compile-time defaults into the player's runtime style.
SetPlayerQTELayoutUse QTE_ORIENTATION_HORIZONTAL or QTE_ORIENTATION_VERTICAL. length is width for horizontal bars and height for vertical bars.
SetPlayerQTEColorsAccepts Pawn RGBA colors such as 0x2ECC71FF.
SetPlayerQTETextPrompt format must contain one %s for the key name. Stage format receives current stage and total stages.
SetPlayerQTETextDrawStyleAdjusts prompt/stage vertical offsets and textdraw letter sizes.
SetPlayerQTESoundsSet either sound to 0 if your script wants silence.

Default Macros

Define these before including qte only when you want to change the default style for the whole script. Runtime setters can still override these defaults per player before StartPlayerQTE.

MacroDefaultDescription
QTE_ORIENTATIONQTE_ORIENTATION_HORIZONTALTrack direction. Use QTE_ORIENTATION_HORIZONTAL or QTE_ORIENTATION_VERTICAL.
QTE_TICK_RATE40Timer interval in milliseconds. Lower values make movement smoother and call the timer more often.
QTE_ZONE_MIN_SIZE5.0Minimum allowed success zone width.
QTE_ZONE_MAX_SIZE80.0Maximum allowed success zone width.
QTE_ZONE_START_MIN10.0Lowest random start position for the success zone.
QTE_ZONE_START_MAX90.0Upper bound used when rolling the success zone.
QTE_TRACK_LEFT220.0Left position of the QTE track on the 640x448 textdraw canvas.
QTE_TRACK_WIDTH200.0Width of the QTE track.
QTE_TRACK_TOP375.0Top position of the QTE track.
QTE_TRACK_HEIGHT14.0Height of the QTE track.
QTE_PROMPT_OFFSET_Y-20.0Vertical offset for the prompt relative to QTE_TRACK_TOP.
QTE_STAGE_OFFSET_Y4.0Vertical spacing below the track for the stage counter.
QTE_PROMPT_LETTER_X0.28Prompt text letter width.
QTE_PROMPT_LETTER_Y1.2Prompt text letter height.
QTE_STAGE_LETTER_X0.24Stage counter letter width.
QTE_STAGE_LETTER_Y1.1Stage counter letter height.
QTE_TRACK_COLOR0x1A1A1AFFBackground track color.
QTE_ZONE_COLOR0x2ECC71FFSuccess zone color.
QTE_POINTER_COLOR0xE74C3CFFMoving pointer color.
QTE_PROMPT_COLOR-1Prompt text color.
QTE_STAGE_COLOR-1Stage counter text color.
QTE_PROMPT_FORMAT"~w~PRESS ~y~[%s] ~w~IN THE GREEN ZONE!"Prompt format. Must contain one %s placeholder for the key name.
QTE_PROMPT_SIZE96Buffer size used for the formatted prompt. Increase this for longer translated prompts.
QTE_STAGE_FORMAT"~y~STAGE ~w~%d/%d"Stage counter format. Receives current stage and total stages.
QTE_STAGE_SIZE32Buffer size used for the formatted stage text.
QTE_SUCCESS_SOUND1083Sound played when a stage is hit correctly.
QTE_FAIL_SOUND1085Sound played when a stage is missed.

Global default example:

#define QTE_TICK_RATE 35
#define QTE_ZONE_MIN_SIZE 8.0
#define QTE_ZONE_MAX_SIZE 65.0
#define QTE_TRACK_TOP 360.0
#define QTE_TRACK_COLOR 0x111827FF
#define QTE_ZONE_COLOR 0x38BDF8FF
#define QTE_POINTER_COLOR 0xF97316FF
#define QTE_PROMPT_COLOR 0xFFFFFFFF
#define QTE_STAGE_COLOR 0xE5E7EBFF
#define QTE_PROMPT_FORMAT "~w~TEKAN ~y~[%s] ~w~SAAT MASUK AREA HIJAU"
#define QTE_PROMPT_SIZE 128
#define QTE_STAGE_FORMAT "~y~PIN ~w~%d/%d"
#define QTE_SUCCESS_SOUND 1057
#define QTE_FAIL_SOUND 1085

#include <open.mp>
#include <qte>

Global Vertical Default

This makes the default style vertical for the whole script. For per-feature vertical QTEs, prefer SetPlayerQTELayout.

#define QTE_ORIENTATION QTE_ORIENTATION_VERTICAL
#define QTE_TRACK_LEFT 585.0
#define QTE_TRACK_TOP 170.0
#define QTE_TRACK_WIDTH 170.0
#define QTE_TRACK_HEIGHT 12.0

#define QTE_PROMPT_OFFSET_Y -22.0
#define QTE_STAGE_OFFSET_Y 6.0

#include <open.mp>
#include <qte>

Compatibility Notes

AreaDetails
TextDraw tagsThe include uses tagged alignment and font values to avoid open.mp tag mismatch warnings.
Key tagsStartPlayerQTE accepts KEY: values, matching open.mp's callback prototype.
TextDraw colour spellingopen.mp uses PlayerTextDrawColour; SA-MP uses PlayerTextDrawColor. The include selects the available spelling internally.
Callback chainingIf y_hooks is loaded, hooks are used. Otherwise, ALS-style chaining is used for OnPlayerKeyStateChange and OnPlayerDisconnect.

Android Clients

Android clients can map some controls differently from desktop clients. For public features, prefer simple keys such as KEY_YES, KEY_NO, KEY_SPRINT, and KEY_ACTION. For desktop ALT/WALK prompts, use KEY_WALK.

Recommended keyTypical prompt
KEY_YESY
KEY_NON
KEY_SPRINTSPACE / SPRINT
KEY_ACTIONACTION
KEY_WALKALT / WALK

License

Released under the MIT License. See LICENSE.

mini-gameopenmppawnsa-mpsa-mp-developmentsa-mp-library

Страница собрана из того, что GitHub публикует о репозитории. samp.directory не хранит этот код. Сообщить о проблеме с этой записью