All Projects → katursis → Pawn.CMD

katursis / Pawn.CMD

Licence: MIT License
🚀 Plugin-powered command processor for SA:MP server

Programming Languages

C++
36643 projects - #6 most used programming language
Pawn
127 projects
c
50402 projects - #5 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to Pawn.CMD

Pawn.Regex
🔎 Plugin that adds support for regular expressions in Pawn
Stars: ✭ 34 (-57.5%)
Mutual labels:  sa-mp, samp
code-parse.inc
Pre-processor macros for analysing PAWN functions.
Stars: ✭ 23 (-71.25%)
Mutual labels:  sa-mp, samp
GWRP-0.3
Игровой режим для San Andreas Multiplayer
Stars: ✭ 22 (-72.5%)
Mutual labels:  sa-mp, samp
gta-samp-mouse-only
Play GTA San Andreas Multiplayer with mouse only and no keyboard
Stars: ✭ 22 (-72.5%)
Mutual labels:  sa-mp, samp
samp-ptl
SA:MP Plugin Template Library (C++17)
Stars: ✭ 16 (-80%)
Mutual labels:  sa-mp, samp
eSelection
Dynamic model selection library for SA-MP servers
Stars: ✭ 28 (-65%)
Mutual labels:  sa-mp, samp
rustext
Fix Russian text plugin for SA-MP: GameText's, TextDraw's and Menu's
Stars: ✭ 15 (-81.25%)
Mutual labels:  sa-mp, samp
samp-foreach
foreach standalone include (non y_iterate version)
Stars: ✭ 20 (-75%)
Mutual labels:  sa-mp, samp
PacPaw
Pawn package manager for SA-MP
Stars: ✭ 14 (-82.5%)
Mutual labels:  sa-mp, samp
ssh-agent-cmd
Script for Windows Command Processor (cmd.exe) to run ssh-agent
Stars: ✭ 40 (-50%)
Mutual labels:  cmd, command-processor
samp-discord-plugin
SA:MP Discord Rich Presence plugin
Stars: ✭ 63 (-21.25%)
Mutual labels:  sa-mp, samp
protection
Flexible server protection system (development)
Stars: ✭ 23 (-71.25%)
Mutual labels:  sa-mp, samp
samp-node-lib
NodeJS library for Scripting San Andreas Multiplayer:SAMP depends on samp-node plugin
Stars: ✭ 23 (-71.25%)
Mutual labels:  sa-mp, samp
Open-GTO
RPG gamemode for SA-MP
Stars: ✭ 45 (-43.75%)
Mutual labels:  sa-mp, samp
SS-Gang-System-SQLITE
SS Gang System for SA-MP
Stars: ✭ 23 (-71.25%)
Mutual labels:  sa-mp, samp
linux-online-docs
linux-online-docs(鸟哥的Linux 私房菜) 🔥 🚀 🎉 🇨🇳
Stars: ✭ 30 (-62.5%)
Mutual labels:  cmd
Windows11-Optimization
Community repository, to improve security and performance of Windows 10 and windows 11 with tweaks, commands, scripts, registry keys, configuration, tutorials and more
Stars: ✭ 17 (-78.75%)
Mutual labels:  cmd
samp-plugin-crashdetect
Crash/error reporting plugin for SA-MP server
Stars: ✭ 93 (+16.25%)
Mutual labels:  sa-mp
Batch-File-examples
🐚 Various batch files (descriptions are in the read me file)
Stars: ✭ 37 (-53.75%)
Mutual labels:  cmd
EFT Flea Market Bot
Escape from Tarkov Flea Market bot, to generate a lot of in-game currency within shortest time, while not even having to actively play the game!
Stars: ✭ 22 (-72.5%)
Mutual labels:  cmd

Pawn.CMD

🚀 Plugin-powered command processor for SA:MP server

Natives

native PC_RegAlias(const cmd[], const alias[], ...);
native PC_SetFlags(const cmd[], flags);
native PC_GetFlags(const cmd[]);
native PC_RenameCommand(const cmd[], const newname[]);
native PC_CommandExists(const cmd[]);
native PC_DeleteCommand(const cmd[]);

native CmdArray:PC_GetCommandArray();
native CmdArray:PC_GetAliasArray(const cmd[]);
native PC_GetArraySize(CmdArray:arr);
native PC_GetCommandName(CmdArray:arr, index, dest[], size = sizeof dest);
native PC_FreeArray(&CmdArray:arr);

native PC_EmulateCommand(playerid, const cmdtext[]);

Callbacks

forward PC_OnInit();
forward OnPlayerCommandReceived(playerid, cmd[], params[], flags);
forward OnPlayerCommandPerformed(playerid, cmd[], params[], result, flags);

How to install

Extract archive in server folder. Update your server.cfg

  • Windows
plugins pawncmd.dll
  • Linux
plugins pawncmd.so

Configuration (pawncmd.cfg in plugins folder)

The values in parentheses are default values

  • CaseInsensitivity (true)
  • LegacyOpctSupport (true)
  • LocaleName ("C")
  • UseCaching (true)

Example command

#include <Pawn.CMD>

cmd:help(playerid, params[]) // you can also use 'CMD' or 'COMMAND' instead of 'cmd'
{
  // code here
  return 1;
}

Registering aliases

You can register aliases for a command

#include <Pawn.CMD>

cmd:help(playerid, params[])
{
  // code here
  return 1;
}
alias:help("commands", "cmds")

Using flags

You can set flags for a command

#include <Pawn.CMD>

enum (<<= 1)
{
  CMD_ADMIN = 1, // 0b00000000000000000000000000000001
  CMD_MODER,     // 0b00000000000000000000000000000010
  CMD_JR_MODER   // 0b00000000000000000000000000000100
};

new pPermissions[MAX_PLAYERS];

flags:ban(CMD_ADMIN)
cmd:ban(playerid, params[])
{
  // code here
  return 1;
}
alias:ban("block")

flags:kick(CMD_ADMIN | CMD_MODER)
cmd:kick(playerid, params[])
{
  // code here
  return 1;
}

flags:jail(CMD_ADMIN | CMD_MODER | CMD_JR_MODER)
cmd:jail(playerid, params[])
{
  // code here
  return 1;
}

public OnPlayerCommandReceived(playerid, cmd[], params[], flags)
{
  if (!(flags & pPermissions[playerid]))
  {
    printf("player %d doesn’t have access to command '%s'", playerid, cmd);

    return 0;
  }

  return 1;
}

public OnPlayerCommandPerformed(playerid, cmd[], params[], result, flags)
{
  if (result == -1)
  {
    SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: Unknown command.");

    return 0;
  }

  return 1;
}

public PC_OnInit()
{
  const testAdminPlayerId = 1, testModerPlayerId = 2, testJrModerPlayerId = 3, testSimplePlayerId = 4;

  pPermissions[testAdminPlayerId] = CMD_ADMIN | CMD_MODER | CMD_JR_MODER;
  pPermissions[testModerPlayerId] = CMD_MODER | CMD_JR_MODER;
  pPermissions[testJrModerPlayerId] = CMD_JR_MODER;
  pPermissions[testSimplePlayerId] = 0;

  PC_EmulateCommand(testAdminPlayerId, "/ban 4 some reason"); // ok
  PC_EmulateCommand(testModerPlayerId, "/ban 8 some reason"); // not ok, moder doesn’t have access to 'ban'
  PC_EmulateCommand(testModerPlayerId, "/kick 15 some reason"); // ok
  PC_EmulateCommand(testModerPlayerId, "/jail 16 some reason"); // ok, moder can use commands of junior moderator
  PC_EmulateCommand(testJrModerPlayerId, "/jail 23 some reason"); // ok
  PC_EmulateCommand(testSimplePlayerId, "/ban 42 some reason"); // not ok
}
If you want to use Pawn.CMD in a filterscript, put this define before including:
#define FILTERSCRIPT
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].