-
Posts
6,089 -
Joined
-
Last visited
-
Days Won
216
Everything posted by IIYAMA
-
Afaik from 0 to 1000. Because according to wiki 1000 enable dual weapons. https://wiki.multitheftauto.com/wiki/Weapon_skill_levels If you really want to know it for sure, then the obvious solution for a programmer is to debug it, isn't it? setPedStat(localPlayer, 21, 1000) iprint("super cow value:", getPedStat(localPlayer, 21))
- 1 reply
-
- 1
-
-
local selectedResourceName = "" -- < fill in -- This function will be restarting a selected resource. local function restartSelectedResource (selectedResource) local resourceState = getResourceState(selectedResource) if resourceState == "running" then restartResource(selectedResource) elseif resourceState == "loaded" then startResource(selectedResource) end end addEventHandler("onResourceStart", resourceRoot, function () local selectedResource = getResourceFromName(selectedResourceName) if selectedResource then setTimer(restartSelectedResource, 600000, 0, selectedResource) else outputChatBox("Can't find the selected resource.") cancelEvent(true, "Can't find the selected resource.") end end) https://wiki.multitheftauto.com/wiki/SetTimer https://wiki.multitheftauto.com/wiki/OnResourceStart https://wiki.multitheftauto.com/wiki/GetResourceFromName https://wiki.multitheftauto.com/wiki/StartResource https://wiki.multitheftauto.com/wiki/RestartResource https://wiki.multitheftauto.com/wiki/GetResourceState https://wiki.multitheftauto.com/wiki/CancelEvent Make sure the resource has access to these functions <right name="function.startResource" access="true" /> <right name="function.restartResource" access="true" /> startResource restartResource Those functions are blocked by default because they are used for administration purposes. Step 1 The rights can be requested by the resource if you add these lines in to your meta.xml: <aclrequest> <right name="function.startResource" access="true" /> <right name="function.restartResource" access="true" /> </aclrequest> Step 2 Commands left to do: (fill in the <resourceName> of the resource that contains this script) /refreshall /aclrequest allow <resourceName> all
-
Use the ipb on yourself instead of your server. The server can indeed have influence on the client his FPS, but clientside has far more direct influence on the FPS.
-
local model = getElementModel(element) https://wiki.multitheftauto.com/wiki/GetElementModel setPlayerSkin is deprecated. It might be removed in next MTA versions. Use setElementModel instead. https://wiki.multitheftauto.com/wiki/SetElementModel
-
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.