Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 28/07/19 in all areas

  1. I want to share this tool and method to optimize PNG files, which are used a lot in gamemodes. This topic will focus on a tool called ZopfliPNG (which I built from source and will provide a file download for) - refer to the bottom of this topic, step 2 for that. https://github.com/google/zopfli Because of the intensive usage of PNG in MTA, optimizing them will benefit total download size for players and performance. 1) use Paint.NET software (https://www.getpaint.net/) to resize your image's resolution (CTRL + R), for example half it with the power of 2, like 256 x 256 to 128 x 128. Depending on the type of image or how far whatever script zooms it, you can go beyond that and make it even lower. Use default settings for saving it, you don't have to worry about size optimization yet. Drawing a lot of high resolution images or textures will affect client performance, and cause lag on low-end PC's. So following this step is highly recommended. You can always gauge the quality outcome while you're saving it using a lower resolution. Note: you can skip this step, if you care more about file & DL size rather than client rendering/memory performance, or if the type or usage of your image(s) result in rapid deterioration in quality upon resizing. By not doing this, and sticking to the main subject of this guide, ZopfliPNG from step 2, you will keep the same quality but only get a file size reduction. After doing the initial optimization with Paint.NET, which is the part that matters to client (rendering) performance, you'd usually think that is the end of it, that the file size Paint.NET outputs (on the various saving profiles, like bit depths, you compare) is the best you can get. But you're wrong, since advanced software like ZopfliPNG can squeeze more out of it, notably most of all without any quality decrease. It's software that assembles PNG format compression from scratch, with all pixels matching 100%. So there's no reason not to do it, also if you didn't initially use step 1) about Paint.NET resizing/actual image tweaks. So, to get a lower size, it's not neccesary to compromise more of your image quality using editing, like resize even more in Paint.NET. So now to get to the point of this guide; 2) ZopfliPNG Download it from: LINK (click) Usage instructions are in the README.txt files in either 32-bit or 64-bit version folders. It's a command-line utility, you can use it in the simplest way by entering this into cmd from the binary's location (after copying your png files): This will optimize the file using default configuration, which guarantees 100% matching pixels (absolutely no worse quality) and usually a huge reduction in file size. As I mentioned in one of the notes, you will benefit also if you won't "pre-process" your PNG's using Paint.net, but only use ZopfliPNG, to not possibly impact your quality but still get a lower resources download size. As you can see here; I made sure to document its usage (README.txt) and included mass optimization (multiple files at once) .bat files, their usage also explained in README.txt. Unfortunately this is as close we can get to mass-optimizing files, because i built zopflipng.exe from original ZopfliPNG source code (https://github.com/google/zopfli) and it doesn't currently feature it in a more convenient way (without having to edit/specify ranges of file names to optimize). Here's some additional information on ZopfliPNG and why it is so groundbreaking over other compression tools: https://ariya.io/2016/06/using-zopfli-to-optimize-png-images https://blog.codinghorror.com/zopfli-optimization-literally-free-bandwidth/ No other tool can theoretically achieve this, let alone with 100% quality preservation. It's state-of-the-art technology. Edit (25th Dec 2019): updated ZopfliPNG binaries (re-built from latest official repository version)
    5 points
  2. Pode verificar o isConsoleActive Cliente: local consoleActive = false addEventHandler("onClientRender", root, function() if (consoleActive ~= isConsoleActive()) then consoleActive = isConsoleActive() setElementData(localPlayer,"consoleActive",consoleActive) end end ) Server: addEventHandler("onPlayerCommand", root, function(cmd) if (cmd ~= "say") then return end if getElementData(source,"consoleActive") then cancelEvent() outputChatBox("*Uso inválido!", source, 255, 0, 0) end end )
    3 points
  3. Acabei de testar aqui e funcionou... mas notei que a altura que você definiu para o colshape está muito pequena (1), e com isso não estava detectando os elementos, só aumentar um pouco que provavelmente funcionará.
    1 point
  4. Tente: local vZones = { {x = 190, y = -489, z = 980, width = 65, depth = 60, height = 1}, } local z = {} function initvZones() if vZones and #vZones ~= 0 then for _,v in ipairs (vZones) do if v then if v.x and v.y and v.z and v.width and v.depth and v.height then local c = createColCuboid (v.x, v.y, v.z, v.width, v.depth, v.height) setElementDimension(c,100) if c then z[c] = true for _,veh in ipairs (getElementsByType("vehicle")) do if (getElementDimension (veh) == 100) then if isElementWithinColShape (veh, c) then destroyElement(veh) end end end addEventHandler ("onElementDestroy", c, function() if z[source] then z[source] = nil end end) addEventHandler ("onColShapeHit", c, function (h, d) if h and isElement(h) and getElementType (h) == "vehicle" and d then destroyElement(h) end end) end end end end end end addEventHandler ("onResourceStart", resourceRoot, initvZones)
    1 point
  5. Sim, getElementsByType("vehicle") vai funcionar da mesma forma, basta iterar a tabela de todos veículos retornada e o valor será o elemento-veículo assim como está no loop dos players. O evento "onResourceStart" não têm nada a ver com isso, ele só está sendo chamado internamente quando o resource é ligado e não fornece nenhum parâmetro ou "elementos" para isso.
    1 point
  6. source não é o jogador no evento onResourceStart. Preste atenção na Wiki. local vZones = { {x = 190, y = -489, z = 980, width = 65, depth = 60, height = 1}, } local z = {} function initvZones() if vZones and #vZones ~= 0 then for _,v in ipairs (vZones) do if v then if v.x and v.y and v.z and v.width and v.depth and v.height then local c = createColCuboid (v.x, v.y, v.z, v.width, v.depth, v.height) if c then z[c] = true for _,thePlayer in ipairs (getElementsByType("player")) do if (getElementDimension (thePlayer) == 100) then -- Tentativa de verdade. if isElementWithinColShape (thePlayer, c) then killPed (thePlayer) end end addEventHandler ("onElementDestroy", c, function() -- Não recomendo fazer isso dentro de loops. if z[source] then z[source] = nil end end) addEventHandler ("onColShapeHit", c, function (h, d) -- Prefira usar nomes fáceis de identificar em vez de letras. if h and isElement(h) and getElementType (h) == "player" then killPed (h) end end) end end end end end end end addEventHandler ("onResourceStart", resourceRoot, initvZones)
    1 point
  7. local damagePlayers = {} function onDamage( ) if damagePlayers[source] and isTimer(damagePlayers[source]) then killTimer(damagePlayers[source]) end damagePlayers[source] = setTimer( function(p) if isElement(p) then damagePlayers[p] = nil end end, 10000, 1, source ) end addEventHandler( "onPlayerDamage", root, onDamage ) Nesse código eu fiz um timer quando o jogador leva hit e reseta depois de 10 segundos. No comando do teleporte você só irá fazer uma verificação na tabela damagePlayers: if damagePlayers[thePlayer] then return outputChatBox("Você não pode usar esse comando agora!", thePlayer) end Coloque isso no inicio do comando do teleporte.
    1 point
  8. Texto corrigido para se adequar as regras de formatação do fórum. Movido para a seção correta de Programação em Lua. Da próxima vez, utilize o botão <> do fórum para postar códigos em vez de colar direto no texto. Veja as regras do fórum aqui:
    1 point
  9. Qual arma que vc deveria andar ao mirar mas não está? Tenha certeza de que o resource defaultstats esteja ativado.
    1 point
  10. https://forum.multitheftauto.com/forum/184-persian-فارسی/ Your wish is granted.
    1 point
×
×
  • Create New...