Jump to content

IIYAMA

Moderators
  • Posts

    6,088
  • Joined

  • Last visited

  • Days Won

    215

Everything posted by IIYAMA

  1. IIYAMA

    Why?

    @Hugo_Almeidowski hmm, just to be sure debug the sound element. local soundREEE = playSound3D("reeet.mp3", pX, pY, pZ, true) outputChatBox(inspect(soundREEE))
  2. IIYAMA

    Why?

    @Hugo_Almeidowski Did you check the debug console? I didn't change anything before the audio started to play, so either it was already broken or there is an error/warning.
  3. yea that can work. I recommend to open the design in Photoshop/something-similar and get all the positions from there. (you might need to do a little bit of maths afterwards to adjust it to the (possible) responsive layout in game)
  4. It doesn't tell you which field you selected. dxGetTexturePixels is a very slow process.(unless it is only done once at the start) But feel free to try it your way. I am interested in what you discover on the way.
  5. IIYAMA

    Why?

    ID elements have to be unique. There shouldn't be two elements with the same ID. local pedContainer = createElement("pedContainer") function TocarSomPed(ped) local pX, pY, pZ = getElementPosition(ped) local dimensaoP = getElementDimension(ped) local IDPed = getElementID(ped) outputChatBox("O nome deste ped é " ..IDPed) local soundREEE = playSound3D("reeet.mp3", pX, pY, pZ, true) setElementDimension(soundREEE, dimensaoP) attachElements(soundREEE, ped) setElementParent(soundREEE, ped) -- the SOUND is now a child of the PED. setElementParent(ped, pedContainer) -- PED is now a child of pedContainer, which has an addEventHandler attached to it. See line 1 and line 31. end addEvent("onPedCriado", true) addEventHandler("onPedCriado", root, TocarSomPed) -- function pedMorreuClient() local setarIDSom = source -- source is the ped. See page: https://wiki.multitheftauto.com/wiki/OnClientPedWasted local soundREEE = getElementChild ( setarIDSom, 0 ) -- get the first child of this PED, which is the SOUND. See line 12. if soundREEE then destroyElement(soundREEE) end end addEventHandler("onClientPedWasted", pedContainer, pedMorreuClient) https://wiki.multitheftauto.com/wiki/GetElementChild https://wiki.multitheftauto.com/wiki/SetElementParent This is information about how children and parents work in MTA: https://wiki.multitheftauto.com/wiki/Element_tree#Example
  6. @mehmet You can use something like this: https://wiki.multitheftauto.com/wiki/Math.isPointInPolygon Or calculate the angle + distance from the centre. (this one will give the best result without relying on the browser) https://wiki.multitheftauto.com/wiki/FindRotation https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPoints2D Or use the browser + svg.(HTML + SVG knowledge required) <svg id="Laag_1" data-name="Laag 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{opacity:0.53;}</style></defs><title>Tekengebied 2</title><path class="cls-1" d="M104.52,305.93a155.81,155.81,0,0,1,.31-114.35L18.44,155.8A249.16,249.16,0,0,0,17.55,342Z"/><path class="cls-1" d="M187.74,392.47a155.86,155.86,0,0,1-80.93-81l-87,36A249.16,249.16,0,0,0,151.57,479.79Z"/><path class="cls-1" d="M107.13,186.05a155.82,155.82,0,0,1,80.92-80.38L152.49,19.82A249.13,249.13,0,0,0,20.77,150.27Z"/><path class="cls-1" d="M158,17.55l35.56,85.84a155.77,155.77,0,0,1,113.78.24l35.51-85.71A249.12,249.12,0,0,0,158,17.55Z"/><path class="cls-1" d="M312.92,105.93a155.78,155.78,0,0,1,80.43,80.36l86-35.64a249.15,249.15,0,0,0-131-130.44Z"/><path class="cls-1" d="M395.65,191.83A155.82,155.82,0,0,1,396,305.68l86.65,35.89a249.08,249.08,0,0,0-.9-185.38Z"/><path class="cls-1" d="M307.69,394.51a155.75,155.75,0,0,1-114.4.25l-36.18,87.32a249.11,249.11,0,0,0,186.7-.37Z"/><path class="cls-1" d="M393.67,311.23a155.82,155.82,0,0,1-80.44,81l36.12,87.18a249.18,249.18,0,0,0,131-132.26Z"/><path d="M28.16,153.33A240.89,240.89,0,0,1,155.55,27.21l-3.06-7.39A249.13,249.13,0,0,0,20.77,150.27Z"/><path d="M158,17.55l3.06,7.39a240.85,240.85,0,0,1,178.72.37l3.07-7.39A249.12,249.12,0,0,0,158,17.55Z"/><path d="M154.63,472.4A240.9,240.9,0,0,1,27.21,344.45l-7.39,3.06A249.16,249.16,0,0,0,151.57,479.79Z"/><path d="M24.94,338.9a240.95,240.95,0,0,1,.89-180l-7.39-3.06A249.16,249.16,0,0,0,17.55,342Z"/><path d="M474.32,159.25a240.93,240.93,0,0,1,.9,179.26l7.39,3.06a249.08,249.08,0,0,0-.9-185.38Z"/><path d="M345.37,27.6A240.87,240.87,0,0,1,472,153.71l7.39-3.06a249.15,249.15,0,0,0-131-130.44Z"/><path d="M340.75,474.32a240.88,240.88,0,0,1-180.57.37l-3.07,7.39a249.11,249.11,0,0,0,186.7-.37Z"/><path d="M473,344.07A240.87,240.87,0,0,1,346.29,472l3.06,7.39a249.18,249.18,0,0,0,131-132.26Z"/></svg>
  7. Notes: The car explosion might not look the same, even though it is the same type. (to be honest it looks nicer) You might want to only apply it to the types you want to replace. Damage is disabled for all elements, which includes peds, objects and vehicles. You might need to write the same damage method for those.
  8. explosions can't be detected with onClientPlayerWeaponFire My first first step gives you everything you need know for the second step. addEventHandler("onClientExplosion", root, function (x,y,z,theType) createExplosion (x, y, z, theType, true, -1.0, false ) local creator = source -- the one that created the explosion, this doesn't have to be a player. local playerX, playerY, playerZ = getElementPosition(localPlayer) local distance = getDistanceBetweenPoints3D(x, y, z, playerX, playerY, playerZ) end)
  9. @majqq The first step would be cancelling this event: https://wiki.multitheftauto.com/wiki/OnClientExplosion x: the X Coordinate of where the explosion was created y: the Y Coordinate of where the explosion was created z: the z Coordinate of where the explosion was created theType: the type of explosion created, Values are: 0: Grenade 1: Molotov 2: Rocket 3: Rocket Weak 4: Car 5: Car Quick 6: Boat 7: Heli 8: Mine 9: Object 10: Tank Grenade 11: Small 12: Tiny The second step, recreating the explosion and disable the damage: https://wiki.multitheftauto.com/wiki/CreateExplosion Optional Arguments makeSound: a boolean specifying whether the explosion should be heard or not. camShake: a float specifying the camera shake's intensity. damaging: a boolean specifying whether the explosion should cause damage or not. And the last step is indeed:https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPoints3D For your first iteration you can work with rings. So if distance is closer than: damage = 0 if distance is closer than 30 units damage = damage + 10 if distance is closer than 15 units damage = damage + 30 if distance is closer than 5 units damage = damage + 50 iprint(damage) Later you can do some more advanced math stuff which gives you something similar to GTA.
  10. triggerClientEvent ("onPedCriado", thePlayer, ped) function TocarSomPed (ped) Serverside elements are available on clientside. But clientside created elements are not available serverside.
  11. You can use a GUI element: https://wiki.multitheftauto.com/wiki/Client_Scripting_Functions#Static_Images But the quality will not be the same. Check also rendering with textures, you can boost the performance considerably: https://wiki.multitheftauto.com/wiki/DxCreateTexture
  12. First make it, then optimise it. ipairs, pairs (and next) loops are function based loops. They process tables with their own rules. ipairs loops through numbers starting from 1. It will stop looping when there is no value at the next index. {1, 2, nil, 4} With this table it will loop only 2 items. It has as benefit to loop through error sensitive tables, which can skip the damaged data. (Not that I ever had to deal with a damaged table in my life...) pairs loops through all indexes. It doesn't matter if it is a number, string, userdata, table or even a function. The only thing it can't do is looping it in order. But do you really think that there are no other, not function based loops? Here is a list of loops that do not make use of lua functions: https://www.tutorialspoint.com/lua/lua_loops.htm
  13. Functions are slower. But you are at a point where you shouldn't worrying about optimizing to the bone. But if you really want to know about speed: Functions are one of the slowest type of operations in Lua. A loop can be faster than an if statement. But not with the ipairs loop. ipairs() = function Why use these `slow` functions? Your brain is also a kind of computer and it's performance can also be decreased. This happens very quickly when you do not use enough functions. Functions are used to name/identify the operations in your code.
  14. Sometimes by just adding a random debug line in your code, it can reveal not updated code.
  15. iprint(source) Did you debug it?
  16. As it is now, the code triggers immediately while loading the resource and source is not defined.
  17. Hmm, is your timing correct? (When is the second event being called) Is the eventName correct? Your test events are not correctly camelcase named, which might be correct named on serverside. ontest > onTest And how do you trigger?
  18. Those warnings are all happening on different lines. I only see two lines that destroy elements, which means that you are showing only half of the places where the warning occur. The thing that is going wrong is that the code is trying to destroy elements that are destroyed. Can I see the other warning lines as well? (Don't show everything, just show the important code as you did before)
  19. IIYAMA

    dxDrawCircle

    To cut out stuff: nightly.multitheftauto.com/files/shaders/shader_hud_mask.zip But as @DNL291 said, an image might be easier. (also for the effect)
  20. IIYAMA

    dxDrawCircle

    You might be able to do that with a mask shader: https://wiki.multitheftauto.com/wiki/Shader_examples#Hud_mask
  21. If you are worrying about the internet usage. Get yourself a second server. Which can be a cloud server. This will reduce the impact on your main server. As for the clients. The most laggy part is loading the mods. You can queue processes like this: (untested) local nextModLoading = 0 local function processMods (modsInQueue) local timeNow = getTickCount() if timeNow > nextModLoading then local newMod = modsInQueue[1] -- load mods table.remove(modsInQueue, 1) nextModLoading = timeNow + 300 end if #modsInQueue == 0 then removeRenderEvent(processMods) end end do local modsInQueue = {} function addModToLoader (newMod) modsInQueue[#modsInQueue + 1] = newMod addRenderEvent(processMods, nil, modsInQueue) end end
  22. if weaponIndexByID[item_id] == 30 and weaponModels[item_id] -- Check if there is something at that index. (error prevention) and weaponModels[item_id][1] == 1254 -- then index twice to get access to the sub-table then outputChatBox("ko") end -- sub-table: {1254, x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0, scale = 1}
  23. What do you mean with that? Are you saying that your scripts are also located in that direction?
  24. I feel deeply honoured when you say that. ? But even so, I am somebody with limits as well. I get the feeling that you are the same on your language section. ?
  25. Yea that should be fine as far as I can see.
×
×
  • Create New...