-
Posts
6,058 -
Joined
-
Last visited
-
Days Won
208
Everything posted by IIYAMA
-
@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>
-
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.
-
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)
-
@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.
-
triggerClientEvent ("onPedCriado", thePlayer, ped) function TocarSomPed (ped) Serverside elements are available on clientside. But clientside created elements are not available serverside.
-
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
-
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
-
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.
-
Sometimes by just adding a random debug line in your code, it can reveal not updated code.
-
iprint(source) Did you debug it?
-
As it is now, the code triggers immediately while loading the resource and source is not defined.
-
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?
-
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)
-
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)
-
You might be able to do that with a mask shader: https://wiki.multitheftauto.com/wiki/Shader_examples#Hud_mask
-
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
-
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}
-
What do you mean with that? Are you saying that your scripts are also located in that direction?
-
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. ?
-
Yea that should be fine as far as I can see.
-
You for 99% correct. But there is nothing `extra` to be stored, we only moved things around. If you do not set it's parent to soundContainer, it will not count. If we do nothing: (everything is parallel) <sound></sound> <sound></sound> <sound></sound> <sound></sound> <soundContainer> <!-- no children so we count 0 --> </soundContainer> If we use setElementParent: <soundContainer> <!-- 4 children, so we count 4 --> <sound></sound> <sound></sound> <sound></sound> <sound></sound> </soundContainer>
-
@majqq hmm, maybe another way of making it would be easier for you to build it and it doesn't require any tables. It simply uses the element tree: https://wiki.multitheftauto.com/wiki/Element_tree -- on top local soundContainer = createElement("soundContainer") -- in your function if getElementChildrenCount (soundContainer) < 5 then local sound = [[ ... ]] setElementParent(sound, soundContainer) end If we would visualise this: <soundContainer> <sound></sound> <sound></sound> <sound></sound> <sound></sound> </soundContainer> And the cool thing about it, is that there is nothing you have to clean from a table.
-
1. wav is an uncompressed format ogg is a compressed format. Before a compressed format can be played, your computer has to uncompress it first. A This cost time and memory. There are two very well known ways of compressing. The first one is removing information, which results in quality loss. ? A The second one is restructuring the data and removing spaces in between. But by doing this the format can't be read directly by the media player. It has to be restored to it's original state before it can be played. ? When playing audio repeatedly (for example while firing your weapon), your computer will be uncompressing a ogg file repeatedly, which can cause a bit of lag if your computer can't handle it. 2. You only have to destroy it, when your audio element doesn't stop by itself. For example when looped or streamed. element playSound3D ( string soundPath, float x, float y, float z, [ bool looped = false ] ) 3. local nextShootingTime = 0 -- on top of the script. --- in your function --- local timeNow = getTickCount() if timeNow > nextShootingTime then nextShootingTime = timeNow + 20 -- play audio end 4. You need to learn tables for that...
-
See this topic: That guy has the same issue. You get this error because you send a trigger event, but the clients/players haven't loaded their scripts. This can be either an timing issue or there is another error which causes the script to fail loading. The event onClientResourceStart is a great way to detect when a player can receive triggerClientEvents
-
That depends how good you are with Javascript. I would probably pick CEF for the job, just because you are working item based. But if you are better in lua than JavaScript, dx might be your solution. Also CEF supports SVG, which makes your icons look much more sharper. () And YES!! animated crazy stuff