samp.directory
← Scripts e bibliotecas

Se8870/bind-system

Simple bind system with several types.

Biblioteca★ 1atualizado dez. de 2021MITPawnsampctl
Abrir no GitHub

Instalar com o sampctl

sampctl package install Se8870/bind-system

Execute na pasta do seu projeto. O sampctl baixa o pacote e as dependências dele.

Depende de 1 pacote

README.md

bind-system

Simple bind system with several types, making it more dynamic and easy to use.

Installation

Simply install to your project:

sampctl package install Se8870/bind-system

Include in your code and begin using the library:

#include <bind_system>

Function Lists

Callbacks:

// Called when you're using `BIND_TYPE_CUSTOM`
forward Bind_OnCustomExecuted(playerid, PlayerBind:slot, const string:action[]);

// Called when you set the key press
forward Bind_OnKeyPressed(playerid, PlayerBind:slot, const string:action[]);

Functions:

// Getting all slots and store it inside an array.
forward void:Bind_GetSlots(playerid, PlayerBind:output[MAX_BIND]);

// Get & Set
forward E_BIND_TYPE:Bind_GetType(playerid, PlayerBind:slot);
forward bool:Bind_SetType(playerid, PlaerBind:slot, E_BIND_TYPE:type);

forward Bind_GetKeys(playerid, PlayerBind:slot);
forward bool:Bind_SetKeys(playerid, PlayerBind:slot, keys);

forward bool:Bind_GetAction(playerid, PlayerBind:slot, string:output[], len = sizeof(output));
forward bool:Bind_SetAction(playerid, PlayerBind:slot, const string:action[]);

// Core function
forward PlayerBind:Bind_Create(playerid, E_BIND_TYPE:type, const string:action[]);
forward bool:Bind_Execute(playerid, PlayerBind:slot);
forward bool:Bind_Remove(playerid, PlayerBind:slot);

Usage

#include <a_samp>
#include <bind_system>

CMD:createbind(playerid, params[])
{
    new 
        E_BIND_TYPE:type, action[32];

    if (sscanf(params, "is[32]", _:type, params))
    {
        // Usage: /createbind [type] [action]
        // Type: 1 =  type command | 2 = type chat | 3 = (type custom, you decided)
        return 0;
    }

    if (type == BIND_TYPE_NONE || type > BIND_TYPE_CUSTOM)
    {
        // Error: invalid type.
        return 0;
    }

    Bind_Create(playerid, type, action);
    // Success creating bind (ID: 1)
    return 1;
}

CMD:executebind(playerid, params[])
{
    new PlayerBind:slot;

    if (sscanf(params, "i", _:slot))
    {
        // Usage: /executebind [slot]
        return 0;
    }

    Bind_Execute(playerid, slot);
    return 1;
}

CMD:removebind(playerid, params[])
{
    new PlayerBind:slot;

    if (sscanf(params, "i", _:slot))
    {
        // Usage: /removebind [slot]
        return 0;
    }

    Bind_Remove(playerid, slot);
    return 1;
}

Testing

To test, simply run the package:

sampctl package run

Esta página é montada com o que o GitHub publica sobre o repositório. O samp.directory não hospeda o código. Avisar de um problema com esta página