Jump to content

Disinterpreter

Other Languages Moderators
  • Posts

    1,279
  • Joined

  • Last visited

  • Days Won

    3

Disinterpreter last won the day on October 30 2021

Disinterpreter had the most liked content!

About Disinterpreter

  • Birthday 28/11/1995

Member Title

  • Russian Section Moderator

Details

  • Gang
    MTA Roleplay
  • Location
    Russia, Vologda

Recent Profile Visitors

6,978 profile views

Disinterpreter's Achievements

Lil' G

Lil' G (37/54)

69

Reputation

  1. From https://github.com/multitheftauto/mtasa-blue/issues/2538#issuecomment-1029828744 Is anyone prove it for today? Seems like a bull:~ (sorry).
  2. I often see how people are trying to start server using really strange solutions. So I thought "I need to make a good tutorial", let's get it! You need a Linux server (I use Debian 10) and installed the server. Usually I put the server in /opt directory, in this tutorial we do it same. Part One: Installing the server Let's start to install pure Multi Theft Auto linux server. As a joke from bashorg said: "it only takes three commands to install Gentoo", you have to put only two commands apt install unzip wget https://linux.multitheftauto.com/dl/multitheftauto_linux_x64.tar.gz && \ tar xvf multitheftauto_linux_x64.tar.gz && \ rm multitheftauto_linux_x64.tar.gz &&\ cd multitheftauto_linux_x64/mods/deathmatch/ && \ wget https://linux.multitheftauto.com/dl/baseconfig.tar.gz && \ tar xvf baseconfig.tar.gz && \ mv baseconfig/* . && \ rm -rf ./baseconfig/ && \ mkdir resources && cd resources && \ wget https://mirror.multitheftauto.com/mtasa/resources/mtasa-resources-latest.zip && \ unzip mtasa-resources-latest.zip && \ rm mtasa-resources-latest.zip && \ cd ../../../ && chmod +x ./mta-server64 putty_xjovvhDRiG.mp4 What are about these commands? Downloading and unpacking mta server binaries Downloading and unpacking default configs Downloading and unpacking resources Part 2: Daemonization Many of tutorials was written when systemd isn't exists. But not today. Let's make a systemd unit. Before we're starting to do it, we need to check one thing. Basically MTA Server has ncurses UI, that's can be inconvenient for daemons, so we have to check flags. Okkay! We take them all! There are a lot of guides how to make different systemd units, but I've made the config for you. You only need to put the file into /etc/systemd/system/multitheftauto.service [Unit] Description=Multi Theft Auto Dedicated server After=network.target StartLimitIntervalSec=0 [Service] Type=simple Restart=always RestartSec=1 User=root WorkingDirectory=/opt/multitheftauto_linux_x64 ExecStart=/opt/multitheftauto_linux_x64/mta-server64 -t -n -u [Install] WantedBy=multi-user.target And make systemd reload the configs Need video? putty_QR8ebBKoVy.mp4 Seems like you're done all of my steps. What's next? There are good commands for management the unit 1. journalctl -u multitheftauto -n -f 2. systemctl enable multitheftauto 3. systemctl stop multitheftauto 4. systemctl restart multitheftauto 5. systemctl start multitheftauto 6. systemctl status multitheftauto 1. Reads logs in the stream 2. Enable the unit (after rebooting the server the unit will start) 3,4,5 Stop/restart/start the unit (the server) 6. Status of the unit (is it running? Stopped? and last lines from the std out) More info you may read here: https://www.freedesktop.org/software/systemd/man/journalctl.html and here: https://www.freedesktop.org/software/systemd/man/systemctl.html
  3. Я готов взяться за помощь (серверсайд), если весь код будет свободным ПО под лицензией AGPLv3
  4. Part 0; Preamble At the moment we have a long discussion about databases in the MTA Community, a huge part of the Team thinks that DB-drivers must be only as modules, but right now, we have only RDBMS databases(SQLite and MySQL). It isn’t enough for many dynamic MTA servers. So, I want to suggest an interesting solution to this problem, so let’s get started! Part 1; Tarantool When we think about DODBMS the first variant of this is MongoDB. MongoDB works well with JS, like nodejs, but I want to present to you the DODBMS which work with Lua. This database is sometimes similar to MongoDB, but it works only with Lua(and SQL but I don’t get it). You can put the data there, get it, and write functions. Cool! And this DBMS is used in production, the developer of this DB is MailRu Group, so, take my word for it, these clients are serious guys, especially MasterCard. Part 1.1: Setting and installing Tarantool https://www.tarantool.io/en/download/os-installation/debian/ After installing launch the command `tarantool` and load global config with command box.cfg{} Part 1.2: The space’s markup I'll try to make a managed alcohol list, so watch my hands -- a sequence box.schema.sequence.create('drinks_seq', { if_not_exists = true }) -- a space, like a table in MySQL box.schema.create_space('drinks', { if_not_exists = true, format={ { name = 'id', type = 'unsigned'}, { name = 'name', type = 'string'}, { name = 'count', type = 'unsigned'}} }) -- an index box.space.drinks:create_index('pk', { parts = { 'id' }, if_not_exists = true }) -- Insert 13 bottles of beer box.space.drinks:insert{box.sequence.drinks_seq:next(), 'Beer', 13} That’s all, the cascade has done! Part 1.3: Fall in love workarounds Without spoilers, our workaround is fetchRemote, so, do the server. Any solution from: https://github.com/tarantool/http#installation And take a look to my code: #!/usr/bin/env tarantool local http_router = require('http.router') local http_server = require('http.server') local json = require('json') -- Load default config box.cfg{} -- Start the server -- WARNING: 0.0.0.0 listen the port for all interfaces, don't do it, use 127.0.0.1! local httpd = http_server.new('0.0.0.0', 3820, { log_requests = true, log_errors = true }) local router = http_router.new() -- GET endpoint, returns data from database router:route({ path = '/drinks', method = 'GET' }, function() -- Load space local dspace = box.space.drinks -- Select all, too risky read more about select and limits -- Here: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_index/select/ local drinks = dspace:select{} return {status = 200, body = json.encode(drinks), headers = { ['content-type'] = 'application/json; charset=utf8' }} end ) -- PUT endpoint, add data to the database router:route({ path = '/drinks', method = 'PUT' }, function(req) local dspace = box.space.drinks -- [1] is https://github.com/multitheftauto/mtasa-blue/issues/1073 local body = req:json()[1] -- box.sequence.drinks_seq:next() is auto-increment local drinks = dspace:insert{box.sequence.drinks_seq:next(), body.type, tonumber(body.count)} if drinks then return {status = 200, body = json.encode(drinks), headers = { ['content-type'] = 'application/json; charset=utf8' }} else return {status = 200, body = '{"status": "something went wrong"}', headers = { ['content-type'] = 'application/json; charset=utf8' }} end end ) -- POST endpoint, edit the data in the database router:route({ path = '/drinks', method = 'POST' }, function(req) local dspace = box.space.drinks -- [1] is https://github.com/multitheftauto/mtasa-blue/issues/1073 local body = req:json()[1] -- Well... Complicated thing (not much) -- update(key, {{ = is assignment, number of field, value}, ...}) local drinks = dspace:update(tonumber(body.id), {{'=', 3, tonumber(body.count)}}) if drinks then return {status = 200, body = json.encode(drinks), headers = { ['content-type'] = 'application/json; charset=utf8' }} else return {status = 200, body = '{"status": "something went wrong"}', headers = { ['content-type'] = 'application/json; charset=utf8' }} end end ) httpd:set_router(router) httpd:start() After that we have to start it. cd /path/to/saved/script && chmod +x ./server.lua && ./server.lua Part 2.0: MTA resource The communication side will be simple command drinks with interactive options. local url = "http://127.0.0.1:3820/drinks" -- GET endpoint function showDrinks() local sendOptions = { queueName = "tarantool.drinks.get", method = "GET", } local successRemote = fetchRemote(url, sendOptions, function (responseData, responseInfo) local error = responseInfo.statusCode if error == 200 then print (responseData) end end ) end -- PUT endpoint function addDrinks(arg) local data = { type = tostring(arg[1]), count = tonumber(arg[2]) } local sendOptions = { queueName = "tarantool.drinks.add", postData = toJSON(data), method = "PUT", } local successRemote = fetchRemote(url, sendOptions, function (responseData, responseInfo) local error = responseInfo.statusCode if error == 200 then print ("Successfully added") end end ) end -- POST endpoint function updateDrinks(arg) local data = { id = tonumber(arg[1]), count = tonumber(arg[2]) } local sendOptions = { queueName = "tarantool.drinks.update", postData = toJSON(data), method = "POST", } local successRemote = fetchRemote(url, sendOptions, function (responseData, responseInfo) local error = responseInfo.statusCode if error == 200 then print ("Successfully updated") end end ) end -- Command handler addCommandHandler("drinks", function(ply, cmd, ...) local arg = {...} local subcmd = arg[1] -- subcmd is useless in the table table.remove(arg, 1) -- case/switch if subcmd == 'list' then showDrinks() end if subcmd == 'add' then addDrinks(arg) end if subcmd == 'update' then updateDrinks(arg) end end) And… That’s all. Look at the screenshot, it works! Conclusion: By the idea it must be simple only in resource without HTTP middleware, but at the moment it is impossible due to slow moving MTA progress, so if you like my tutorial and want to push my solution without middleware push ? and talk about it there. A solution without workaround: https://github.com/multitheftauto/mtasa-blue/issues/2208
  5. Попробуй кинуть от головы https://wiki.multitheftauto.com/wiki/ProcessLineOfSight Или https://wiki.multitheftauto.com/wiki/IsLineOfSightClear
  6. Может дело в дешманском хостинге с заниженными характиристиками?
  7. Ну если ты натыкаешь бесконечных циклов, то CPU от этого вырастит, например. Так же иногда в простое сервер всё же делает какие-то вещи(но обычно на гарфиках это пики вего лишь).
  8. Ну тогда я тут ничего сказать не могу. Надо изучать. AMX'у что-то не нравится конкретно в моде. Это надо изучать.
  9. Возьми архив отсюда https://github.com/multitheftauto/amx/issues/55 И положи сюда mods\deathmatch\
  10. Да. Я умею отказываться от кастомного лаунчера. Пользуйтесь тем что предоставила МТА. В противном случае, на данный момент, вы нарушаете GNU/GPLv3 и я не думаю, что мне разрешено оказывать вам помощь.
  11. Подчеркну маленькую мелочь, никто не пишет символ $ после числа. $ всегда пишется перед числом.
  12. Не могу. Не я же программист этого кода. Я только подсказал путь для решения.
  13. Нет, смотри, у тебя сейчас маркер находится внутри pickupJobTrudoustroistvo, однако addEventHandler находится в глобальном окружении. Тебе нужно чтобы addEventHandler видел твой маркер, как тебе посоветовали выше, ты можешь блок с addEventHandler добавить внутрь функции pickupJobTrudoustroistvo. Ну или есть десяток других способов.
×
×
  • Create New...