Skip to content

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) built with C# and 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

Features

  • Capture the Flag gameplay.
  • Configurable Weapon Packs.
  • Multiple weapon catalogs.
  • In-game coin economy.
  • Redeemable combat combos.
  • Optional GunGame mode.
  • Multiple GunGame weapon progressions.
  • Performance-based team balancing.
  • Automatic map rotation.
  • Player ranks and statistics.
  • SQLite and MariaDB support.
  • Docker support.

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

Additional Game Modes

GunGame

Besides the default Capture the Flag gameplay, the server includes an optional GunGame mode that can be enabled by administrators at runtime.

Unlike traditional GunGame servers, this mode does not replace Capture the Flag. Both game modes run simultaneously on the current map, allowing players to continue capturing flags while progressing through weapon levels.

Commands

Command Description
/gungameon <kills-per-level> Enables GunGame.
/gungameoff Disables GunGame.

Rules

  • Players start with the first weapon in the selected progression.
  • Every configured number of kills advances the player to the next weapon.
  • Knife kills steal one weapon level from the victim.
  • The first player to complete the progression wins the GunGame match.
  • Capture the Flag objectives remain active while GunGame is enabled.
  • Completing GunGame does not end the Capture the Flag match. Instead, the event concludes, the winner receives a special reward, their teammates receive a smaller bonus, and normal Capture the Flag gameplay continues.

Available Weapon Progressions

  • Classic
  • Reverse Classic
  • Pistols Only
  • SMGs Only
  • Shotguns Only
  • Rifles Only
  • Powerful Weapons

Weapon System

When players spawn, they are presented with a weapon selection menu containing the weapons available in the currently active weapon catalog.

Selected weapons are automatically saved to the player's Weapon Pack, allowing them to reuse the same weapons across future spawns without having to select their weapons again.

Weapon Catalogs

Administrators can change the active weapon catalog at runtime.

Available catalogs include:

  • Walking Weapons
  • Run Weapons
  • Run & Walk Weapons
  • Rifles Only
  • War Weapons
  • Heavy Weapons
  • Melee Weapons

Player Commands

Command Description
/weapons Opens the list of available weapons from the current catalog.
/weaponpack Displays the player's saved Weapon Pack. Weapons can be removed individually from this menu.

Admin Commands

Command Description
/weaponcatalog Changes the active weapon catalog at runtime.

GunGame Integration

When GunGame is enabled:

  • Weapon selection is disabled.
  • The Weapon Pack menu is disabled.
  • Weapon catalog changes are disabled.

This prevents conflicts with the GunGame weapon progression, where players are restricted to a single expected weapon.

Combo System

Coins

Players earn Coins by participating in the match.

Coins are awarded for actions such as:

  • Achieving kill streaks.
  • Eliminating the enemy flag carrier.
  • Capturing the enemy flag.
  • Returning the friendly flag.
  • Scoring a point for the team.
  • Ranking up.

Once a player reaches 100 Coins, they can use the /combos command to exchange all their coins for a temporary combat package.

Redeeming a combo resets the player's coin balance back to 0.

Available Combos

  • +100 Health, +100 Armour and Flamethrower
  • +100 Health, +100 Armour and Grenades
  • +100 Health, +100 Armour and Molotov Cocktails
  • +100 Health and Rocket Launcher (RPG) (disabled by default; admins can enable it with /rpgon)
  • +100 Health, +100 Armour and Satchel Charges
  • +100 Health, +100 Armour and Tear Gas

GunGame Integration

The /combos command is disabled while GunGame is active.

Additionally, Coins are no longer awarded for achieving kill streaks or ranking up during GunGame. This prevents players from accumulating enough Coins to redeem a combo immediately after the event ends. Rewards related to the core Capture the Flag gameplay, such as eliminating the enemy flag carrier, capturing the enemy flag, returning the friendly flag, and scoring points for the team, remain unchanged.

This prevents players from obtaining weapons outside the GunGame progression. Instead, the winner is rewarded with 100 Coins, fully restored Health and Armour, and a special weapon after completing the entire weapon progression. Since GunGame is integrated into the ongoing Capture the Flag match, the winner's teammates also receive a smaller bonus consisting of additional Health, Armour, and Coins.

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

sa-mp-005

sa-mp-005

sa-mp-006

sa-mp-006

sa-mp-007

sa-mp-007

sa-mp-008

sa-mp-008

sa-mp-009

sa-mp-009

sa-mp-010

sa-mp-010

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

  • Download the appropriate release package for your operating system:
  • Extract the package to a directory of your choice.
  • Modify the .env file according to your needs.
  • Start the Open Multiplayer server:
    • Windows: omp-server.exe
    • Linux: ./omp-server

Deployment with Docker

  • Clone the repository:
git clone --recursive 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:

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

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

Supported RDBMS

SQLite

  • 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
  • The database and its schema will be created automatically during server startup if they do not already exist.

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
  • The database and its schema will be created automatically during server startup if they do not already exist.

Architectural overview

Show diagram

overview

Main components

  • Application Core. Contains all gameplay logic for the Capture the Flag game mode, including the rules and procedures that define how the game is played. It also defines the outbound ports required to interact with external systems.
  • Persistence Adapters. Provide concrete implementations of the outbound ports related to persistence. Each adapter encapsulates the data access logic for a specific storage technology, allowing the application core to remain independent of any specific persistence technology.
  • Host Application. Acts as the application's entry point and contains everything required to bootstrap the game mode.
    • Load application settings from .env file.
    • Select the database provider.
    • Register services in the DI container.
    • Register ECS systems.
    • Enable desired ECS system features.

Credits

This project would not have been possible without the following people and projects:

  • DevD4v3 — Creator of the original Capture the Flag game mode.
  • Parca_35 — Helped test the game mode.
  • ikkentim — Creator of the SampSharp framework.
  • Nickk888SAMP — Creator of NTD (TextDraw Editor).
  • samp-incognito — Creator of the Streamer Plugin.
  • Open Multiplayer — Creator of open.mp, a multiplayer modification for Grand Theft Auto: San Andreas that is fully compatible with San Andreas Multiplayer (SA-MP).
  • OpenSamp
    • Maintainer of omp-streamer-component, the x64 port of Incognito's Streamer Plugin for open.mp.
    • Creator of SampSharp.OpenMp.Streamer, providing managed (.NET) bindings for the Streamer Plugin on the SampSharp open.mp x64 host.

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

About

A Capture the Flag game mode for open.mp (Open Multiplayer, a multiplayer mod for GTA San Andreas), built with C# and SampSharp

Topics

Resources

License

Stars

31 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages