Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by IIYAMA

  1. You could add a return here: https://gitlab.com/IIYAMA12/draw-distance/-/blob/master/scripts/main_c.lua#L156 If the map does not match your list.
  2. I believe the error is about: $input = mta::getInput(); + use MultiTheftAuto\Sdk\Mta; mta > Mta use MultiTheftAuto\Sdk\Mta; $input = Mta::getInput();
  3. There are some methods to speed up rendering, but that is only going to work if you can modify the content. https://developer.mozilla.org/en-US/docs/Web/CSS/text-rendering https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering
  4. That is indeed the case. Syntax: bool triggerClientEvent ( [ table/element sendTo = getRootElement(), ] string name, element sourceElement [, arguments... ] ) Optional argument sendTo is not filled in, therefore it will send to all. To fix that: triggerClientEvent(source, "Emoji5:activarEfecto", root, source ) triggerClientEvent(source, "Emoji5:activarEfecto", root ) triggerClientEvent(source, "Emoji5:activarEfecto", source ) -- or for better performance
  5. This resource basically increases the draw distance for all objects. If you want to increase FPS, you have to make compromises which elements you want to skip. At this line you can add a condition or ask someone to create one for you: https://gitlab.com/IIYAMA12/draw-distance/-/blob/master/scripts/main_c.lua#L53
  6. A dead coroutine means that this: local SCAN_WORLD = coroutine.create(function() end) function has ended it's execution in some way. Either by an error or just running until the very end. I recommend to start the next async call just before the yield. This will eliminate the problems of resuming dead coroutines. So: STREET_LIGHTS.SCAN_TIMER = setTimer(resumeScan, 1000, 0) addEventHandler("onClientResourceStart", resourceRoot, function() if not isTimer(STREET_LIGHTS.SCAN_TIMER) then STREET_LIGHTS.SCAN_TIMER = setTimer(resumeScan, 1000, 1) end return true end) Run the code for X amount of time and start the resume timer there: (see a version of your current method below) local MAX_EXECUTION_INTERVAL = 3 -- ms local maxExecutionTime = 0 -- inside of the loop if getTickCount() > maxExecutionTime then STREET_LIGHTS.SCAN_TIMER = setTimer(resumeScan, 1000, 1) coroutine.yield() end You might consider balance the STREET_LIGHTS.SCAN_TIMER timer out with the max execution time. function resumeScan() maxExecutionTime = getTickCount() + MAX_EXECUTION_INTERVAL return coroutine.resume(SCAN_WORLD) end ---> math.abs(x) % 100 == 100 This will never be true 100 % 100 = 0 99 % 100 = 99 101 % 100 = 1 500 % 100 = 0 You might consider using 0 math.abs(x) % 100 == 0 if math.abs(x) % 100 == 0 then SCAN.current.x = x print"yield" STREET_LIGHTS.SCAN_TIMER = setTimer(resumeScan, 1000, 1) coroutine.yield() end
  7. A coroutine is a kind of thread type, which you can use to put a function to a temporary stop. The coroutine.create method requires a function and returns the coroutine. local co co = coroutine.create(function () end) The coroutine.yield method stops the thread, when it is called inside of the function. local co co = coroutine.create(function () coroutine.yield() end) To start a coroutine you can must call the method coroutine.resume, the first argument has to be the coroutine. local co co = coroutine.create(function () print("A") coroutine.yield() print("B") end) coroutine.resume(co) -- print A -- but does NOT print B To resume the coroutine after yield, just call coroutine.resume again. local co co = coroutine.create(function () coroutine.yield() print("B") end) coroutine.resume(co) -- start -- coroutine.yield() coroutine.resume(co) -- print B Add an async function of any kind (timer) and you are ready to go. local co co = coroutine.create(function () print("A") coroutine.yield() print("B") end) coroutine.resume(co) -- print A setTimer(function () coroutine.resume(co) -- print B end, 5000, 1)
  8. You could start with first making sure it works without database. Instead you save it inside of the memory. Unlike elementdata which is bound to an element, this will stay until the resource is stopped. local serialData = {} function setPlayerSerialData(player, value) serialData[getPlayerSerial(player)] = value return true end function getPlayerSerialData(player) return serialData[getPlayerSerial(player)] end -- SET setPlayerSerialData(player, perfectname) -- GET local perfectname = getPlayerSerialData(player) print(perfectname)
  9. Is everything clear or do you have any questions? @Dzsozi (h03)
  10. Use a database (and manager resource). There are some community resources out there that can help you with that. For example this one (which is not official released on the community resource since I am still building on it, but never the less feel free to use it. https://gitlab.com/IIYAMA12/asyncdatabase Read the readme Modify the config and set to SQLite Check the examples Others: https://community.multitheftauto.com/index.php?p=resources&s=details&id=17541 https://community.multitheftauto.com/index.php?p=resources&s=details&id=6313 Search query: https://community.multitheftauto.com/index.php?p=resources&s=list&name=data&descr=&category=
  11. There is a limit code can run for X amount of time each frame. If exceed this amount, the code will abort and you will receive this error. You can use a coroutine in order to temporary stop your code and resume in the next frame. local co co = coroutine.create(function () -- your code START ---------------------- -- inner loop START -- -- if getTickCount > ... then callNextFrame(function () coroutine.resume(co) end) coroutine.yield() -- -- inner loop END -- ---------------------- -- code END end) -- start coroutine.resume(co) Calling next frame: https://gitlab.com/IIYAMA12/mta-communication-enchantment/-/blob/master/sync/sync_shared.lua#L421 (note there are some variables that are defined above the function)
  12. Thx @Shady1 P.s. I made some last tweaks for installation script. It seems it for some unknown reason didn't always create a meta.xml file for the API credentials.
  13. Serverinfo This resource is a small API for MTA server info, which you can modify / expand to your liking. It is many used to display information about the current state if the server. Like for example how many players are playing. Read the installation carefully, because you certainly do not want to put your admin login credentials online. ? Note: before you even download this resource, test if your web interface is even available. Start your server. Open a web browser and fill in your (local) IP and standard port. If it ask for a username and password, it looks like it is OK. If not, something doesn't seems to be correct. !Servers hosts that are based on slots, might have disabled the exposure of the web interface. <ip>:<port> Endpoint: <ip>:<port>/<resourceName>/api/<endpointName>.json Local ip and standard port: Analytics Team info Chat history Generic info Player info Download: https://community.multitheftauto.com/?p=resources&s=details&id=18781
  14. Try this play ground of mine. Should be working, if not it might be a hardware or setting issue. do --[[ Capture content here ]] local renderTarget addEventHandler( "onClientResourceStart", resourceRoot, function() renderTarget = dxCreateRenderTarget( 500, 500, true ) end ) function captureContent( callBack ) if not renderTarget then return false end dxSetRenderTarget( renderTarget, true ) callBack() -- captureContent( >>> function() end <<< ) dxSetRenderTarget() return renderTarget end end do --[[ Cache renderTargets for static content ]] local cache = {} function cacheRenderTarget( key, renderTarget ) local pixels = dxGetTexturePixels( renderTarget ) if not pixels then return false end cache[key] = dxCreateTexture( pixels ) return true end function getTextureFromCache( key ) if cache[key] then iprint( 'from cache' ) end return cache[key] end end addEventHandler( "onClientRender", root, function() -- When updating content local dynamicTexture = captureContent( function() local size = getTickCount() % 501 dxDrawRectangle( 0, 0, size, size, tocolor( 0, 0, 100, 100 ) ) dxDrawText( "abcdefghi dynamic" .. getTickCount(), 10, 0, 500, 500, tocolor( 255, 255, 255 ), 1, "default", "left", "top", false, false, false, false, true ) dxDrawText( "abcdefghi dynamic" .. getTickCount(), 10, 20, 500, 500, tocolor( 255, 255, 255 ), 2, "default", "left", "top", false, false, false, false, true ) end ) if dynamicTexture then dxDrawImage( 0, 500, 500, 500, dynamicTexture ) end -- When just drawing static stuff local staticTexture = getTextureFromCache( 'static' ) if not staticTexture then staticTexture = captureContent( function() dxDrawRectangle( 0, 0, 500, 500, tocolor( 0, 0, 100, 100 ) ) dxDrawText( "abcdefghi static (not so sharp)", 10, 0, 500, 500, tocolor( 255, 255, 255 ), 1, "default", "left", "top", false, false, false, false, true ) dxDrawText( "abcdefghi static (not so sharp)", 10, 20, 500, 500, tocolor( 255, 255, 255 ), 2, "default", "left", "top", false, false, false, false, true ) end ) if staticTexture then cacheRenderTarget( 'static', staticTexture ) end end if staticTexture then dxDrawImage( 500, 500, 500, 500, staticTexture ) end end )
  15. Can you create a smaller version of your current resource, so that we can take a closer look at your problem? (small size is important because we can focus mainly on the problem) Just looking at your current code is a very inefficient method in finding a bug. Best to let the computer do the work for us.
  16. Keep in mind that the capture process starts at the left-top of the screen. posx = (sX/2)-(x1/2) dxText ( core, posx+2, posy-max*scrolling, rtW, rtH, tocolor ( 255, 255, 255, 255 ), z2*0.90,font,"left","top",true, true, false,false, true) It might not be captured. local rtW, rtH = dxGetMaterialSize(texture) You already know the size of the render target, no need to compute.
  17. string.sub(string.gsub("abcdefg69hijklmn7opqrs0tuvw71xyz72", "[^%d]", ""), 1, 4) -- 6970 With string.sub you can make a selection of characters. Arguments: The string Start index: 1 End index: 4 https://www.tutorialspoint.com/string-sub-function-in-lua
  18. You can for example replace all non numeric characters with empty strings. string.gsub("abcdefg69hijklmn7opqrs0tuvw71xyz72", "[^%d]", "") --[[ Returns 2 values: Result: 69707172 Items replaced (with empty string): 26 ]]
  19. A different technique: Guard Clauses You might want to read this, to get a better understanding of the technique. The result is more or less the same, except there are some differences with the returned values. In your function it doesn't matter, but there are functions where it does matter a lot.
  20. First of all, it important to understand there is serverside and there is clientside. Serverside is running on the server application, or just call it the server. This is where all players connect to in order to player the game together. MTA San Andreas 1.5\server\MTA Server.exe Here are server functions available. Clientside in running on each game application. It is literally the MTA game. MTA San Andreas 1.5\Multi Theft Auto.exe Keep in mind that there can multiple clientsides. For each connected player there is a clientside. The data between those clientsides is not shared. Here are client functions available. The reason why some function are not available on the other side is many because of security restrictions. You do not want to grant all players the rights to be able to ban each other, only the server should be able to ban a player. And some functions are just not so useful at the other side, like drawing an image just 1 frame on your screen. Imagine having server doing that every frame, your internet will just die.
  21. That looks fine. Next up, write the following in both situations to the serverlog. Collect them from the logs and place them here, so that we can compare the input from both situations. outputServerLog(inspect({freeID, login, vehID, positionVeh, vehcolor, cost, 1000, "TRANZIT", handlings, doors, panels, wheels, lights})) Code should be placed directly before the dbExec function call.
  22. local nameveh, cost = getVehicleDataFromTable( vehID ) Does this function accepts strings or numbers? Because addCommandHandler will provide the vehID as a string. local nameveh, cost = getVehicleDataFromTable( tonumber(vehID) ) if not nameveh then return end Please use the code tag for your code, or many forum users will not even attempt to look at your problem
  23. @Wozi I have moved your topic to tutorials, so that it is better preserved and easier to find. Good luck with your project!
  24. MTA useful functions do not exist unless they are added. See Code and expand the blue box 'Server- and/or clientside Script', there you can find the source code for that function. In that case I only recommend to post on your own language section. It saves some time for both of us. ?
  • Create New...