Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
ArKaNeMaN committed Dec 9, 2024
0 parents commit 666e587
Show file tree
Hide file tree
Showing 25 changed files with 1,679 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .build-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PACKAGE_NAME=CustomWeaponsAPI
PACKAGE_README_USE=1

PACKAGE_COMPILED_PLUGINS_USE=1
PACKAGE_COMPILED_PLUGINS_SAVE=0

PACKAGE_PLUINGS_LIST_USE=0
PACKAGE_ASSETS_USE=0
158 changes: 158 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
name: CI

on:
push:
branches: [master]
paths-ignore:
- "**.md"

pull_request:
types: [opened, reopened, synchronize]
release:
types: [published]

env:
PACKAGE_NAME: CustomWeaponsAPI
STORE_READMY: 1
PARAMS_CONRTOLLER_TAG: 1.0.0-b4

jobs:
build:
name: "Build"
runs-on: ubuntu-latest
outputs:
COMMIT_SHA: ${{ steps.declare_sha.outputs.COMMIT_SHA }}
SEMVER: ${{ steps.declare_sha.outputs.SEMVER }}
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Parse SemVer string (release)
id: semver_parser
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
uses: booxmedialtd/[email protected]
with:
input_string: ${{ github.ref }}
version_extractor_regex: 'refs\/tags\/(.*)$'

- name: Declare SHA & package name
id: declare_sha
shell: bash
run: |
SHA=$(git rev-parse --short HEAD)
echo "COMMIT_SHA=$SHA" >> $GITHUB_OUTPUT
echo "SEMVER=${{ steps.semver_parser.outputs.fullversion }}" >> $GITHUB_OUTPUT
- name: Setup latest ReAPI includes
env:
REPO: "rehlds/reapi"
run: |
mkdir -p dep/reapi
cd dep/reapi
curl \
--silent \
https://api.github.com/repos/$REPO/releases/latest | \
jq .assets[0].browser_download_url -r | \
xargs wget
7z x *.zip
echo "REAPI_INCLUDE_PATH=$(pwd)/addons/amxmodx/scripting/include" >> $GITHUB_ENV
- name: Setup ParamsController includes
env:
REPO: AmxxModularEcosystem/ParamsController
TAG: ${{ env.PARAMS_CONRTOLLER_TAG }}
OUTPUT_VAR_NAME: PARAMS_CONRTOLLER_INCLUDE_PATH
run: |
mkdir -p dep/${REPO}
cd dep/${REPO}
if [ -z "${TAG}" ]; then
TAG=`curl --silent https://api.github.com/repos/${REPO}/releases/latest | jq .tag_name -r`
fi
wget https://github.com/${REPO}/archive/refs/tags/${TAG}.zip
7z x ${TAG}.zip
REPO_NAME=`echo "${REPO}" | grep -Po '(?<=\/)\w+'`
echo "${OUTPUT_VAR_NAME}=$(pwd)/${REPO_NAME}-${TAG}/${INCLUDE_PATH:-amxmodx/scripting/include}" >> $GITHUB_ENV
- name: Setup AMXXPawn Compiler
uses: wopox1337/[email protected]
with:
version: "1.10.5428"

- name: Compile plugins
working-directory: amxmodx/scripting/
env:
REAPI_INCLUDE: ${{ env.REAPI_INCLUDE_PATH }}
PARAMS_CONRTOLLER_INCLUDE: ${{ env.PARAMS_CONRTOLLER_INCLUDE_PATH }}
run: |
compile() {
sourcefile=$1
amxxfile="$(echo $sourcefile | sed -e 's/\.sma$/.amxx/')"
output_path="../plugins/$amxxfile"
mkdir -p $(dirname $output_path)
echo -n "Compiling $sourcefile ... "
amxxpc $sourcefile -o"$output_path" \
-i"include" \
-i"$REAPI_INCLUDE" \
-i"$PARAMS_CONRTOLLER_INCLUDE"
}
export -f compile
find . -type f -name "*.sma" -exec bash -c 'compile "$0"' {} \;
- name: Move files
env:
STORE_READMY: ${{ env.STORE_READMY }}
run: |
mkdir -p publish/${{ env.PACKAGE_NAME }}/addons
mv amxmodx/ publish/${{ env.PACKAGE_NAME }}/addons
if [ ! -z "${STORE_READMY}" ]; then
mv README.md publish/
fi
- name: Deploy artifact
uses: actions/[email protected]
with:
name: ${{ env.PACKAGE_NAME }}-${{ steps.declare_sha.outputs.COMMIT_SHA }}-dev
path: publish/*

publish:
name: "Publish release"
runs-on: ubuntu-latest
needs: [build]
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
steps:
- name: Download artifact
uses: actions/[email protected]
with:
name: ${{ env.PACKAGE_NAME }}-${{ needs.build.outputs.COMMIT_SHA }}-dev

- name: Packaging binaries
id: packaging
run: 7z a -mm=Deflate -mfb=258 -mpass=15 -r ${{ env.PACKAGE_NAME }}-${{ needs.build.outputs.SEMVER }}.zip

- name: Publish artifacts
uses: softprops/[email protected]
id: publish-job
if: |
startsWith(github.ref, 'refs/tags/') &&
steps.packaging.outcome == 'success'
with:
files: |
*.zip
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.amxx
*.zip
.build
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Extended Menu System
21 changes: 21 additions & 0 deletions amxmodx/configs/plugins/ExtendedMenuSystem/Menus/MenuExample1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"Command": "example_menu_1",
"ChatCommands": [
"say /menu1"
],
"Title": [
"Заголовок",
" Подзаголовок 1",
" Подзаголовок 2"
],
"Items": [
{
"Title": "Пункт 1",
"Command": "say Я нажал на пункт 1"
},
{
"Title": "Пункт 2",
"Command": "say Я нажал на пункт 2"
}
]
}
17 changes: 17 additions & 0 deletions amxmodx/configs/plugins/ExtendedMenuSystem/Menus/MenuExample2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"Command": "example_menu_2",
"ChatCommands": [
"say /menu2"
],
"Title": "Кого вызвать на дуэль?",
"Controller": {
"Controller": "Players",

"ExcludeSelf": true,
"ExcludeDead": true,
"ExcludeTeammates": true,

"Title": "{i:playerName} \\d#{i:playerIndex}",
"Command": "tipa_vyzov_na_duel {i:playerIndex}; say {i:playerName}, вызываю тебя на дуэль!"
}
}
18 changes: 18 additions & 0 deletions amxmodx/configs/plugins/ExtendedMenuSystem/Menus/MenuExample3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Command": "example_menu_3",
"ChatCommands": [
"say /menu3"
],
"Title": "Привет, {m:playerName}!",
"Extensions": [
"PlayerPlaceholders"
],
"Items": [
{
"Title": "Твой SteamId: {m:playerSteamId}"
},
{
"Title": "Твой индекс: {m:playerIndex}"
}
]
}
32 changes: 32 additions & 0 deletions amxmodx/scripting/EMS/API/MenuController.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <amxmodx>
#include <ems>
#include <ParamsController>
#include "EMS/Objects/MenuController"

API_MenuController_Init() {
register_native("MenuController_Register", "@_MenuController_Register");
register_native("MenuController_AddParams", "@_MenuController_AddParams");
}

T_MenuController:@_MenuController_Register(const pluginIndex) {
enum {Arg_Key = 1, Arg_Callback};

new controllerKey[EMS_CONTROLLER_KEY_MAX_LEN];
new controllerCallback[EMS_EVENT_HANDLER_MAX_LEN];

get_string(Arg_Key, controllerKey, charsmax(controllerKey));
get_string(Arg_Callback, controllerCallback, charsmax(controllerCallback));

return MenuController_Register(controllerKey, MenuController_MakeCallback(pluginIndex, controllerCallback));
}

@_MenuController_AddParams(const pluginIndex, const paramsCount) {
enum {Arg_Controller = 1, Arg_Params};

new T_MenuController:controller = get_param(Arg_Controller);
new Array:newParams = ParamsController_Param_ListFromNativeParams(Arg_Params, paramsCount);

MenuController_AddParams(controller, newParams);

ArrayDestroy(newParams);
}
Empty file.
Loading

0 comments on commit 666e587

Please sign in to comment.