Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

A game mode for open.mp (Open Multiplayer) created with .NET/C# and SampSharp.net

License

Notifications You must be signed in to change notification settings

DevD4v3/Capture-The-Flag

Repository files navigation

🎮 Capture The Flag

A fast-paced C# game mode for open.mp — featuring two teams, two flags, and pure competitive chaos.

SA-MP logo

Capture The Flag is a game mode for open.mp (Open Multiplayer, a multiplayer mod for GTA San Andreas) created with the SampSharp framework.

There are 2 flags on the map, one for each team. Players need to capture the enemy's flag and bring it back to their own base.

Index

Gameplay

The Beta team plays against the Alpha team. The goal is to steal the enemy team’s flag and bring it back to the spawn of your own flag.

To score, your own flag must be at its base, so teams must attack and defend at the same time. Team coordination and tactical play are essential to win.

The match lasts 15 minutes. The team with the most captures when time runs out wins.
If both teams have the same number of captures, the match ends in a draw.

Beware! Enemies can see flag carriers on their radar.

In this video, you can watch a gameplay demo: https://youtu.be/rsWCZaT4aBE
You can also check the full playlist: https://www.youtube.com/playlist?list=PLBM-9TMXSAJjsWn4zmg1ua7eof9Aj83fS

Gameplay Rules

Game Objective

  • Steal the enemy team’s flag and bring it back to your base to score a capture.
  • The match does not end when a team reaches a specific number of captures.
  • The match only ends when the timer runs out.

Flag Rules

Stealing the enemy flag

  • A player can steal the enemy flag by picking up the flag pickup at the enemy base, marked by a square icon on the map.
  • A player can carry only one flag at a time.

Capturing (scoring a capture)

  • To score a capture, all of the following conditions must be met:
    • The player is carrying the enemy flag
    • The player reaches their own base or capture zone
    • The player’s team flag is at its base position
  • If the team’s flag has been stolen or is dropped somewhere on the map, a capture cannot be scored.

Flag carrier death

  • If a player dies while carrying the enemy flag:
    • The flag is dropped on the ground at the player’s current position
    • The player stops being the flag carrier

Flag carrier disconnection

  • If a player disconnects while carrying the enemy flag:
    • The flag is dropped on the ground at the player’s last known position
    • The player is removed from the match

Flag carrier inactivity (pause)

  • If a flag carrier remains paused or inactive for 30 seconds:
    • the enemy flag is automatically returned to its base
    • the player stops being the flag carrier

Flag auto-return

  • If a flag remains dropped on the map and is not recovered:
    • It automatically returns to its base after 120 seconds

Death and respawn

  • When a player dies:
    • Players respawn at their team’s base
    • A random spawn position is selected for the player (spawn location is not fixed)
    • No additional spawn protection is applied
    • If they were carrying a flag, the flag drop rule applies

Match end conditions

  • The match ends only when the timer reaches zero.
  • The team with the highest number of captures wins.
  • If both teams have the same number of captures:
    • The match ends in a draw
    • There is no sudden death

Round Transition Rules

  • Every 15 minutes, the current map ends and a new map is loaded.
  • During map rotation:
    • All connected players are frozen
    • Players are switched to spectator mode
  • A 10-second "loading map" countdown is displayed before the new round starts.
  • Teams are rebalanced based on player performance from the previous round:
    • Players are reassigned to teams according to their scores
    • Team balance is calculated automatically by the system
  • Players are not sent to the class selection screen:
    • Respawn is automatic
    • The system decides the spawn and team assignment

Screenshots

sa-mp-000

sa-mp-000

sa-mp-001

sa-mp-001

sa-mp-002

sa-mp-002

sa-mp-003

sa-mp-003

sa-mp-004

sa-mp-004

Technologies used

Programming Languages

Softwares

Frameworks and libraries

Testing

Software Engineering

These concepts have been applied to this project:

Programming Paradigms

Software Patterns

Design Principles

Requirements to play

Deployment without Docker

  • You must download Visual C++ Redistributable x86 to load plugins such as SampSharp and Streamer.
  • You need to download the ctf-win.zip file that contains the files to run the game mode.
  • Once downloaded, modify the .env file according to your needs.
  • Run the omp-server.exe.

Deployment with Docker

  • Clone the repository:
git clone https://github.com/DevD4v3/Capture-The-Flag.git
  • Change directory:
cd Capture-The-Flag
  • Copy the contents of .env.example to .env:
cp .env.example .env
  • Build the image and initiate services:
docker compose up --build -d
  • Check the server logs to see if everything is working properly:
docker compose exec -it app cat log.txt
localhost:7777

Credentials

The following table shows the default credentials for authentication from the game mode.

PlayerName Password
Admin_Player 123456
Moderator_Player 123456
VIP_Player 123456
Basic_Player 123456

Note that these credentials are only available if your database provider is in-memory. In your .env file you must indicate it as follows.

DatabaseProvider=InMemory

How to become an admin?

You must add your name and secret key from the .env file:

ServerOwner__Name=MrDave # Your nickname in the game
ServerOwner__SecretKey=1234._%==?! # Specify the secret key to give me admin.

It is necessary to specify your secret key, which you will use when executing the command "/givemeadmin" in the game.

Supported RDBMS

SQLite

  • Download sqlite3 CLI from here (select the file named sqlite-tools-win-x86).
  • Create a file called .env in the root directory:
copy .env.example .env
  • You must specify the name of the database provider from the .env file:
DatabaseProvider=SQLite
  • You must specify the location of the database file:
SQLite__DataSource=C:\Users\mrdave\OneDrive\Desktop\gamemode.db
  • Finally, you must import the database:
sqlite3 gamemode.db < ./scripts/sqlite/gamemode.sql

See the scripts for more information.

MariaDB

  • Install MariaDb Server and set up your username and password.
  • Create a file called .env in the root directory:
copy .env.example .env
  • You must specify the name of the database provider from the .env file:
DatabaseProvider=MariaDB
  • You must specify the connection string in the .env file:
MariaDB__Server=localhost
MariaDB__Port=3306
MariaDB__Database=gamemode
MariaDB__UserName=root
MariaDB__Password=123456789
  • Finally, you must import the database:
mariadb -uroot -p123456789 gamemode < ./scripts/mariadb/gamemode.sql

See the scripts for more information.

Architectural overview

Show diagram

overview

Main components

  • Application Core. Contains all the logic of the game called "Capture The Flag", including the rules and procedures that define how the game is played.
  • Persistence layer. Contains all data access logic. The purpose of this layer is to prevent the filtering of data access logic in the application core.
  • Host Application. Contains everything needed to run the game mode. It represents the entry point of the application. This layer performs other tasks such as:
    • Load application settings from .env file.
    • Select the database provider.
    • Register services to DI Container.
    • Add systems to the services collection.
    • Enable desired ECS system features.

Credits

  • DevD4v3 for creating the "Capture The Flag" game mode.
  • Parca_35 for helping test the game mode.
  • ikkentim for creating the SampSharp framework.
  • Nickk888SAMP for creating NTD (TextDraw Editor).
  • samp-incognito for creating the streamer plugin.
  • Open Multiplayer for creating a multiplayer mod for Grand Theft Auto: San Andreas fully backward compatible with San Andreas Multiplayer (SA-MP).

Mappers

  • Area66 by DragonZafiro.
  • d_dust5, SA_Hill, de_aztec and de_dust2_small by Elorreli.
  • Compound and cs_rockwar by Amirab.
  • DesertGlory, fy_iceworld2 and de_dust2x3 by TheYoungCapone.
  • EntryMap and TheConstruction by B4MB1[MC].
  • fy_snow by UnuAlex.
  • fy_snow2 by mihaibr.
  • de_dust2 by JamesT85.
  • Aim_Headshot by haubitze.
  • Aim_Headshot2 by Niktia_Ruchkov.
  • de_dust2x1 by SpikY_.
  • de_dust2x2 by Amads.
  • de_dust2x4 textured by excamunicado.
  • WarZone by Samarchai.
  • WarZone2 by iMaster.
  • cs_assault by Ghost-X.
  • GateToHell and TheWild by Zniper.
  • TheBunker by Dr.Pawno.
  • cs_deagle5 by SENiOR.
  • mp_jetdoor by saawan.
  • Simpson by Risq.
  • ZM_Italy - Unknown.
  • zone_paintball by Famous.
  • mp_island by Leo.
  • Baron's Playground (RC Battlefield V2) by Pyraeus.
  • cs_train, cs_opposition, fy_iceworld and de_dust2x5 by denis_32.

Contribution

Any contribution is welcome! Remember that you can contribute not only in the code, but also in the documentation or even improve the tests.

Follow the steps below:

  • Fork it
  • Create your custom branch (git checkout -b my-new-change)
  • Commit your changes (git commit -am 'Add some change')
  • Push to the branch (git push origin my-new-change)
  • Create new Pull Request

License

This project is licensed under the GNU Affero General Public License v3.0