Jump to content

arezu

Members
  • Posts

    446
  • Joined

  • Last visited

Everything posted by arezu

  1. Did you even test it? I tested it and it works. Here's my test (ran server-side): local timer = nil timer = setTimer(function() outputDebugString("update!") killTimer(timer) end, 1000, 0) Closures in lua uses reference to outside variables, and if the scope ends before closure is called, then the variable is saved until the closures have been "free'd" from memory.. I guess that is kinda how closures work in lua. As a test, I made a script like this: local timer = nil local count = 0 timer = setTimer(function() outputDebugString(tostring(count)) count = 2 end, 1000, 1) count = 1 setTimer(function() outputDebugString("second timer: "..tostring(count)) count = 3 end, 3000, 1) The output was: 1 second timer: 2
  2. I think that the higher up in element tree the element you are attaching with is, the slower it will take to trigger the event, but only if you are triggering with a child of the attached element. Like if you attach event to root, but trigger the event with a player as source element. Depending on how mta devs have implemented it, it may also take longer to trigger if you have many events that are attached to the same element than attaching to an element that doesn't have many events attached to it. But anways, resourceRoot should be more efficient than root. Though the difference in performance may be non-existent.
  3. You cant use GetLatentEventStatus from client to check status of triggerLatentClientEvent. There are two solutions I can think of at the moment: 1. Use a timer to send percent complete for the latent event from server to client, and interpolate between the values each time to make it smoother. 2. Dont use a timer and instead use triggerClientEvent right after triggerLatentClientEvent to send the size of the data that is being sent (by using getLatentEventStatus), and then save getNetworkStats().bytesReceived in the client event to a variable and compare the bytes received from download start to current amount of bytes received (getNetworkStats().bytesReceived - bytesReceivedAtStart) in onClientRender to display it or something.
  4. The first solution I think of is: local values = {"2k","4k","6k","8k","10k","12k","14k","16k", "18k","20k","40k","80k"} local sameValueCount = {} for k, v in pairs(values) do sameValueCount[v] = (sameValueCount[v] or 0) + 1 if(sameValueCount[v] == 3)then -- 3 same values in table (those 3 have the value 'v') end end
  5. arezu

    Event

    https://wiki.multitheftauto.com/wiki/OnClientVehicleDamage is triggered when vehicle is damaged by projectiles also.
  6. Didn't try the exact thing, but I'm pretty sure it won't work It works, I tried it.
  7. Their interior has been changed. Change it back to 0.
  8. use cancelEvent in onPlayerCommand event
  9. There is your answer, client never download server sided scripts. Setting script cache to false is not secure at all, and you can get the data by downloading software which you can find in a few seconds on google, so you can do it even if you have no knowledge in programming, and the data sent via http (resource download) is not encrypted. The best option currently is to use luac.multitheftauto.com to encrypt and compile your files. If you dont want to compile/encrypt all the time since it's a pain the in the ass, then you can make your own script that sends scripts to client with triggerClientEvent and then use loadstring to load the scripts. That should be more secure than setting cache to false, since data sent through triggerClientEvent is encrypted by default (unless you change that in mtaserver.conf).
  10. What are you trying to do? free memory that lua variables use? set the variable to nil (if it is a table, you will need to set all references to the table to nil), and lua will free it when it best fits. You can also use "collectgarbage" lua function to change the behavior of the garbage collector, and you can change keys in tables to be weak keys, so they may automatically be free'd and refilled when lua sees it fits.
  11. MTA example: local name = "bla" dbQuery(connection, "SELECT * FROM Table WHERE Nicknames = ?", name) or do you mean when the column "Nicknames" contains "bla" somewhere, where nicknames are seperated by a comma?
  12. You can also use https://wiki.multitheftauto.com/wiki/OnClientPlayerChangeNick if you intend to use gui* functions later.
  13. This or if possible for you, attach the event to resourceRoot instead of root and trigger using resourceRoot, then it will only trigger for the same resource.
  14. Your scripts are never safe in mta but use cache="false" in méta.xml. Its the best way to protect your scripts. No, it's very easy to get the script source if you use cache="false". Using luac.multitheftauto.com is currently the safest method, and only those that are able to write the same/better script can decrypt it, so no one is really gonna bother.
  15. https://luac.multitheftauto.com/ Use Anti-decompile and Encrypt option.
  16. If you can give an example of what exactly you are trying to do, then we can possibly give a better solution.
  17. https://community.multitheftauto.com/in ... ls&id=7349
  18. arezu

    FPS Cap

    As ixjf said, gta san andreas has issues when you run the game at a different fps than 25/30 (i dont remember which of those) because the game was originally made for ps2, and since it's a console game, the fps is the same for each console. The pc version is a shi**y port and not to mention gta san andreas is very old. An example where this becomes a big issue is when swimming. If you try to swim with 100 fps, your character will barely move.
  19. arezu

    Shader Help

    The first problem I notice is that you are not even using the shader to draw, also the render target is not needed. You only need to do this: function onClientRenderTest() if not shader then return outputChatBox("Shader error") end if not image then return outputChatBox("Image error") end dxSetShaderTransform(shader, Images[3][1][1],Images[3][1][2], Images[3][1][3], Images[3][1][4],Images[3][1][5],Images[3][1][6],Images[3][1][7],Images[3][1][8], Images[3][1][9]) dxDrawImage(x*0.3, y*0.3, x*0.6, y*0.6, shader) end
  20. tonumber: changes a string that contains a number into a number, so that it can be used mathematically. math.floor: rounds down a number to nearest integer, in other words, 5.5 becomes 5.0, 5.9 does as well and 5.1 too. _: underscore is used sometimes when there is a function that returns many values, but you dont care about the first values, and you want a value after the underscore.
  21. If you want to make the rounded rectangle scalable, then it's better if you just make an image of the corner and draw everything else with dxDrawRectangle, then the download should be less than 1kb (more in photoshop, because of useless photoshop info in the image)
  22. You should learn how to debug your scripts and check the documentation better; there are tutorials on how to debug at this forum. Also, https://wiki.multitheftauto.com/wiki/AddCommandHandler Command handlers do not have a source, only events do, and also these are the parameters: Check the example on wiki.
  23. Debug your code using outputDebugString. Put one in server side startCountDown outside the if statement and one inside, and then put another one in client side startCountDown. My guess is that 'source' that you call the function with is not an element.
  24. Yes. Alternatively use a number in each table and use table.sort, but it's easier to insert to table with ordered index instead.
  25. Make a script that checks if there is a target in front of the vehicle for some time, then set target to the player that was in front of you, otherwise shoot the projectile without a target.
×
×
  • Create New...