Skip to content

Commit

Permalink
Initial Code Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaosParadise committed Jul 22, 2021
1 parent acb48b1 commit 5ee1104
Show file tree
Hide file tree
Showing 3,646 changed files with 370,288 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
45 changes: 45 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# MTA Generated
/dumps
/dumps/*
*Thumbs.db
*.log
*.tex
*.db
*.db-journal
/mta-server64
/mta
/x64
MTA Server.exe
core.dll
libcurl.dll
mods/deathmatch/dbconmy.dll
mods/deathmatch/deathmatch.dll
mods/deathmatch/libmysql.dll
mods/deathmatch/lua5.1.dll
mods/deathmatch/pcre3.dll
net.dll
pthread.dll
xmll.dll
mods/deathmatch/server-id.keys
LICENSE
NOTICE
README
mods/deathmatch/dumps/
local.conf
banlist.xml
logs
data




# Owl Configuration
/mods/deathmatch/resource-cache/
/mods/deathmatch/resources/guieditor/
/mods/deathmatch/settings.xml
/mods/deathmatch/mtaserver.conf

# Version Control
.vscode
.git
.gitlab-ci.yml
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# MTA Generated
/dumps
/dumps/*
*Thumbs.db
*.log
*.tex
*.db
*.db-journal
/mta-server64
/mta
/x64
MTA Server.exe
core.dll
libcurl.dll
mods/deathmatch/dbconmy.dll
mods/deathmatch/deathmatch.dll
mods/deathmatch/libmysql.dll
mods/deathmatch/lua5.1.dll
mods/deathmatch/pcre3.dll
net.dll
pthread.dll
xmll.dll
mods/deathmatch/server-id.keys
LICENSE
NOTICE
README
mods/deathmatch/dumps/
local.conf
banlist.xml




# Owl Configuration
/mods/deathmatch/resource-cache/
/mods/deathmatch/resources/guieditor/
/mods/deathmatch/settings.xml
/mods/deathmatch/mtaserver.conf

# Personal
.vscode
40 changes: 40 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
image: docker:latest

services:
- docker:dind

stages:
- build
- release

variables:
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest

before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY

build:
stage: build
script:
- docker build --pull -t $CONTAINER_TEST_IMAGE .
- docker push $CONTAINER_TEST_IMAGE
only:
- master
- develop
- tags


release-image:
stage: release
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
- apk add curl
- curl -X POST $WEBHOOK_URL
variables:
# Don't clone
GIT_STRATEGY: none
only:
- master
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM debian:stable-slim

# Dependencies
RUN apt-get update && apt-get install -y \
unzip \
wget \
default-libmysqlclient-dev \
libncurses5-dev \
libncursesw5-dev \
libncurses5 \
libncursesw5 \
&& apt clean \
&& ldconfig

# Creates a system user with no password and a home directory
RUN useradd -d /home/mtasa -m mtasa

# Setup our workdir
WORKDIR /home/mtasa/

# Download the latest linux server binaries and set them up in /home/mtasa/server
RUN wget -O mta.tar.gz https://linux.mtasa.com/dl/multitheftauto_linux_x64.tar.gz \
&& tar xfz mta.tar.gz \
&& mv multitheftauto_linux_* server \
&& rm mta.tar.gz \
&& adduser -h /home/mtasa -D -S mtasa \
&& chown -R mtasa server

# Copy our source code over
COPY --chown=mtasa mods/deathmatch/ server/mods/deathmatch/

RUN mv server/mods/deathmatch/linux-libs/* /usr/lib/x86_64-linux-gnu/

USER mtasa

EXPOSE 22003 22005 22126
# Can set defaults like so:
# ENV SERVER_IP 127.0.0.1

ADD --chown=mtasa docker-entrypoint.sh ./docker-entrypoint.sh
RUN chmod +x docker-entrypoint.sh
ENTRYPOINT [ "./docker-entrypoint.sh" ]
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# OwlGaming MTA

This repository contains the OwlGaming MTA codebase for Multi Theft Auto. The recommended way to deploy the code is using a docker image.

## Building for release

- Build the image `docker build -t owlgaming-mta .`
- Refer to the environment variable below and deploy using your MySQL Database
```shell
docker run -p 22003:22003 -p 22005:22005 -p 22126:22126/udp -e MTA_DATABASE_NAME=... owlgaming-mta
```
- You can grab the latest structures for your database from `mods/deathmatch/data`

## Logs

Logs are written to `mods/deathmatch/resources/logs/logs` as they are created in game. It's recommended to pick these up using Filebeat with Elasticsearch to make them searchable.

## Quick Links

* [Coding Conventions](coding_conventions.md)
* [Useful Functions](useful_functions.md)

## Docker Build Environment Variables

### MTASERVER.CONF
- `SERVER_IP`
- `SHOULD_BROADCAST`
- `OWNER_EMAIL_ADDRESS`

### SETTINGS.XML
- `PRODUCTION_SERVER`
- `MTA_DATABASE_NAME`
- `MTA_DATABASE_USERNAME`
- `MTA_DATABASE_PASSWORD`
- `MTA_DATABASE_HOST`
- `MTA_DATABASE_PORT`

- `CORE_DATABASE_NAME`
- `CORE_DATABASE_USERNAME`
- `CORE_DATABASE_PASSWORD`
- `CORE_DATABASE_HOST`
- `CORE_DATABASE_PORT`

- `FORUMS_API_KEY`
- `IMGUR_API_KEY`
86 changes: 86 additions & 0 deletions coding_conventions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Introduction to Coding Conventions #

## 1 - What is Coding Convention? ##

Coding conventions are a set of guidelines that recommend programming style, practices and methods for each aspect of a script written in this server. These conventions I want you all to follow cover indentation, comments, declarations, statements, white space, naming conventions, programming practices, programming principles, etc.

These are guidelines for script structural quality. All scripters are highly recommended to follow these guidelines to help improve the readability of server's source code and make the system maintenance and development easier.

## 2 - Why are Coding Conventions so important? ##

Code conventions are important to scripters for a number of reasons:

* 40%-80% of the lifetime we spend on a script goes to maintenance.
* Hardly any complex script or system is maintained for its whole life by the original author.
* Coding conventions improve the readability of the software, allowing scripters to understand new code more quickly and thoroughly.



# II - Explanations #

## 1. Comments ##

A comment is not only be used to disable a block of script but also is used to embed readable annotations in the script .Those annotations are potentially significant to scripters but are ignored by compilers and interpreters.

Comments are added with the purpose of making the script easier to understand. The syntax for comments in LUA is -- at the end of the line or --[[ & ]] at the beginning and at the end of the block.

Example:
![Desert.jpg](http://puu.sh/7Th8w.png)

## 2. Indentation ##

An indent style is a convention governing the indentation of blocks of script to convey the script's structure. Indent style is just one aspect of programming style but it's the only one I need you all to understand and follow.

Indentation is a must when you script in owlgaming scripting team, it better convey the structure of your script to human readers. In particular, indentation is used to show the relationship between control flow constructs such as conditions or loops and code contained within and outside them.

Good example:
![Desert.jpg](http://puu.sh/7TgdL.png)

Bad example:
![Desert.jpg](http://puu.sh/7Tgb5.png)


## 3. Function & variable naming conventions ##

A naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types, functions, and other entities in scripts.

Reasons for using a naming convention (as opposed to allowing scripters to choose any character sequence) include the following:

* to reduce the effort needed to read and understand the script.
* to enhance script appearance (for example, by disallowing overly long names or unclear abbreviations).



Some of the potential benefits that can be obtained by adopting a naming convention include the following:

* to provide additional information about the use to which an identifier is put;
* to help formalize expectations and promote consistency within the scripting team;
* to enable the use of automated refactoring or search and replace tools with minimal potential for error;
* to enhance clarity in cases of potential ambiguity;
* to enhance the aesthetic and professional appearance of script (for example, by disallowing overly long names, comical or "cute" names, or abbreviations);
* to provide meaningful data to be used in script handovers which require submission of source code as you will have to post on this forum sometimes.
* to provide better understanding in case of code reuse after a long interval of time.


The choice of naming conventions can be an enormously controversial issue. However, there will be no issue if you follow this convention I set here:

1. Resource, Function & Variable need to be short and descriptive.
1. Function have first character of the word in upper case while other characters are in lower case, except the first word.
1. Resource have all characters of the word in lower case.
1. Good examples of function & variable naming: isPlayerStaff(), isElementProcessed(), openInterior(), closeInventory(), getVehicle(), dateOfMonth, leapYear, terryBear.
1. Bad examples of function & variable nameing: a12, x2, x3, doIt(), finishingStuff(), StartProcessing(), GETTHERE().

## 4. Versioning Convention ##
For global server script version:
A.B.C.D in which:
* 10 D units equal to 1 C unit; 10 C units equal to 1 B unit and so on.;
* 1 D unit equals to 1 minor change/fix.;
* 1 C unit equals to 1 newly created script/system/major change.;

For single script/system version
A.B in which
* 10 B units equal to 1 A unit.;
* Even version means stable version.;
* Odd version means unstable/stresstesting version.;

The purposes of versioning is to let you know how much has been updated compared to previous versions and to let you know how complete a single script/system you're using is.
47 changes: 47 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh
set -e

# Make sure line endings are properly set

cd /home/mtasa/server/

# SET THE mtaserver.conf FROM mtaserver.conf.bak
cat ./mods/deathmatch/mtaserver.conf.bak \
| sed "s/SERVER_IP/${SERVER_IP}/" \
| sed "s/SHOULD_BROADCAST/${SHOULD_BROADCAST}/" \
| sed "s/mta_mysql.dll/mta_mysql.so/" \
| sed "s/bcrypt.dll/bcrypt.so/" \
| sed "s/OWNER_EMAIL_ADDRESS/${OWNER_EMAIL_ADDRESS}/" \
> ./mods/deathmatch/mtaserver.conf

# SET THE settings.xml FROM settings.xml.bak
cat ./mods/deathmatch/settings.xml.bak \
| sed "s/PRODUCTION_SERVER/${PRODUCTION_SERVER}/" \
| sed "s/MTA_DATABASE_NAME/${MTA_DATABASE_NAME}/" \
| sed "s/MTA_DATABASE_USERNAME/${MTA_DATABASE_USERNAME}/" \
| sed "s/MTA_DATABASE_PASSWORD/${MTA_DATABASE_PASSWORD}/" \
| sed "s/MTA_DATABASE_HOST/${MTA_DATABASE_HOST}/" \
| sed "s/MTA_DATABASE_PORT/${MTA_DATABASE_PORT}/" \
| sed "s/CORE_DATABASE_NAME/${CORE_DATABASE_NAME}/" \
| sed "s/CORE_DATABASE_USERNAME/${CORE_DATABASE_USERNAME}/" \
| sed "s/CORE_DATABASE_PASSWORD/${CORE_DATABASE_PASSWORD}/" \
| sed "s/CORE_DATABASE_HOST/${CORE_DATABASE_HOST}/" \
| sed "s/CORE_DATABASE_PORT/${CORE_DATABASE_PORT}/" \
| sed "s/FORUMS_API_KEY/${FORUMS_API_KEY}/" \
| sed "s/IMGUR_API_KEY/${IMGUR_API_KEY}/" \
| sed "s/WEBSITE_PASSWORD/${WEBSITE_PASSWORD}/" \
> ./mods/deathmatch/settings.xml

# Move our modules to the right paths
if [ ! -d "./x64/modules" ]; then
mv ./mods/deathmatch/modules/ ./x64/modules
# Delete the conflicting linux lib
# rm ./x64/linux-libs/libstdc++.so.6
# apparently they don't include it anymore
fi

# Start mtasa server
exec ./mta-server64 -n -t -u

# The flags allow us to Cntrl+C or docker stop gracefully
# Details here: https://github.com/multitheftauto/mtasa-blue/blob/master/Server/launcher/Main.cpp
Loading

0 comments on commit 5ee1104

Please sign in to comment.