From 3ab6b1badf24f50dc0d34996c7478906f9cb66e5 Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Wed, 18 Apr 2018 10:09:48 -0400 Subject: [PATCH] Create dockerized version Create dockerized version which will automatically build this. --- .gitignore | 1 + Dockerfile | 27 ++++ Makefile | 34 ++++ README.markdown | 17 +- files/amxmodx.sha | 1 + ENSL.sma => src/ENSL.sma | 0 src/compile.sh | 4 + src/include/nsteam.inc | 341 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 421 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 files/amxmodx.sha rename ENSL.sma => src/ENSL.sma (100%) create mode 100755 src/compile.sh create mode 100644 src/include/nsteam.inc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a007fea --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cf7518f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM ubuntu + +# Need to install GCC-MULTILIB to be able to run amxxpc +RUN apt-get update && apt-get upgrade -y +RUN apt-get install -y wget git vim curl ca-certificates gcc-multilib hashalot + +RUN useradd -m amxx && mkdir -p /var/build && chown -R amxx:amxx /var/build + +USER amxx +WORKDIR /home/amxx +RUN wget -q -O amxx.tgz "https://www.amxmodx.org/release/amxmodx-1.8.2-base-linux.tar.gz" && \ + wget -q -O amxx_ns.tgz "https://www.amxmodx.org/release/amxmodx-1.8.2-ns-linux.tar.gz" + +COPY files/amxmodx.sha /home/amxx +RUN sha256sum -c amxmodx.sha + +RUN tar -zxf amxx.tgz && tar -zxf amxx_ns.tgz + +WORKDIR /home/amxx/addons/amxmodx/scripting + +COPY src/*.* /home/amxx/addons/amxmodx/scripting/ +COPY src/include/* /home/amxx/addons/amxmodx/scripting/include + +# RUN ./amxxpc ENSL.sma && cp ENSL.sma /var/build + +USER root +ENTRYPOINT ["/home/amxx/addons/amxmodx/scripting/compile.sh", "ENSL.sma"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..77a9be5 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +REGISTRY ?= ensl +PROJECT ?= ensl-plugin +TAG ?= latest + +ifdef REGISTRY + IMAGE=$(REGISTRY)/$(PROJECT):$(TAG) +else + IMAGE=$(PROJECT):$(TAG) +endif + +all: + @echo "Available targets:" + @echo " * build - build a Docker image for $(IMAGE)" + @echo " * pull - pull $(IMAGE)" + @echo " * push - push $(IMAGE)" + @echo " * test - build and test $(IMAGE)" + +build: Dockerfile + docker build -t $(IMAGE) . + +run: build + docker run -v $(shell pwd)/build/:/var/build -ti $(IMAGE) + +pull: + docker pull $(IMAGE) || true + +push: + docker push $(IMAGE) + +clean: + rm -f $(shell pwd)/build/* + +test: build + @echo "TODO" diff --git a/README.markdown b/README.markdown index 428e3c6..fe3a32b 100644 --- a/README.markdown +++ b/README.markdown @@ -1,17 +1,26 @@ ENSL Plugin =========== -This is the source code of ENSL Plugin. It was used on [European NS League](http://www.ensl.org) for many years. +This is the source code of ENSL Plugin. It was used on European NS League for many years. -Originally based on CAL Plugin, but later completely remade by Ari "jiriki" Timonen. Rest of the credits below: +## How to compile + +Use the provided Dockerfile to install libs, amxmodx and compile it. + +1. Run `make build` to build docker image +1. Run `make run` to compile and find it in **build** directory. + +## Credits + +Originally based on CAL Plugin, but later completely remade by jiriki. Rest of the credits below: + DarkSnow's socket example + CAL Features by CAL-ns|Austin (xHomicide) and Jim "JazzX" Olson - + Asmodee for waypoint fixes & weaponfix & other fixes + + Asmodee for waypoint fixes, weaponfix and other fixes + Multivac's Jetpack fix + sawce's icons plugin + www.nsmod.org + www.amxmodx.org Right now only legacy code is the unstuck function from CAL Plugin. Full description of all the features is here: -http://www.ensl.org/articles/426 \ No newline at end of file +http://www.ensl.org/articles/426 diff --git a/files/amxmodx.sha b/files/amxmodx.sha new file mode 100644 index 0000000..92733df --- /dev/null +++ b/files/amxmodx.sha @@ -0,0 +1 @@ +43d9e13a462609626bbf6ef68f568973fd43fb8e0789ba4261c9b44f0ff380fc amxx.tgz diff --git a/ENSL.sma b/src/ENSL.sma similarity index 100% rename from ENSL.sma rename to src/ENSL.sma diff --git a/src/compile.sh b/src/compile.sh new file mode 100755 index 0000000..1712317 --- /dev/null +++ b/src/compile.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +./amxxpc $1 +cp $1 /var/build diff --git a/src/include/nsteam.inc b/src/include/nsteam.inc new file mode 100644 index 0000000..a619daa --- /dev/null +++ b/src/include/nsteam.inc @@ -0,0 +1,341 @@ +/* +* AMX mod X team functions for "Natural-Selection 3.2" +* by Mev-Rael (Tyrael@inbox.lv ; Tyrael_Greefien @ skype; Mevrael @ steam) +* +* 28.04.2010 +* +* http://ns.boxg.lv - Baltic Natural-Selection Community +* +* Those functions provides a simple manipulation with NS (MvA) teams: +* 1) Check if player is in team +* 2) Change player team +* 3) Count players in team +* 4) Get players ID and count in team +*/ + +#if !defined NS_INC + #include +#endif + +/* +* Check if player is in team +* return true or false +*/ + +// Check if player is in readyroom +stock nst_is_readyroom(id) +{ + new team[4] + ns_get_user_team(id, team, 3) + + if (equal(team, "und") && is_user_connected(id)) + { + return true + } + return false +} + +// Check if player is in spectatorteam +stock nst_is_spectate(id) +{ + new team[2] + ns_get_user_team(id, team, 1) + + if (team[0] == 's') + { + return true + } + return false +} + +// Check if player is in marine team +stock nst_is_marine(id) +{ + new team[2] + ns_get_user_team(id, team, 1) + + if (team[0] == 'm') + { + return true + } + return false +} + +// Check if player is in alien team +stock nst_is_alien(id) +{ + new team[2] + ns_get_user_team(id, team, 1) + + if (team[0] == 'a')) + { + return true + } + return false +} + + +/* +* Change player team +*/ + +// Send a player to readyroom +stock nst_readyroom(id) +{ + new team[4] + ns_get_user_team(id, team, 3) + + if (!equal(team, "und") && is_user_connected(id)) + { + client_cmd(id, "readyroom; readyroom") + } +} + +// Readyroom all +stock nst_readyroomall() +{ + new players[32], num, i + get_players(players, num) + for (i=0; i