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

Se8870/samp-command-guess

SA-MP Command guesser to correct player mistakes when typing a command.

Библиотека★ 18обновлён февр. 2022 г.MITPawnsampctl
Открыть на GitHub

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

sampctl package install Se8870/samp-command-guess

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

Используется в 2 пакетах

README.md

SA:MP Command Guess

Just simple command guesser for SA-MP using Levenshtein Distance function.

Will working with most of command processor (including y_commands and also discord command)

Installation

Using sampctl

Simply install to your project:

sampctl package install Se8870/samp-command-guess

Include in your code and begin using the library:

#include <command-guess>

Manual installation

Simply download it from main repository, or go to release page.

Extract command.guess.inc inside the zip or tar.gz to your server directory (It should be inside pawno/includes)

Include in your code and begin using the library:

#include <command-guess>

Function Lists

Command_Guess(output[], const cmdtext[], len = sizeof dest);

Usage

With Y_CMD

#include <a_samp>
#include <YSI_Visual\y_commands>
#include <command-guess>

main() 
{
    print("Script loaded");
    
    Command_SetDeniedReturn(true);
}

public e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success) 
{
    if (success == COMMAND_UNDEFINED) 
    {
        new 
            guessCmd[32], 
            dist = Command_Guess(guessCmd, cmdtext);
  
        if (dist < 3)
        {
            SendClientMessageEx(playerid, -1, "{FF0000}ERROR:{FFFFFF} \"%s\" is not found, did you mean \"%s\"?", cmdtext, guessCmd);
        }
        else
        {
            SendClientMessageEx(playerid, -1, "{FF0000}ERROR:{FFFFFF} \"%s\" is not found", cmdtext);
        }
        return COMMAND_SILENT;
    }
    return COMMAND_OK;
}

With most command processor (I-ZCMD Example)

#include <a_samp>

#include <izcmd>
#include <command-guess>

main() 
{
    print("Script loaded");
}
public OnPlayerCommandPerformed(playerid, cmdtext[], success) 
{
    if (!success) 
    {
        new 
            guessCmd[32],
            dist = Command_Guess(guessCmd, cmdtext);

        if (dist < 3)
        {
            SendClientMessageEx(playerid, -1, "{FF0000}ERROR:{FFFFFF} \"%s\" is not found, did you mean \"%s\"?", cmdtext, guessCmd);
        }
        else
        {
            SendClientMessageEx(playerid, -1, "{FF0000}ERROR:{FFFFFF} \"%s\" is not found", cmdtext);
        }
        return 1;
    }
    return 1;
}

Testing

To test, simply run the following commands:

sampctl package run

pawnsampsamp-command-guess

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

Se8870/samp-command-guess: Библиотека для SA-MP | samp.directory