-
Posts
6,058 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
I don't think that is enough for just a Youtube video. Open your default browser. Go to the youtube video you want to watch. Open the inspector. Go to the network tab. Reload the page. And see the list of requests + domains showing up one by one.
-
I am very sure that CORS will block it, if it is from another domain. https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS But a way around that would be making a XMLHttpRequest https://developer.mozilla.org/nl/docs/Web/API/XMLHttpRequest And put the website inside of the contentWindow. https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/contentWindow Of course, there are some seriously limitations to this, as images, css, js are received with other requests. So to answer your question: `It depends.` If the CSS, JS, images and other content are embedded then there will be no problem.
-
Did you optimise it for web? A tool I use a lot: fontsquirrel.com
-
The easiest way would be invert it's velocity. But in some cases it might not be very accurate. (In case of a player you have to lift him up a little bit) getElementVelocity setElementVelocity ----- Another way would be resetting the player back to it's previous position. (This might require some more performance impact as you will have to record it's previous position at all times.) ----- Another way would be: calculate from the position of the vehicle/player and the position colshape the difference. - Based on each separated axis: x1 - x2, y1 - y2, z1 - z2 (vector) - Based on all axis. (Distance) [might not be required] In case of a sphere colshape the distance from the center is always the same. So you do know how much distance is required to move somebody out of the sphere. If you normalize the vector and multiply it by the required distance, what kind of result do you think that will have? (Just becareful not place the player in the ground....) --- The last way. Just teleport him to a known location out of the area.
-
Clientside local thisTable = {} addEvent("update-------") addEventHandler("update-------", resourceRoot, function (index, data) thisTable[index] = data end, false) Serverside local thisTable = {} function updateTable (target, index, data) thisTable[index] = data triggerLatentClientEvent(target, "update-------", resourceRoot, index, data) end updateTable(target, "index", {"data"}) -- all players updateTable(getElementsByType("player"), "index", {"data"}) -- all players updateTable(getRandomPlayer(), "index", {"data"}) -- just a single player updateTable({getRandomPlayer()}, "index", {"data"}) -- just a single player Keep in mind that when testing this code, it is important to mind "when/timing?" + "triggerClientEvent/communication". As in this example the client hasn't loaded it's scripts yet. Adjust it to your needs. @majqq
-
Yes, I can't explain it better than this: Client (see my example) Trigger: When vehicle damage Condition: You must be the syncer of the vehicle. Actions: - Save updates for the table. (Not a new version of the main table) - Start the buffer timer. 200ms?(if not running already) In case of firedamage or a minigun you will be preventing a trigger event that is send every frame. --------------- Trigger: When the buffer timer is finished. Action: Send the table updates to the server. _______________ _______________ _______________ Server Trigger: When there is an update from the client. Condition: If a player is closer to the vehicle than 300+ units, do action 1 for him. Else do action 2 for him. Action 1: Send a (latent) trigger event to the selected person. Action 2: Save this message in a table. Start a personal buffer timer for him. This table could contain similar types of updates from different vehicles. The data should contain is a reference to the player and to the vehicle. Which you can use to pick the right and latest update for the player. (Also here start the buffer timer only when it is not running for the selected person) -------------- Trigger: When the personal buffer timer is finished.(action 2) Action: Send the table new table to the client.
-
It will hurt the sender a bit. But only if he or she has terrible internet. And you can always increase the buffer/delay time. (Remember to test the latent version for your target group) When you are going to send information back it will also hurt the receiver without doubts. But you can use an even bigger delay for players that are far away. So only the players that are closeby should actually receive data immediately. On the other hand elementdata could save you some data for closeby players. The usage require less data, but the target players are not control able. So if there are 500 players in your server, then I do not recommended it. You should test both ways. It is a paradox I know... Why not set elementdata clientside? Because players will overwrite the data from each other. It is something the server should manage. Who is your target group by the way? @majqq
-
- With parameters I mean the arguments you want to use there. - There are no shared tables. I recommend to first try to use the clean way. Sync with triggerEvents, so that you do not destroy other players their network usage directly. (of course this can still happen) Buffer up to at least 200ms. Check if latent events are fast enough for your target group. If your players have bad internet, then it might be possible that the information never gets send... Latent events will only send information when the network isn't blocked. This means that position and orientation of players should be more accurate while sending information. Element data usage will increase when the player count increases, so test it before you use that type instead. Untested code local damageToSync = {} local syncVehicleDamageTimer local function syncVehicleDamage () syncVehicleDamageTimer = nil -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- triggerServerEvent("syncVehicleDamage", resourceRoot, damageToSync) -- -- or -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- triggerLatentServerEvent("syncVehicleDamage", resourceRoot, damageToSync) -- It will improve the gameplay. >>> BUT this will work ONLY fine if your target players have fast internet. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- damageToSync = {} -- reset table end addEventHandler("onClientVehicleDamage", root, function (attacker, weapon, loss) if isElementSyncer(source) and attacker and getElementType(attacker) == "player" and loss > 0 then -- register vehicle local vehicleDamageTable = damageToSync[source] if not vehicleDamageTable then vehicleDamageTable = {} damageToSync[source] = vehicleDamageTable end -- register attacker + loss of vehicle vehicleDamageTable[attacker] = (vehicleDamageTable[attacker] or 0) + loss -- start sync delay if not syncVehicleDamageTimer then syncVehicleDamageTimer = setTimer(syncVehicleDamage, 200, 1) end end end) The table structure. --[[ -- table structure -- local damageToSync = { [vehicle] = { [attacker] = loss, [attacker] = loss } [vehicle] = { [attacker] = loss, [attacker] = loss } } ]]
-
Oke, Is there more to it? Because this is not enough to pick the right method. For example: Response time? Delay in between? Network bandwidth limit? Parameters? Is it used for visuals only or has it also influence on gameplay directly? Which players do need to receive this information immediately? Which ones later? (Which ones not? > Players that join later or that are far away.)
-
@majqq The answer to that depends for 95% on what your endpoint needs. Enough context is essential for coding with responsibility.
-
6000x6000 https://wiki.multitheftauto.com/wiki/GetPlayerMapBoundingBox
-
You can easily update it every 3 seconds, nobody that notice much of a difference. Except for the ice bears. ?
-
Nice! ? Btw your update speed is a bit too fast.
-
addEvent("startArmour", true) addEventHandler("startArmour", getRootElement(), function () addEventHandler("onClientRender", root, renderArmour) end) function renderArmour () dxDrawText("equipting armour", 342, 259, 907, 322, tocolor(28, 135, 226, 255), 1.50, "bankgothic", "left", "top", false, false, false, false, false) end You need two separated functions for that. See also this source-code/tutorial if you want to pass arguments:
- 1 reply
-
- 1
-
You probably will need modules for the communication between your bot to discord. There must be a lot of security stuff in it, so you do not want without that. https://discord.js.org/#/ From your bot to MTA, a socket is not required. Nodejs has a build in module https, which you can use. https://www.twilio.com/blog/2017/08/http-requests-in-node-js.html And on the MTA side: There you can create your HTML file which you can use to receive requests. https://wiki.multitheftauto.com/wiki/Resource_Web_Access table form: This is a table containing all the form data submitted to the page using HTTP POST combined with any variables passed in the querystring with HTTP GET. The variable form should be available in your HTML file which can contain the message data from a post request. It can be complicated stuff if you haven't worked without sockets before. But that doesn't mean that you should give up.
-
Cheers! ?
-
If the issue is 100% related to what @Mr.Loki said. Then the texture will simply fail to load. Which shouldn't cause any laggy errors. Thought it might be a good idea to blacklist failed loaded textures as well or use a delay before retrying to load the texture. The main question is now "will textures use more or less vram incompare to file paths?" I can honestly can't awnser that. Technically textures would need more ram, as it is always in use. But drawing from path requires most likely a lot more cleaning, as I am not sure if it buffers those kinds of textures. If you really want to know that, then you only have to watch the free vram.
-
If do not know why your error occur, it looks like you are drawing before the resource has been fully loaded. But you could try this: (untested, experimental code and overkill) do -- no errors when drawing without a given texture local dxDrawImage_ = dxDrawImage function dxDrawImage (...) if ({...})[5] then dxDrawImage_(...) end end end do local blackList = {} local nextTimeConvertToTexture = 0 function getImage(name) if not descricoes[name] then return nil end local texture = descricoes[name].texture if not texture then local timeNow = getTickCount() if timeNow > nextTimeConvertToTexture and not blackList[filePath] then local filePath = 'imagens/'..descricoes[name].img if fileExists(filePath) then texture = dxCreateTexture(filePath) descricoes[name].texture = texture nextTimeConvertToTexture = timeNow + (1000 / 60) -- convert at a MAX speed of 60 fps else blackList[filePath] = true end end end return texture end end It will also optimise your code in a later state of the game. (speed up drawing)
-
That should be fine, as long as the sound stays the child and not the parent.
-
@Emix You have read wiki you know?
-
Your mathematics has to be at a more advanced level. Have you ever considered to use stuff that already exist? https://community.multitheftauto.com/index.php?p=resources&s=list&name=lib&descr=dx&category= To answer your question: "How?" You could do it with: https://wiki.multitheftauto.com/wiki/DxCreateRenderTarget make a render target https://wiki.multitheftauto.com/wiki/DxSetRenderTarget start capture target Draw your stuff on the left-top conner of your screen. ? https://wiki.multitheftauto.com/wiki/DxSetRenderTarget end capture target https://wiki.multitheftauto.com/wiki/DxDrawImageSection or https://wiki.multitheftauto.com/wiki/DxDrawImage Draw the render target
-
@majqq@Pirulax I am terrible sorry. It seems like my information is partly incorrect. I tested it: It seems that it only will destroy children when you manually destroy an element. (It will only destroy it's children with destroyElement + propagation is enabled) And changing the parent to player doesn't work. Information that is still correct: Sound elements do destroy them self after ending.
-
That is about this: 1. Resource 1 <resourceRoot></resourceRoot> Resource 2 <resourceRoot></resourceRoot> ------------------------------ 2. Resource 1 example = createElement("example", "example") <resourceRoot> <example id="example"></example> </resourceRoot> Resource 2 <resourceRoot></resourceRoot> ------------------------------ 3. Resource 1 <resourceRoot> <example id="example"></example> </resourceRoot> example = getElementByID("example") setElementParent(example, resourceRoot) New structure: <resourceRoot></resourceRoot> Resource 2 <resourceRoot> <example id="example"></example> </resourceRoot> ------------------------------ It looks now as if the element <example> has been transferred to another resource. But it didn't. It is still part of resource 1. If you stop resource 1, then the <example> element will still be destroyed. < that comment it about his. And the funny thing is, that <example> will ALSO be destroyed when you stop resource 2 That poor example does not stand a chance! And this comment for some reason doesn't make sense, because I have never seen this happen.