-
Posts
6,058 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
Yes it is indeed different and limited to an extend. I am using OOP for my code, but I am NOT using the MTA OOP classes which you might think is strange. The reason behind that is that I structure my code with OOP. The MTA OOP classes have nothing to do with with structuring the position of the code.
-
yes, Unless: There is a wrapper in between. do local setElementData_ = setElementData function setElementData (...) -- hell happens here... setElementData_(...) end end Or this event is used: https://wiki.multitheftauto.com/wiki/OnElementDataChange Which is a async.
-
You could also use the setElementDimension function on the map root element. Propagation calls down the element tree should be enabled for that element. https://wiki.multitheftauto.com/wiki/SetElementDimension https://wiki.multitheftauto.com/wiki/Element_tree
-
setElementData on the race element, wouldn't change line 6, which sets a table value under the key "title". self.title = 'Great 8-Track' Is that not your issue?
-
move line 1, in the healthshake function. The value of the variable `hp` doesn't change by itself. It has to be done every 500ms.
-
I am very sure that you do not want to make a infinity loop. It is a very bad thing after all. This is an infinity loop: while true do end Never ending execution of code, which at the end gets abort because the game starts to freeze. And this is what you probably want: setTimer(function () end, 1000, 0) Executing the function once per second.
-
function getProgress( addtick, tick ) local tick = getTickCount() local tableMessages = {texto, r, g, b, tick} getProgress(5000, v[5]) By Attaching the tick data to the message.
-
@JeViCo The syntax: bool fetchRemote ( string URL[, string queueName = "default" ][, int connectionAttempts = 10, int connectTimeout = 10000 ], function callbackFunction, [ string postData = "", bool postIsBinary = false, [ arguments... ] ] ) Problem 1 Always be called The callback function will always be called, even if there is an error. function myCallback( responseData, errno ) if errno == 0 then Problem 2 Execution order: Line: 1 local variable Line: 2 fetchRemote("http_stuff", Making a network request. Line: 6 Line: 7 print(variable) -- nil ------------------------------------------------------------------------------------------------- ---------- Waiting for the network request to be finished ---------- ------------------------------------------------------------------------------------------------- Line: 2 function(resp) Callback function will be called after a delay. The delay can be long or short, depending on the response. If not response, it will be called eventually with an error. connectTimeout: Number of milliseconds each connection attempt will take before timing out https://wiki.multitheftauto.com/wiki/FetchRemote Line: 3 variable = resp Line: 4 print(variable) -- OK Line: 5 end) Callback functions in combination with the network are always async. The code doesn't wait for these callback functions.
-
@Sorata_Kanda The value [function] is a part of a class. Functions can't leave their resource environment. So it is impossible to export them while they are loaded. But you can send them over as unloaded code: local exportedFunctionValue = "Airplane = {} function Airplane:fly () end" loadstring(exportedFunctionValue)()
-
I am also not using the MTA account system for players. As I want my database to be 100% complete + portable. If you are going to switch server, you need to move 2 databases. So I decided not do that. There were some unhappy staff players about it, as they had to login double... even so it felt like a valid decision. If you want to make use of the MTA's account system, the username is most of the time used as the primary key for both databases. Do you need the account system and ACL? The account system is useful for registering staff. The ACL is useful for setting the rights of for staff. The account system is making use of the ACL. Yes, unless you want to build up a whole `staff rights system` by yourself. Do you need it for players? No, unless you want players to use the /login and /register commands.
-
In my opinion it is far more (beginner) user friendly. If you were to use a database as basis: - Everybody has to learn how to work with table relations. - Everybody needs a database edit tool before anybody in the server can be admin. I understand that you want more, but the [end user] is...
-
@Sorata_Kanda Example on line 3 shouldn't be working. You need the unpack function for that. (Which unpacks the table) local x, y, z = unpack(fromJSON(json) ) The last example should be working. Hmmm strange. Well this is why I use iprint: iprint(fromJSON(json)) I love to know with what I am dealing with.
-
Nope, a vector isn't a table. I am not exactly sure if they build this data type in C++ or it might be a meta-table. Not that it really matters. As long as you can work with them. Untested converter do local keys = {"x", "y", "z", "w"} function vectorToTable (vector) local newTable = {} for i=1, #keys do local key = keys[i] local value = vector[key] if value then newTable[key] = value else break end end return newTable end end iprint(toJSON(vectorToTable(Vector2(234,2434))), "\n\n" , toJSON(vectorToTable(Vector3(234,2434,454))), "\n\n" , toJSON(vectorToTable(Vector4(234,2434,454, 365))) )
-
--[[ OLD addEvent("warphal", true) addEventHandler("warphal",root,spawn) ]] local spawns = { {2014.47,1523.71,10.81}, {2023.47,1437.71,10.81}, {2121.47,1481.71,10.81}, {1928.47,1482.71,10.81} } function spawn () local rnd = math.random(#spawns) -- Using client pre-defined variable setElementPosition ( client, spawns[rnd][1],spawns[rnd][2],spawns[rnd][3]) iprint("spawn function has been called") -- debug line end addEvent("warphal", true) -- moved to here addEventHandler("warphal",resoourceRoot, spawn, false) -- receive the event only for the resourceRoot element. And not it's children: false = getPropagated triggerServerEvent ("warphal", resourceRoot) -- using the resourceRoot as source element resourceRoot is the main element created by the resource. Every element created by resource is attached to it. Pre-defined variables:
-
destroyElement(SapphireTeam)
-
1. Not really. It probably has multiple damage layers. 2. You can't cancel damage serverside, as that event triggers much too late. There is connection delay (ping). By the time you reset the health, the player might have been (insta) killed already. Possible solution for an overwrite: https://wiki.multitheftauto.com/wiki/OnClientExplosion cancelEvent() https://wiki.multitheftauto.com/wiki/CreateExplosion
-
Your calculations are a bit strange For example this line: x = rWidth - dxGetTextWidth(v) / table.getn(columns) - 1 --1 dxGetTextWidth(v) / table.getn(columns) --2 rWidth - --[[result of 1]] --3 --[[result of 2]] - 1 --4 x = --[[ result of 3]] Is this really the math order you intended? ---------- For example you have a max with of 500 pixels. containerWidth = 500 And you have 8 column (names). columns = {{},{},{},{},{},{},{},{}} First step. Calculate the width of the text per column! Second step. Calculate the total width of all text items together. (So that you can scale down [and up] the columns) Which is for example 450px. containerWidth / 450 = 1.111111... (scale factor!) Or higher, 600px containerWidth / 600 = 0.833333.... (scale factor!) If you multiply these values with your columns then shouldn’t they fit perfectly? Margins around? containerWidth_ = containerWidth - margin * 2 Margins in between? containerWidth_ = containerWidth - margin * (#columns - 1) Fixed column size? containerWidth / #columns It isn't that hard, just do it step by step by step by step.
-
https://wiki.multitheftauto.com/wiki/DxDrawLine3D See example on that page.
-
That really depends how you compare and use it. 1 on 1, sure it can be 30x faster. But aren't you comparing two different things? A function vs just an empty variable. If you take a look at dxDraw functions, it is obvious that they are being called every frame. Incompare to call getElementData there isn't much of a difference. The data is bound to the element, it is not like you have to search in all elementdata for it. Example: You use 60 dx functions each frame and 1 time a getElementData function. How much will we gain from optimize this function? The real danger of elementdata is in using it, without knowing what mechanisms are activated behind it, after it is SET.
-
After you destroyed an element. A saved userdata reference will remain inside of the Lua memory. A userdata reference is not an element itself. It is a value that can be used to refer to an element in MTA. ------ It is like having a cat which you named `miauw`. After it died of old age, you can still refer to your precious cat by calling it's name. `miauw` I have dinner for you! (calling function: giveCatFoot(cat)) And then your grandma reminds you of the fact that it has already died... (warning: element does not exist) ------- That is sort of how userdata references work. See function isElement for userdata validation. isElement
-
outputChatBox("|SWAT| ["..Rank.."] #00ff00" .. getPlayerName ( source ) .. " #0000FF:#ffFFff " .. text, getRootElement(), 000, 128, 192, true ) First layer of paint RGB = RED, GREEN, BLUE Second layers of paint: #HEX Tool: http://www.javascripter.net/faq/rgbtohex.htm
-
If that is the case, then I think you picked the wrong project. Be realistic and do smaller projects first. @gujuk2 Instead of a loading bar, you can also display a loading image or loading text. Check this example: https://wiki.multitheftauto.com/wiki/IsTransferBoxActive It is used to detect if the transferbox(download bar) is active.
-
-- serverside local resources = getResources () local resourceCount = #resources setElementData(resourceRoot, "resourceCount", resourceCount) -- clientside local resourceCount = getElementData(resourceRoot, "resourceCount") iprint("resourceCount:", resourceCount)
-
[...] You can do that in the meta.xml. <download_priority_group>1<download_priority_group /> If not set, the download priority group for a resource defaults to 0. If this is set higher than 0, then the resource will be downloaded and started on the client earlier than other resources. If set to less than 0, the resource will be downloaded and started on the client later than other resources. https://wiki.multitheftauto.com/wiki/Meta.xml