Jump to content

botder

MTA Team
  • Posts

    524
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by botder

  1. In your Video settings should be an option called Enable Device Selection Dialog, which you can un-tick to disable that dialog.

    This dialog shows the name of your GPU, where each of your monitor is plugged into.

    • Like 1
  2. If you want to test your script with two players on a single machine you should use a virtual machine.

    If you want to run two servers on your local machine you have to run both servers on different ports.

    If you want to play on two servers simultanously then you should go with the first option.

    I didn't understand your suggestion/idea.

    • Like 1
  3. You can run MTA:SA in a virtual machine, which in turn is running Windows.

    You can also run GTA:SA (and maybe MTA:SA) with Wine.

    There are no other options, because MTA:SA only supports the Windows release of the GTA:SA game.

  4. You can make your own script, which is loaded before the encrypted script. You can overwrite functions in your own script to output the URL in debug and then spoof the result whenever the encrypted script does a callRemote.

    -- Store the original function
    local _callRemote = callRemote
    
    -- Overwrite the global function for our purpose
    function callRemote(url, a, b, c, d, ...)
        outputDebugString(("callRemote(%q, ...)"):format(url))
        
        -- Should we spoof the result?
        if url ~= "<url which returns ip>" then
            return _callRemote(url, a, b, c, d, ...)
        end
    
        -- callRemote(url, callback)
        if type(a) == "function" then
            return callback("<fake data from url>", 200, b, c, d, ...)
        end
        
        -- callRemote(url, attempts, callback)
        if type(b) == "function" then
            return callback("<fake data from url>", 200, c, d, ...)
        end
    
        -- callRemote(url, attempts, timeout, callback)
        if type(c) == "function" then
            return callback("<fake data from url>", 200, d, ...)
        end
    
        -- callRemote(url, queueName, attempts, timeout, callback)
        if type(d) == "function" then
            return callback("<fake data from url>", 200, ...)
        end
    end

     

    • Like 1
  5. function splitf(input, separator)
        local output = split(input, separator)
    
        for index = 1, #output do
            local fragment = output[index]
    
            if fragment:match("^%d") then
                output[index] = tonumber(fragment:match("^%d+%.?%d+"))
            end
        end
    
        return output
    end

    Example:

    output = {"Hello", "123", "World", "123prefix", "3.141wtf", "suffix456"}
    1    Hello      string
    2    123        number
    3    World      string
    4    123        number
    5    3.141      number
    6    suffix456  string

     

  6. What you want is data serialization. There are different ways to store information e.g. in files, in memory, in databases etc. You should consider that other servers might want to store other useful information about elements (e.g. you might store the owner of the vehicle) and each of these servers use a different method to store the information. You have the Lua language and the MTA functions to make your own serialization structure. You can go ahead, make a serialization "library" for MTA and release it for others.

  7. 8FDkeV7.png

    --[[ Draw a fancy bounding box:
        c-----d
        |\   /|
        | \ / |
        |  x  |
        | / \ |
        |/   \|
        a-----b
    ]]
    local minX, minY, minZ, maxX, maxY, maxZ = vehicle:getBoundingBox()
    
    local a = vehicleMatrix:transformPosition(Vector3(minX, minY, maxZ))
    drawTextOnWorldPosition("a", a)
    local b = vehicleMatrix:transformPosition(Vector3(maxX, minY, maxZ))
    drawTextOnWorldPosition("b", b)
    local c = vehicleMatrix:transformPosition(Vector3(minX, maxY, maxZ))
    drawTextOnWorldPosition("c", c)
    local d = vehicleMatrix:transformPosition(Vector3(maxX, maxY, maxZ))
    drawTextOnWorldPosition("d", d)
    
    dxDrawLine3D(c, d, 0xFFFF0000, 1.0)
    dxDrawLine3D(a, b, 0xFFFF0000, 1.0)
    dxDrawLine3D(c, a, 0xFFFF0000, 1.0)
    dxDrawLine3D(d, b, 0xFFFF0000, 1.0)
    dxDrawLine3D(a, d, 0xFFFF0000, 1.0)
    dxDrawLine3D(b, c, 0xFFFF0000, 1.0)
    function drawTextOnWorldPosition(text, vecPosition)
        local x, y = getScreenFromWorldPosition(vecPosition)
    
        if x and y then
            dxDrawText(text, x, y, nil, nil, 0xFFFFFFFF, 2.0, "default-bold", "center", "center")
        end
    end

    You didn't tell me what you want to do, my previous code segment only solved the question in the first post.

  8. You need OOP enabled:

    function getElementRotatedBoundingBox(element)
        local elementMatrix = element:getMatrix()
        local minX, minY, minZ, maxX, maxY, maxZ = element:getBoundingBox()
        local minVector = elementMatrix:transformPosition(Vector3(minX, minY, minZ))
        local maxVector = elementMatrix:transformPosition(Vector3(maxX, maxY, maxZ))
        return minVector, maxVector
    end

     

  9. On 7.1.2017 at 2:47 PM, K1parik said:

    why is that?

    ERROR: discord/socket.lua:56: attempt to call global 'sockOpen' (a nil value)

    You are missing the socket module for your MTA server. There is a check in place to prevent starting the resource without it, which you probably circumvented, because the resource stops immediately if it's not available.

    • Like 1
  10.                                                                      1 second
                                                      1 minute  =       60 seconds
                                       1 hour  =     60 minutes =     3600 seconds
                           1 day  =   24 hours =   1440 minutes =    86400 seconds
              1 month  =  31 days =  744 hours =  44640 minutes =  2678400 seconds
    1 year = 12 months = 365 days = 8760 hours = 525600 minutes = 31536000 seconds

     

    • Like 2
  11. 1 hour ago, LoPollo said:

    Sure, i copied pasted it

    EDIT: nope i had in the clipboard the token of another app i tried to use for this, SO THE TOKEN WAS WRONG. But even after copying the correct token the problem is still here

    https://github.com/Necktrox/mta-discord-bot/commit/da6cd936a57ef106b2c612fd7dec0bc893de216c

    Fixed, I didn't test this part of the code, because I modified my config to include the "Bot " prefix and never tested it without it. Sorry for any inconvenience.

    • Like 1
  12. 5 hours ago, LoPollo said:

    @Necktrox can you tell me how to use the bot? I know it's node.js (right?), npm to install, but then when i have to configure i have no idea what to do. BTW nice job!

    There are 3 parts, the relay server and 2 MTA resources. You can install PM2 (Unitech/pm2) to launch the relay node.js server. You only have to duplicate example.config.json as config.json, make your changes to the configuration and run the relay.

    Below is a copy of my PM - how to configure the relay.

    Token

    1. Visit Applications @ discordapp.com
    2. Create a new application if not done yet or select an existing one
    3. Create a bot user for the application
    4. Reveal the bot user token (you have to click on 'click to reveal')
    5. Copy the entire bot token and paste it into your config (see example below)

    Note: Do not share this bot token with anybody, because they will have access to the bot user.

    Passphrase

    This is a random text passphrase you can set to anything you want. Make sure the MTA resource uses the same passphrase in the configuration, otherwise the MTA resource won't be able to authenticate with the node.js relay. The passphrase is like a login password just to make sure nobody can connect to the node.js relay and send messages/spam without your permission to do so.

    Example Configuration?

    1. {
    2.     "port": 8100, // You can use any port you want
    3.     "passphrase": "super-secret-password", // You can use any passphrase you want
    4.     "server": "228439442069651456", // Discord server/guild id from Mr.Green Discord guild
    5.     "bots": [{
    6.         "channel": "race", // Name of the channel the bot communicates on (here: #race, do not include the hash #)
    7.         "token": "bot.token" // Your secret bot user token (do not share this code with others)
    8.     }]
    9. }

    Warning: JSON configuration files do not support comments. Remove these.

    • Like 1
  13. 50 minutes ago, specahawk said:

    Also, I don't understand why you have separate resources for the events and the actual API. This is a design decision ofc, but is it worth running two separate Lua VMs?

    One the one hand you are forced to keep OOP disabled in any resource, which uses the socket module's functions; and I like to use the OOP methods, because the code looks cleaner and easier to read when you try to understand it. On the other hand, you can restart the event handler resource without interrupting the connection with the Discord relay - I have to admit here, that I didn't have any specific reason not to use one resource, it was personal preference.

    56 minutes ago, specahawk said:

    The split function in util splits according to the separator, but do you escape the separator (like URL encode it maybe) anywhere? If the separator can be a part of the actual message then I have some snippet I made for this project to safely escape/unescape strings which I can send a pull request for.

    I actually encode the JSON string with base64 to avoid this issue, see here.

×
×
  • Create New...