Jump to content

savour

Members
  • Posts

    45
  • Joined

  • Last visited

Posts posted by savour

  1. Well, in "embeds" you can embed more than one embed, so you have to put it on another table (table per embed)

    
    embeds = {
    	{	-- This is embed number 1
    	  title = "Hi",
    	  description = " S6066 authored & committed",
    	  fields={
    		  {name="1",value="2"},
    		  {name="3",value="4"}
    		},
    	  footer = {
    		  text = "Woah! So cool! :smirk:",
    		  icon_url = "https://i.imgur.com/fKL31aD.jpg"
    		}
    	}
    }

     

  2. 11 hours ago, majqq said:

    I would like to try this way, but what do u mean by saying "a little buggy"?

     

    Someone told me that he had bugs retrieving the false values from a json table (makes the value nil, which results of removing it from the Lua table). I didn't really test that bug but it should be fine, you can make some work around if you encountered it, not fatal bugs at the end so you are good to go (still, columns or another table are easier)

  3. IIYAMA's answer is the ideal way to handle that, storing items in a separate table, or use add another columns to your existing table. you can still store a whole table at one cell by the way but maybe you will find it a little buggy. you can store the table in a cell as JSON (text) using toJSON(table), and when you retrieve it use fromJSON()

    • Like 2
  4. 6 hours ago, majqq said:

    Here comes first question, i would need to get some basic data on resource start about player, in this case nick, serial and IP.

    When you poll the query, it returns a table including other tables, each one represents a row, like this:

    local dbQ = dbQuery(database, "SELECT * FROM `players` WHERE `serial` = ?", player_serial)
    local dbR = dbPoll(dbQ, -1)
    -- in this case you're only expecting one row so the player will be dbR[1]
    serial = dbR[1].serial
    name = dbR[1].name
    
    -- If you're dealing with multiple entries:
    local dbQ = dbQuery(database, "SELECT * FROM `players`")
    -- This will result:
    {
      {name = "player1", serial="serial1", ...},
      {name = "player2", serial="serial2", ...},
      -- and so on
    }
      

     

    About the dbExec, it will almost have no effect on the performance in your case, the query when the resource start will take some milliseconds ( kind of unnoticeable server lag ), so it should be fine. also you can test the performance by the getTickCount function to make sure everything is good

    • Like 1
  5. 11 hours ago, majqq said:

    I don't clearly understand, what means that it will freeze entire server? It is some kind of lag, until function is executed? If so, then how many ms would be a decent value here?

     

    It means that it will wait for the results from the database, then continue executing, however, if the function didn't receive any value from the query during the `timeout` it will return nil, then continue the execution.

    for SQLite, you shouldn't worry about that (since it is on the same server, you almost get an instant response) so an ideal value should be -1 (no timeout) if you are dealing with a well-made database and healthy queries.

    11 hours ago, majqq said:

    https://wiki.multitheftauto.com/wiki/DbExec

    This function is meant to change something in database, and it doesn't give any return in back? For example creating tables if they not exist? Should be always used within dbFree?

     

    This function, dbExec, doesn't return any value related to the query, it just executes the query, so you don't need a dbFree. (also, dbFree is used on a dbQuery return)

    and yea, you should use it when you expect no return from it, like creating tables of not exists, updating, dropping/deleting.

    11 hours ago, majqq said:

    https://wiki.multitheftauto.com/wiki/DbQuery

    This one should be used within dbPoll to get result? Plus dbFree in case of don't using dbPoll?

     

    Use dbPoll if you're expecting a result, dbFree if you don't expect a result (just like using dbExec). i will make it clearer:

    -- Here, you don't expect a result
    local qh = dbQuery(connection, "CREATE TABLE IF NOT EXISTS table_name")
    dbFree(qh)
    -- This is the same as
    dbExec(connection, "CREATE TABLE IF NOT EXISTS table_name")
    
    -- Here, you are expecting a result
    local qh = dbQuery(connection, "SELECT * FROM table_name")
    local result = dbPoll(qh, -1)	-- (When using -1 timeout, you don't really need to use dbFree)

    However,  you should use dbFree when setting a 0+ timeout with a chance of failure.

    12 hours ago, majqq said:

    I can't access debugdb for some reason, probably is due of ACL, however i couldn't find anything related with them in ACL, or i simply removed/skipped it.

     

    It's a server-console command, which means that it's only available on the server's command prompt

    12 hours ago, majqq said:

    https://wiki.multitheftauto.com/wiki/DbPrepareString

    This function is meant to help and prevent SQL injections. So it should be all the time i guess? As i see this function also allows to create a big query with loop.

     

    You should always use it in general. it makes quotes and other stuff to make sure it doesn't contain a second statement (which is the basic SQL Injection) is there. for the loops thing, it return a string and you concatenate it, so you can print it to see the difference, you will understand it more this way.

    one more thing, string buffering is extremely bad for the performance, instead use a table and concatenate it later.

    • Like 1
  6.  

    On 02/09/2019 at 22:40, edge said:

    I've found that, but I'm getting some errors when I'm trying to add the file as a cog to the bot. Any advices?

    Show me the error, and the area where it happens

  7. It's totally expected, when you hide the gui at the first time, isCursorShowing will return false after, so when you execute the function again it will show the cursor, as simple as that:

    not true = false

    not false = true

    So, it you only want to hide it, why checking for its visibility

     

    showCursor(false, true)

     

    • Like 1
  8. In the first case, the first argument is the player who typed the command, and it's up to you to call it whatever you want.

    in the second case the source gotta be defined in the parent event/function, also it refers for "which element (player) am i going to trigger this event for?"

    also, the source is most likely to be hidden, you will find what it refers to when you search about the parent event in the wiki (would be like "The source of this event is ...")

    • Like 1
  9. The thing is, marker hits are triggered for a lot of elements (including other markers as well), not just players, so you have to specify that.

    local respawnMarker = createMarker(2, 0, 2.22, "cylinder", 1.0, 255, 100, 100, 100)
    function toSpawnIt(player)
      if source == respawnMarker and getElementType(player) == "player" then
        spawnPlayer(player, 10, 0, 5)
      end
    end
    addEventHandler("onMarkerHit", resourceRoot, toSpawnIt)
  10. 1 hour ago, majqq said:

    Convert integer. For example:

    12000 > 12

     11000 > 11

    5000 > 5

     1000 > 1

     less or equal to 999 > 0

    well, from what i see here you don't really need the round method

    math.floor(12345/1000) = 12

    math.floor(19999/1000) = 19

    math.floor(999/1000) = 0

    also for more optimization, avoid using the OOP on render events, since it uses double the resources (from my experience) also you can make some value setters outside the render events (that changes the value after something is happened) and use the final results only on rendering

    • Like 1
  11. You don't need render events when dealing with cegui, also if you want the user to input anything, you must use an Editbox(you can set its alpha to zero), else you gonna have to learn some DX functions

  12. Radio buttons will save you a lot of code, cuz in case of checkboxes you will need to check every checkbox ( in case if the player choose more than once ), However, if you want to continue with checkboxes; you gonna use guiCheckBoxGetSelected( checkbox ) and it will return true/false.

  13. Hello there, I've been searching for the FileSystem module that is shown here: https://wiki.multitheftauto.com/wiki/Modules/FileSystem

    Unfortunately, I couldn't find anywhere, also the download links are outdated for both windows and linux, when I deeply traced the links I found the source code for the whole MTA:Eir project, but again, I don't have the right tools and the enough knowledge to extract the tool and recompile it. so if anyone has this piece of module it would be great to re-upload it.

    Thanks in advance!

×
×
  • Create New...