Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/06/21 in all areas

  1. 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
    1 point
  2. You're welcome! And don't worry we all have been there.
    1 point
  3. local tick = getTickCount() local delay = 150 -- ms local jump = false addEventHandler("onClientRender", root, function() if getTickCount() - tick > delay then if getPedControlState(localPlayer, "jump") and not jump then outputChatBox("jump") jump = true elseif not getPedControlState(localPlayer, "jump") and jump then jump = false end tick = getTickCount() end end) So you can detect, regardless of the key that the player presses.
    1 point
  4. 1 point
  5. We have reason to believe you're engaged in malicous activities targetting MTA servers and/or users. If you are ready to speak the truth about what you did (in 2020), then you can create a new appeal. But not while lying, as right now @Pablo escobar
    1 point
  6. There you go, best tutorial out there:
    1 point
  7. I've been thinking of the easiest way to put this, but let's give it a shot. Your 'brother' (for my reply let's assume true.. true or not, you can imagine we often hear this) is a problem for MTA, because he is playing on a highly competitive server, CIT (in CIT LV which is even more competitive) and being part of a small group of people that you can find on any game where there is a high level of competition and serious stakes: cheaters. The thing is, on MTA the border for cheating is extremely high and most cheat devs already cannot even deliver a product, with AC being too strong. As MTA gets ahead of them, it gets to the point of sort of taking the kind of person of which most wouldn't be spending their time hacking games, but much bigger stuff in the real world. There is always someone out there that has the skills required, who can, after much grinding, discover a vulnerability (method) that allows them to write a cheat. The saying goes: nothing is ever fully secure. This group of people (3 to 4 CIT players - including "TucoS", another named "Kogar", and "Ammar" your 'brother') were so serious about their desire to cheat, that they resorted to hiring a private cheat developer, one that happens to also be skilled enough for the aformentioned. This small circle of cheaters is paying hundreds of dollars per working version, and they have already attracted & been supplied by this cheat developer a few years ago, including 2018 and 2019, getting banned and last chances multiple times. We caught up with them again, yesterday they all got banned. But this time, the ban is permanent, as they haven't learned from previous bans (when they got caught with custom cheats as well) and cannot be expected to ever change. We are now also making an example of them. It's obvious why MTA would want to ban this group of people for good. They are not welcome on MTA anymore after what happened several times. Their sweatiness when it comes to their desire and quest to cheat is also disgraceful, the example we are setting is mostly aimed at any of such niche groups at highly competitive servers, that would want to also hire a personal cheat dev to try and do something. It is to say that nothing is ever really undetected, undetectable and that anything leaves traces to AC, especially if it works. That we really are taking a more severe approach to any such individuals, it truly is malicious and hideous. Now you can understand why we would ban them forever. But on to you, as (if) a brother.. we also took further measures to ensure they will not ban evade and return. These measures can't be fully effective unless, besides for technical reasons we can't describe for security reasons, we also eliminate any physical possibility of them accessing MTA (like on 'your' PC) - even more so, we already know he (Ammar) used the PC with serial in the past, and even behind that we wouldn't take the 'brother' claim, because brother loyality (to let him play, eventually give your PC to him, things like that) would stand in the way of our decision to ensure these people won't evade their bans and return to MTA. But again, i already know this PC is regularly shared between you and him, so that flag doesn't even have to get raised. MTA has a serious stake to remove these people, including that being so sweaty about the ability to cheat in a very competitive server also means they would be equally sweaty about evading their bans and going on with their day (they have demonstrated to be willing to go very far).. we are really just removing them from our game for good now. And no you can't choose your brother (a cheater), so even if you were acting in good faith I am sorry to inform we can't change anything to this situation. Ban appeal denied.
    1 point
  8. look at my edit above. After testing i found that the mouse works in MTA aswell, this problem has been officialy fixed, just incase anyone else has this problem... right click on your shortcut to GTA and select properties, then chose the tab 'compatability' and check the box next to 'turn off advanced text services'. oh, ive found a new bug...... ahh forget it
    0 points
×
×
  • Create New...