Skip to content

Commit

Permalink
Merge pull request #253 from MrDave1999/dev
Browse files Browse the repository at this point in the history
9.1.3 Release
This PR migrates to open.mp and leaves aside the old SA-MP server.
  • Loading branch information
MrDave1999 authored Dec 14, 2024
2 parents 4a3ddee + 4293fd5 commit 226202c
Show file tree
Hide file tree
Showing 89 changed files with 177 additions and 100 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ logs/
scripts/
screenshots/
tests/
components/
announce.exe
samp-server.exe
samp-npc.exe
announce
samp03svr
samp-npc
omp-server.exe
omp-server
server.cfg
server_log.txt
log.txt
*.zip
*.rar
14 changes: 7 additions & 7 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Download SA-MP Server
run: wget https://github.com/MrDave1999/samp-server/releases/download/sampserver.v1/samp03.zip
- name: Unzip SA-MP Server
run: unzip samp03.zip -d ctf-gamemode-windows
- name: Move contents of samp03 to root directory
- name: Download open.mp Server
run: wget https://github.com/MrDave1999/env.server/releases/download/omp-server/open.mp-win-x86.zip
- name: Unzip open.mp Server
run: unzip open.mp-win-x86.zip -d ctf-gamemode-windows
- name: Move contents of Server to root directory
run: |
mv ctf-gamemode-windows/samp03/** ctf-gamemode-windows
rmdir ctf-gamemode-windows/samp03
mv ctf-gamemode-windows/Server/** ctf-gamemode-windows
rmdir ctf-gamemode-windows/Server
- name: Add plugins to server.cfg file
run: |
echo "" >> ctf-gamemode-windows/server.cfg
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CTF Deploy
name: CTF Deploy Production

on:
push:
Expand All @@ -17,7 +17,8 @@ jobs:
key: ${{ secrets.PRIVATE_KEY }}
port: 22
script: |
cd Capture-The-Flag
cd ctf-prod
git pull origin main
git status
sudo docker compose up --build -d
sudo docker compose up --build -d
sudo docker builder prune -f
24 changes: 24 additions & 0 deletions .github/workflows/deploy-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CTF Deploy Test

on:
push:
branches:
- test

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Deploy using ssh
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
port: 22
script: |
cd ctf-test
git pull origin dev
git status
sudo docker compose up --build -d
sudo docker builder prune -f
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,26 @@ samp-npc.exe
announce
samp03svr
samp-npc
components/
omp-server.exe
omp-server

# logs
logs/
server_log.txt
log.txt
crashinfo.txt

# License
samp-license.txt

# Ban list
samp.ban
bans.json

# IDE files (compiler, includes, etc)
pawno/
qawno/

# User-specific files
*.rsuser
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageVersion Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="SampSharp.Entities" Version="0.10.1" />
<PackageVersion Include="SampSharp.Streamer.Entities" Version="0.10.0" />
<PackageVersion Include="SampSharp.CTF.Entities" Version="0.10.8" />
<PackageVersion Include="SampSharp.CTF.Entities" Version="0.10.9" />
<PackageVersion Include="SampSharp.CTF.Streamer.Entities" Version="0.10.1" />
<PackageVersion Include="SmartFormat" Version="3.5.1" />
<PackageVersion Include="MySqlConnector" Version="2.3.7" />
Expand Down
28 changes: 12 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ COPY ["src/", "/app/src/"]
RUN dotnet publish --framework=net6.0 -c Release -o /app/out --no-restore

#
# Download SA-MP server and dotnet linux-x86
# Download open.mp server and dotnet linux-x86
#
FROM ubuntu:20.04 AS tools
FROM ubuntu:22.04 AS tools
RUN apt-get update && apt-get install -y --no-install-recommends wget

WORKDIR /sampserver
RUN wget https://gta-multiplayer.cz/downloads/samp037svr_R2-2-1.tar.gz --no-check-certificate \
&& tar -xf samp037svr_R2-2-1.tar.gz \
&& rm -f samp037svr_R2-2-1.tar.gz
WORKDIR /sampserver/samp03
RUN rm -rf filterscripts gamemodes include npcmodes scriptfiles server.cfg
WORKDIR /open-mp
ENV OPEN_MP_VERSION="1.3.1.2748"
RUN wget https://github.com/openmultiplayer/open.mp/releases/download/v${OPEN_MP_VERSION}/open.mp-linux-x86.tar.gz --no-check-certificate \
&& tar -xf open.mp-linux-x86.tar.gz \
&& rm -f open.mp-linux-x86.tar.gz
WORKDIR /open-mp/Server
RUN rm -rf filterscripts gamemodes include npcmodes scriptfiles config.json

WORKDIR /runtime
ENV TARGET_FRAMEWORK="6.0.35"
Expand All @@ -48,15 +49,13 @@ RUN wget https://github.com/Servarr/dotnet-linux-x86/releases/download/v${VERSIO
#
# Final stage/image
#
FROM ubuntu:20.04
FROM ubuntu:22.04
WORKDIR /app
EXPOSE 7777/udp

RUN dpkg --add-architecture i386
RUN apt-get update && apt-get install -y --no-install-recommends \
libc6:i386 \
libstdc++6:i386 \
libssl1.1:i386 \
libssl3:i386 \
libicu-dev:i386 \
tzdata \
&& rm -rf /var/lib/apt/lists/*
Expand All @@ -67,8 +66,5 @@ COPY ["plugins/*.so", "plugins/"]
COPY ["codepages/*.txt", "codepages/"]
COPY ["server.cfg.example", "server.cfg"]
COPY --from=tools /runtime runtime
COPY --from=tools /sampserver/samp03 .
RUN echo "" >> server.cfg \
&& echo "coreclr runtime" >> server.cfg \
&& echo "gamemode bin/CTF.Host.dll" >> server.cfg
COPY --from=tools /open-mp/Server .
COPY --from=build /app/out bin
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ There are 2 flags on the map, one for each team. Players need to capture the ene
- [Frameworks and libraries](#frameworks-and-libraries)
- [Testing](#testing)
- [Software Engineering](#software-engineering)
- [Programming Paradigms](#programming-paradigms)
- [Software Patterns](#software-patterns)
- [Design Principles](#design-principles)
- [Requirements to play](#requirements-to-play)
- [Deployment without Docker](#deployment-without-docker)
- [Deployment with Docker](#deployment-with-docker)
Expand Down Expand Up @@ -102,7 +105,7 @@ In this video, you can watch a gameplay demo: https://youtu.be/rsWCZaT4aBE or al

### Softwares
- [.NET CLI](https://learn.microsoft.com/en-us/dotnet/core/tools)
- [SA-MP Server](https://www.sa-mp.mp/downloads)
- [Open Multiplayer](https://github.com/openmultiplayer)
- [CompileApp-FS](https://github.com/MrDave1999/CompileApp-FS)
- [Visual Studio 2022](https://visualstudio.microsoft.com)
- [vscode](https://github.com/microsoft/vscode)
Expand All @@ -111,9 +114,10 @@ In this video, you can watch a gameplay demo: https://youtu.be/rsWCZaT4aBE or al
- [DB Browser for SQLite](https://sqlitebrowser.org)
- [HeidiSQL](https://github.com/HeidiSQL)
- [GitHub Actions](https://github.com/actions)
- [Git](https://git-scm.com)
- [Git](https://github.com/git/git)
- [draw.io](https://app.diagrams.net)
- [Docker](https://github.com/docker)
- [Portainer](https://github.com/portainer/portainer)

### Frameworks and libraries
- [.NET SDK 8.0](https://github.com/dotnet/runtime)
Expand All @@ -140,31 +144,38 @@ In this video, you can watch a gameplay demo: https://youtu.be/rsWCZaT4aBE or al

## Software Engineering

Software engineering concepts have been applied in this project:
These concepts have been applied to this project:

### Programming Paradigms
- [Object-oriented programming (OOP)](https://en.wikipedia.org/wiki/Object-oriented_programming)
- [Structured programming](https://en.wikipedia.org/wiki/Structured_programming)

### Software Patterns
- [Hexagonal architecture](https://en.wikipedia.org/wiki/Hexagonal_architecture_(software))
- [Entity–component–system (ECS)](https://en.wikipedia.org/wiki/Entity_component_system)
- [Object-oriented programming](https://en.wikipedia.org/wiki/Object-oriented_programming)
- [Interface-based programming](https://en.wikipedia.org/wiki/Interface-based_programming)
- [Modular programming](https://en.wikipedia.org/wiki/Modular_programming)
- [Dependency injection](https://en.wikipedia.org/wiki/Dependency_injection)
- [Repository Pattern](https://deviq.com/design-patterns/repository-pattern)
- [Operation Result Pattern](https://medium.com/@wgyxxbf/result-pattern-a01729f42f8c)
- [Guard Clause](https://deviq.com/design-patterns/guard-clause)
- [Open-closed principle](https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle)
- [Explicit dependencies](https://deviq.com/principles/explicit-dependencies-principle)

### Design Principles
- [Separation of concerns](https://en.wikipedia.org/wiki/Separation_of_concerns)
- [Open-Closed Principle](https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle)
- [Dependency Inversion Principle](https://deviq.com/principles/dependency-inversion-principle)
- [Explicit dependencies](https://deviq.com/principles/explicit-dependencies-principle)

## Requirements to play

- You must have **DirectX 9** installed on your local machine.
- You must download **Grand Theft Auto: San Andreas** on your local machine.
- You must download the [SA-MP client](https://www.sa-mp.mp/downloads) or the [open.mp launcher](https://github.com/openmultiplayer/launcher/releases) to connect to the servers.
- You must download [Grand Theft Auto: San Andreas](https://mega.nz/file/yFMjSLZA#8Amh1xyauAKO9Ff1lsbXHZIWHqPC4qEg2McfqhqoHTc) on your local machine.
- You must download [open.mp launcher](https://github.com/openmultiplayer/launcher/releases/latest) to connect to the servers.

## Deployment without Docker

- You must download [Visual C++ Redistributable x86](https://www.microsoft.com/en-us/download/details.aspx?id=48145) to load plugins such as SampSharp and Streamer.
- You need to download the [ctf-gamemode-windows.zip](https://github.com/MrDave1999/Capture-The-Flag/releases/latest) file that contains the files to run the game mode.
- Once downloaded, modify the `.env` file according to your needs.
- Run the `samp-server.exe`.
- Run the `omp-server.exe`.

## Deployment with Docker

Expand All @@ -186,9 +197,9 @@ docker compose up --build -d
```
- Check the server logs to see if everything is working properly:
```sh
docker compose exec -it app cat server_log.txt
docker compose exec -it app cat log.txt
```
- Add the server IP in your [SA-MP client](https://www.sa-mp.mp/downloads):
- Add the server IP in your [omp-launcher](https://github.com/openmultiplayer/launcher/releases/latest):
```
localhost:7777
```
Expand Down Expand Up @@ -289,9 +300,11 @@ See the [scripts](https://github.com/MrDave1999/Capture-The-Flag/tree/dev/script
## Credits

- [MrDave1999](https://github.com/MrDave1999/Capture-The-Flag) for creating the "Capture The Flag" game mode.
- [Parca_35](https://www.youtube.com/channel/UCQUOz-GEp0jMtmGzUEQWElQ) for helping test the game mode.
- [ikkentim](https://github.com/ikkentim/SampSharp) for creating the SampSharp framework.
- [Nickk888SAMP](https://github.com/Nickk888SAMP/TextDraw-Editor) for creating NTD (TextDraw Editor).
- [samp-incognito](https://github.com/samp-incognito/samp-streamer-plugin) for creating the streamer plugin.
- [Open Multiplayer](https://github.com/openmultiplayer) for creating a multiplayer mod for Grand Theft Auto: San Andreas fully backward compatible with San Andreas Multiplayer (SA-MP).

### Mappers

Expand Down
11 changes: 4 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ services:
command: >
bash -c "sed -i 's/lagcompmode 1/lagcompmode ${LagCompMode}/' server.cfg
&& sed -i 's/maxplayers 30/maxplayers ${MaxPlayers}/' server.cfg
&& ./samp03svr"
&& sed -i 's/port 7777/port ${Port}/' server.cfg
&& ./omp-server"
ports:
- ${Port}:7777/udp
- ${Port}:${Port}/udp
environment:
- TZ=${TZ}
volumes:
- ./scripts/sqlite:/app/scripts/sqlite
- ./logs:/app/logs

networks:
default:
name: 'gamemode-ctf'
- ./logs:/app/logs
Binary file modified filterscripts/Aim_Headshot.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/Aim_Headshot.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>
#define FILTER_SCRIPT_NAME "Aim_Headshot"
#include "objects"

Expand Down
Binary file modified filterscripts/Aim_Headshot2.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/Aim_Headshot2.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>
#define FILTER_SCRIPT_NAME "Aim_Headshot2"
#include "objects"

Expand Down
Binary file modified filterscripts/Area51.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/Area51.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>
#define FILTER_SCRIPT_NAME "Area51"
#include "objects"

Expand Down
Binary file modified filterscripts/Area66.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/Area66.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>
#define FILTER_SCRIPT_NAME "Area66"
#include "objects"

Expand Down
Binary file modified filterscripts/Compound.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/Compound.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>
#define FILTER_SCRIPT_NAME "Compound"
#include "objects"

Expand Down
Binary file added filterscripts/CrackFactory.amx
Binary file not shown.
8 changes: 8 additions & 0 deletions filterscripts/CrackFactory.pwn
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <open.mp>
#define FILTER_SCRIPT_NAME "CrackFactory"
#include "objects"

public OnFilterScriptInit()
{
return 1;
}
Binary file modified filterscripts/DesertGlory.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/DesertGlory.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>
#define FILTER_SCRIPT_NAME "DesertGlory"
#include "objects"

Expand Down
Binary file modified filterscripts/EntryMap.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/EntryMap.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>

public OnFilterScriptInit()
{
Expand Down
Binary file modified filterscripts/GateToHell.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/GateToHell.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>
#define FILTER_SCRIPT_NAME "GateToHell"
#include "objects"

Expand Down
Binary file added filterscripts/RC_Battlefield.amx
Binary file not shown.
8 changes: 8 additions & 0 deletions filterscripts/RC_Battlefield.pwn
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <open.mp>
#define FILTER_SCRIPT_NAME "RC_Battlefield"
#include "objects"

public OnFilterScriptInit()
{
return 1;
}
Binary file modified filterscripts/RemoveBuilding.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/RemoveBuilding.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>

public OnPlayerConnect(playerid)
{
Expand Down
Binary file modified filterscripts/SA_Hill.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/SA_Hill.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>
#define FILTER_SCRIPT_NAME "SA_Hill"
#include "objects"

Expand Down
Binary file modified filterscripts/Simpson.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/Simpson.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>
#define FILTER_SCRIPT_NAME "Simpson"
#include "objects"

Expand Down
Binary file modified filterscripts/TheBunker.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/TheBunker.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>
#define FILTER_SCRIPT_NAME "TheBunker"
#include "objects"

Expand Down
Binary file modified filterscripts/TheConstruction.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/TheConstruction.pwn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <a_samp>
#include <open.mp>
#define FILTER_SCRIPT_NAME "TheConstruction"
#include "objects"

Expand Down
Binary file modified filterscripts/TheWild.amx
Binary file not shown.
Loading

0 comments on commit 226202c

Please sign in to comment.