-
Posts
6,097 -
Joined
-
Last visited
-
Days Won
218
Everything posted by IIYAMA
-
Hmm, is your timing correct? (When is the second event being called) Is the eventName correct? Your test events are not correctly camelcase named, which might be correct named on serverside. ontest > onTest And how do you trigger?
-
Those warnings are all happening on different lines. I only see two lines that destroy elements, which means that you are showing only half of the places where the warning occur. The thing that is going wrong is that the code is trying to destroy elements that are destroyed. Can I see the other warning lines as well? (Don't show everything, just show the important code as you did before)
-
To cut out stuff: nightly.multitheftauto.com/files/shaders/shader_hud_mask.zip But as @DNL291 said, an image might be easier. (also for the effect)
-
You might be able to do that with a mask shader: https://wiki.multitheftauto.com/wiki/Shader_examples#Hud_mask
-
If you are worrying about the internet usage. Get yourself a second server. Which can be a cloud server. This will reduce the impact on your main server. As for the clients. The most laggy part is loading the mods. You can queue processes like this: (untested) local nextModLoading = 0 local function processMods (modsInQueue) local timeNow = getTickCount() if timeNow > nextModLoading then local newMod = modsInQueue[1] -- load mods table.remove(modsInQueue, 1) nextModLoading = timeNow + 300 end if #modsInQueue == 0 then removeRenderEvent(processMods) end end do local modsInQueue = {} function addModToLoader (newMod) modsInQueue[#modsInQueue + 1] = newMod addRenderEvent(processMods, nil, modsInQueue) end end
-
if weaponIndexByID[item_id] == 30 and weaponModels[item_id] -- Check if there is something at that index. (error prevention) and weaponModels[item_id][1] == 1254 -- then index twice to get access to the sub-table then outputChatBox("ko") end -- sub-table: {1254, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}
-
What do you mean with that? Are you saying that your scripts are also located in that direction?
-
I feel deeply honoured when you say that. ? But even so, I am somebody with limits as well. I get the feeling that you are the same on your language section. ?
-
Yea that should be fine as far as I can see.
-
You for 99% correct. But there is nothing `extra` to be stored, we only moved things around. If you do not set it's parent to soundContainer, it will not count. If we do nothing: (everything is parallel) <sound></sound> <sound></sound> <sound></sound> <sound></sound> <soundContainer> <!-- no children so we count 0 --> </soundContainer> If we use setElementParent: <soundContainer> <!-- 4 children, so we count 4 --> <sound></sound> <sound></sound> <sound></sound> <sound></sound> </soundContainer>
-
@majqq hmm, maybe another way of making it would be easier for you to build it and it doesn't require any tables. It simply uses the element tree: https://wiki.multitheftauto.com/wiki/Element_tree -- on top local soundContainer = createElement("soundContainer") -- in your function if getElementChildrenCount (soundContainer) < 5 then local sound = [[ ... ]] setElementParent(sound, soundContainer) end If we would visualise this: <soundContainer> <sound></sound> <sound></sound> <sound></sound> <sound></sound> </soundContainer> And the cool thing about it, is that there is nothing you have to clean from a table.
-
1. wav is an uncompressed format ogg is a compressed format. Before a compressed format can be played, your computer has to uncompress it first. A This cost time and memory. There are two very well known ways of compressing. The first one is removing information, which results in quality loss. ? A The second one is restructuring the data and removing spaces in between. But by doing this the format can't be read directly by the media player. It has to be restored to it's original state before it can be played. ? When playing audio repeatedly (for example while firing your weapon), your computer will be uncompressing a ogg file repeatedly, which can cause a bit of lag if your computer can't handle it. 2. You only have to destroy it, when your audio element doesn't stop by itself. For example when looped or streamed. element playSound3D ( string soundPath, float x, float y, float z, [ bool looped = false ] ) 3. local nextShootingTime = 0 -- on top of the script. --- in your function --- local timeNow = getTickCount() if timeNow > nextShootingTime then nextShootingTime = timeNow + 20 -- play audio end 4. You need to learn tables for that...
-
See this topic: That guy has the same issue. You get this error because you send a trigger event, but the clients/players haven't loaded their scripts. This can be either an timing issue or there is another error which causes the script to fail loading. The event onClientResourceStart is a great way to detect when a player can receive triggerClientEvents
-
That depends how good you are with Javascript. I would probably pick CEF for the job, just because you are working item based. But if you are better in lua than JavaScript, dx might be your solution. Also CEF supports SVG, which makes your icons look much more sharper. () And YES!! animated crazy stuff
-
That really depends on your user-case. When requesting the browser, you will be starting a web browser application inside of your game. This cost more performance than just rendering a rectangle with dx. But rendering 1000 elements, yes the browser will be more optimised to render multiple elements better/faster. The browser can actually do have influence on the FPS, if the website is not optimised or when there are too many browser windows created. The question you actually want to ask is: "Which is better for me?" And you are the only one able to answer that question. So a few of my recommendations: Use dx: When displaying just a few elements at a location When you do not want to spend a lot of time on a project. Setting up and maintaining a browser requires more code. For optimised textures. Use the browser: When rendering tons of elements. When using a lot of (CSS) animating. When you understand CSS and HTML (required). When handling UI/UX browser events based (Javascript required). Other things: Do not create too many browsers windows. Stop the browser from rendering, when not used: https://wiki.multitheftauto.com/wiki/SetBrowserRenderingPaused A browser renders content like this:
-
Because the players/clients haven't loaded their scripts yet. The server is always one step a head in time.
-
That is not possible.
-
Yes. To be honest, I still do not understand your question completely, so I am trying to gamble a bit.
-
You can do that with local functions. Those functions can only be used within the file local name = function () end local function name () -- this one is able call itself,in compare to the previous one: name() end local name -- variable scope starts here function name () end Another solution would a table with methods.
-
-- -- -- -- -- -- This block cannot be frozen! -- -- -- -- -- co[id] = coroutine.create(function() -- This block can be frozen!!!!!!!!!!!!!!!!!!!!!! local id = querydb("SELECT * FROM `kayitlar` WHERE `KullaniciAdi`='mahlukat'") print("querydb: "..tostring(id)) local result = getQueryResult(id) print("queryresult: "..tostring(result)) end) -- -- -- -- -- function querydb () -- This block can be frozen!!!!!!!!!!!!!!!!!!!!!! coroutine.yield() end function getQueryResult () -- This block can be frozen!!!!!!!!!!!!!!!!!!!!!! coroutine.yield() end That way.
-
@XiVirtue Every step of the query process have to be done inside of the coroutine function. And you cannot use two coroutines for one execution process. Tip: Functions blocks that are outside of the coroutine, but called from within the coroutine function block, are considered to be part of the coroutine. It sound complicated, but it means that you can yield a coroutine from a different function, as long as it is part of the coroutine process.
-
@Sorata_Kanda The event 'onPlayerJoin' triggers faster than a client has loaded his client resources. onClientResourceStart > triggerServerEvent > races > triggerClientEvent This also works for clients that are already in the server.
-
Keep in mind that a table should not be a part of a race element. Because tables become a new object when they are saved inside of elementData. But a race element can be a part of a table. There is a function called isElement after all. Another way to reference from a raceElement to a table is by using another table. They should be both in the same environment. reference = {} table = {} element = [[...]] reference[element] = table The event system is indeed async.
-
Yes, elementData should be considered as something similar to attributes. <race title="example" /> It defines the specifications of elements. Before you continue, rendering based on elements is not the method with the most performance. So keep that in mind. But! The benefits: There is less (validation- and maintenance)code required. If an element is deleted, then you do not have to clean it from a table. 100% control serverside. Client elements can be set as children of server elements. So these can be auto cleaned as well. The tables from the queries are formatted as arrays, so looping through them doesn't require much time.
-
See the first example of this page: https://wiki.multitheftauto.com/wiki/GetElementMatrix Maybe this: https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPointAndSegment2D (might need a 3D version of it) And this: function findClosestPointOf2Lines3D (line1X,line1Y,line1Z,line1VectorX,line1VectorY,line1VectorZ,line2X,line2Y,line2Z,line2VectorX,line2VectorY,line2VectorZ) local Vec1 = Vector3 (line1VectorX,line1VectorY,line1VectorZ) local Vec2 = Vector3 (line2VectorX,line2VectorY,line2VectorZ) local line1 = Vector3 (line1X,line1Y,line1Z) local line2 = Vector3 (line2X,line2Y,line2Z) local a = Vec1:dot(Vec1) local b = Vec1:dot(Vec2) local e = Vec2:dot(Vec2) local d = a*e - b*b if tostring(d) ~= "0.0f" then local r = line1 - line2 local c = Vec1:dot(r) local f = Vec2:dot(r) local s = (b*f - c*e) / d local t = (a*f - c*b) / d local closestPointLine1 = line1 + Vec1 * s local x,y,z = vectorUnpack(closestPointLine1) return x,y,z end return false,false,false end function vectorUnpack(v) return v.x, v.y, v.z end
