Jump to content

botder

MTA Team
  • Posts

    524
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by botder

  1. Create a marker and use that. Could you explain your problem further?
  2. You need true in meta.xml https://wiki.multitheftauto.com/wiki/Ma ... g_Matrices local position = vehicle.matrix.position + vehicle.matrix.forward * 3 player:setPosition(position)
  3. botder

    Tables

    That's not OOP. You only nested functions inside a table.
  4. https://github.com/Jusonex/V8ForSA Don't ask me how to use it or even how to set it up. You should try to contact Jusonex.
  5. Here: https://wiki.multitheftauto.com/wiki/CEF_Tutorial
  6. botder

    svp error

    Replace that function with this one: It will show you the script, which caused the warning. function table.size(tab) if type(tab) ~= "table" then error("table.size: argument tab is not a table", 2) end local length = 0 for _ in pairs(tab) do length = length + 1 end return length end
  7. You can multiply the blur if you render the screen source multiple times on a render target. Beware, it has a huge peformance impact. Lua Script: http://pastebin.com/10DumXhb Blur Shader: http://pastebin.com/VfAnetdB
  8. botder

    :getAllByType()

    Element.getAllByType("player")
  9. The pattern is wrong, here is the fix: function getPlayerNameWithoutTags(player) return getPlayerName(player):gsub("%[.*%]", "") end
  10. For live updates: Scheduled server restarts should happen every week (or every day) and only a stable script package should be on the "production" system. You should also control the memory/cpu usage if you keep the server running to check if there are any leaks in your script, which occur when the server runs under load (with players). About the part with the performance: I once made a local math.clamp and an exported function math_clamp (from an util resource) and tested the amount of times they were executed in a second. The local function had about 3200 calls and the exported function had something around 900 - 1000 if I recall correctly. You can say it's 3 times faster. As conclusion, you are likely to run into performance issues if you have many resources, which use exported functions. Try to make a main resource with the "critical" code and various other resources without exported functions, which purely work with events and no more, to avoid using the exported functions.
  11. There is a huge/noticeable performance difference between localized functions and exported functions. A good developer/scripter will find a balance between exported and local functions.
  12. https://www.mta-sa.org/thread/31092-umf ... ufteilung/ I made a similiar voting in a different forum (German).
  13. You could make a local variable in your class file and save the instance/object data inside it. The disadvantage is that you have to access the data through that variable in every function/method. Items = {} local ItemsMetatable = { __index = Items } local ItemsData = {} function Items.new(name) local data = {} data.name = name local object = {} -- object.__data = data -- Can be accessed in other files setmetatable(object, ItemsMetatable) ItemsData[object] = data return object end function Items:getName() return ItemsData[self].name -- OR: self.__data.name (unsafe) end
  14. For any sorting you have to compare 2 values. The parameters 'a' and 'b' are values from your table (you shouldn't care about index) and table.sort calls that function with 2 parameters.
  15. onClientPreRender Notice (not quite sure about this): This number might be inaccurate, because pre-rendered frames might be dropped, which will show higher FPS (prerendered) than the actual FPS (rendered). local framesPerSecond = 0 local framesDeltaTime = 0 addEventHandler("onClientPreRender", root, function (deltaTime) framesDeltaTime = framesDeltaTime + deltaTime framesPerSecond = framesPerSecond + 1 if framesDeltaTime >= 1000 then setElementData(localPlayer, "fps", framesPerSecond) framesDeltaTime = framesDeltaTime - 1000 framesPerSecond = 0 end end ) onClientRender local framesPerSecond = 0 local framesDeltaTime = 0 local lastRenderTick = false addEventHandler("onClientRender", root, function () local currentTick = getTickCount() lastRenderTick = lastRenderTick or currentTick framesDeltaTime = framesDeltaTime + (currentTick - lastRenderTick) lastRenderTick = currentTick framesPerSecond = framesPerSecond + 1 if framesDeltaTime >= 1000 then setElementData(localPlayer, "fps", framesPerSecond) framesDeltaTime = framesDeltaTime - 1000 framesPerSecond = 0 end end ) @ getCurrentFPS This example is even more inaccurate than onClientPreRender because it may jump randomly between 0-FPSLIMIT, depending on CPU usage.
  16. local anything = "This whole number: 123456" local number = tonumber(anything:match("%d+")) print(number) Output:
  17. Look at the wiki. https://wiki.multitheftauto.com/wiki/Se ... _functions local count = #getAccounts()
  18. You need to send the rotation from your client to server and from your server to other clients.
  19. https://wiki.multitheftauto.com/wiki/StartResource loadMaps: A boolean specifying if any .map files will be started with the resource.
  20. You should really use (/debugscript 3) to find these mistakes. In line 6 you are using "else if", but it should be "elseif"
  21. You only gave us the wrong link (which shows permission denied, see edit in URL): https://community.multitheftauto.com/ind ... s&id=11695
  22. xmlNodeGetValue(xmlFindChild(xmlFindChild(rootNode_EDITME, "username", 0), "asd", 0))
  23. table[Aname2] = nil destroyElement (table[Aname2]) You clear the variable before you use it (it will be always nil)
  24. Try this solution. It synchronizes the damage multiplier with the server and each client handles the damage themself. CLIENT local vehicleDamage = {} addEventHandler("onClientResourceStart", resourceRoot, function () local vehicles = getElementsByType("vehicle", root, true) if #vehicles > 0 then triggerServerEvent("onClientElementStreamIn", resourceRoot, vehicles) end end ) addEventHandler("onClientElementStreamIn", root, function () vehicleDamage[source] = 1.0 triggerServerEvent("onClientElementStreamIn", resourceRoot, source) end ) addEventHandler("onClientElementStreamOut", root, function () vehicleDamage[source] = nil end ) addEventHandler("onClientElementDestroy", root, function () vehicleDamage[source] = nil end ) addEvent("onClientVehicleDamageSync", true) addEventHandler("onClientVehicleDamageSync", resourceRoot, function (vehicle, multiplier) vehicleDamage[vehicle] = multiplier end ) addEventHandler("onClientVehicleDamage", root, function (_, _, loss) if vehicleDamage[source] then setElementHealth(source, getElementHealth(source) - (loss * vehicleDamage[source])) cancelEvent() end end ) SERVER DAMAGE_MULTIPLIER = 0.30 addEvent("onClientElementStreamIn", true) addEventHandler("onClientElementStreamIn", resourceRoot, function (data) if type(data) == "vehicle" then for index, vehicle in pairs(data) do if isElement(vehicle) then triggerClientEvent(client, "onClientVehicleDamageSync", resourceRoot, vehicle, DAMAGE_MULTIPLIER) end end else if isElement(data) then triggerClientEvent(client, "onClientVehicleDamageSync", resourceRoot, data, DAMAGE_MULTIPLIER) end end )
  25. If you had *.domain.ext on your whitelist then someone can make a URL with hisdomain.ext/path/xyz.domain.ext and it will work.
×
×
  • Create New...